From d4582a566313449b73a780277bb7c0f1d81a813e Mon Sep 17 00:00:00 2001 From: 5cript Date: Sat, 23 Nov 2024 23:56:40 +0100 Subject: [PATCH 1/2] Changed parcel target to custom command. --- cmake/frontend/emscripten.cmake | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmake/frontend/emscripten.cmake b/cmake/frontend/emscripten.cmake index 219eb9f..bb823f0 100644 --- a/cmake/frontend/emscripten.cmake +++ b/cmake/frontend/emscripten.cmake @@ -42,22 +42,32 @@ function(nui_prepare_emscripten_target) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) - add_custom_target( - ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_TARGET}-parcel + add_custom_command( + OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html" COMMAND ${CMAKE_COMMAND} -E copy_directory "${NUI_SOURCE_DIRECTORY}/nui/js" "${NUI_MODULE_BUILD_DIR}/nui-js" COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_STATIC} "${CMAKE_BINARY_DIR}/static" ${INLINER_COMMAND} COMMAND "${CMAKE_BINARY_DIR}/node_modules/.bin/parcel" build --dist-dir "${CMAKE_BINARY_DIR}/bin" ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_PARCEL_ARGS} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - BYPRODUCTS "${CMAKE_BINARY_DIR}/bin/index.html" DEPENDS "${CMAKE_BINARY_DIR}/bin/index.js" ) + add_custom_target( + ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_TARGET}-parcel + DEPENDS "${CMAKE_BINARY_DIR}/bin/index.html" + ) + if (${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_UNPACKED_MODE}) set(SINGLE_FILE_STRING "") + + add_custom_command( + OUTPUT "${CMAKE_BINARY_DIR}/../bin/index.wasm" + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/index.wasm" "${CMAKE_BINARY_DIR}/../bin/index.wasm" + ) + add_custom_target( ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_TARGET}-copy-wasm - COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/bin/index.wasm" "${CMAKE_BINARY_DIR}/../bin/index.wasm" + DEPENDS "${CMAKE_BINARY_DIR}/../bin/index.wasm" ) add_dependencies(${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_TARGET}-parcel ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_TARGET}-copy-wasm) else() From 937a079a4aa30ed806149b4f72a9f2254add5783 Mon Sep 17 00:00:00 2001 From: 5cript Date: Sun, 24 Nov 2024 00:33:56 +0100 Subject: [PATCH 2/2] Added removal of static dir --- cmake/frontend/emscripten.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/frontend/emscripten.cmake b/cmake/frontend/emscripten.cmake index bb823f0..8e61c12 100644 --- a/cmake/frontend/emscripten.cmake +++ b/cmake/frontend/emscripten.cmake @@ -45,6 +45,7 @@ function(nui_prepare_emscripten_target) add_custom_command( OUTPUT "${CMAKE_BINARY_DIR}/bin/index.html" COMMAND ${CMAKE_COMMAND} -E copy_directory "${NUI_SOURCE_DIRECTORY}/nui/js" "${NUI_MODULE_BUILD_DIR}/nui-js" + COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/static" COMMAND ${CMAKE_COMMAND} -E copy_directory ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_STATIC} "${CMAKE_BINARY_DIR}/static" ${INLINER_COMMAND} COMMAND "${CMAKE_BINARY_DIR}/node_modules/.bin/parcel" build --dist-dir "${CMAKE_BINARY_DIR}/bin" ${NUI_PREPARE_EMSCRIPTEN_TARGET_ARGS_PARCEL_ARGS}