Skip to content

Commit

Permalink
Merge pull request #126 from NuiCpp/fix/better-parcel-target
Browse files Browse the repository at this point in the history
Changed parcel target to custom command.
  • Loading branch information
5cript authored Nov 23, 2024
2 parents 873ad20 + 937a079 commit f7141ff
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cmake/frontend/emscripten.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,33 @@ 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 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}
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()
Expand Down

0 comments on commit f7141ff

Please sign in to comment.