WASM: Fix .html file not generated

This commit is contained in:
halx99 2023-09-05 22:40:25 +08:00
parent 5a528b46e5
commit d7a72ea587
7 changed files with 30 additions and 2 deletions

View File

@ -437,14 +437,19 @@ function(ax_setup_app_config app_name)
endif()
endif()
endif()
endfunction()
# stupid & pitfall: function not emcc not output .html
macro (ax_setup_wasm_app_config app_name)
# setup wasm target
if(WASM)
get_target_property(_APP_SOURCE_DIR ${app_name} SOURCE_DIR)
set(CMAKE_EXECUTABLE_SUFFIX ".html")
target_link_options(${app_name} PRIVATE
"-sEXPORTED_FUNCTIONS=[_main]"
"-sEXPORTED_RUNTIME_METHODS=[ccall,cwrap]"
)
message(STATUS "===== wasm app ${app_name} ${_APP_SOURCE_DIR}/index.html ... ")
set(EMSCRIPTEN_LINK_FLAGS "-lidbfs.js -s MIN_WEBGL_VERSION=2 -s MAX_WEBGL_VERSION=2 -s STACK_SIZE=4mb -s INITIAL_MEMORY=512MB --shell-file ${_APP_SOURCE_DIR}/index.html --use-preload-cache")
# Disable wasm, generate js build?
# string(APPEND EMSCRIPTEN_LINK_FLAGS " -s WASM=0")
@ -458,8 +463,7 @@ function(ax_setup_app_config app_name)
set_target_properties(${app_name} PROPERTIES LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS}")
endif()
endfunction()
endmacro()
# if cc_variable not set, then set it cc_value
macro(ax_set_default_value cc_variable cc_value)

View File

@ -232,3 +232,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()

View File

@ -258,3 +258,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()

View File

@ -613,3 +613,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()

View File

@ -195,3 +195,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()

View File

@ -195,3 +195,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()

View File

@ -239,3 +239,7 @@ endif()
if (NOT DEFINED BUILD_ENGINE_DONE)
ax_uwp_set_all_targets_deploy_min_version()
endif()
if (WASM)
ax_setup_wasm_app_config(${APP_NAME})
endif()