From de8949ed5b275f26ca381f42753ec613d9516c45 Mon Sep 17 00:00:00 2001 From: Nathanial Lydick Date: Wed, 25 Oct 2023 20:37:00 -0400 Subject: [PATCH 1/5] Use the Urho shell.html rather than generating one from the emscripten default. --- Source/Urho3D/CMakeLists.txt | 7 +++++++ cmake/Modules/UrhoCommon.cmake | 29 +++++++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Source/Urho3D/CMakeLists.txt b/Source/Urho3D/CMakeLists.txt index 43cf8f398..a57b9fe6f 100644 --- a/Source/Urho3D/CMakeLists.txt +++ b/Source/Urho3D/CMakeLists.txt @@ -645,3 +645,10 @@ endif () if (URHO3D_FORCE_AS_MAX_PORTABILITY) add_definitions (-DAS_MAX_PORTABILITY) endif () + +# Symlink/copy html shell for use by downstream projects +if (WEB) + # Ensure the output directory exist before creating the symlink + file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + create_symlink (${CMAKE_SOURCE_DIR}/bin/shell.html ${CMAKE_BINARY_DIR}/bin/shell.html FALLBACK_TO_COPY) +endif () diff --git a/cmake/Modules/UrhoCommon.cmake b/cmake/Modules/UrhoCommon.cmake index d64c86ac5..17880e83b 100644 --- a/cmake/Modules/UrhoCommon.cmake +++ b/cmake/Modules/UrhoCommon.cmake @@ -1160,19 +1160,28 @@ macro (add_html_shell) check_source_files ("Could not call add_html_shell() macro before define_source_files() macro.") if (EMSCRIPTEN) if (NOT ${ARGN} STREQUAL "") + # Prefer the user-defined shell set (HTML_SHELL ${ARGN}) + elseif (EXISTS ${CMAKE_SOURCE_DIR}/bin/shell.html) + # Fallback to the shell present in the project source + set (HTML_SHELL ${CMAKE_SOURCE_DIR}/bin/shell.html) + elseif (DEFINED URHO3D_HOME AND EXISTS ${URHO3D_HOME}/bin/shell.html) + # Then to the Urho3D shell (full window/screen with no console output) + set (HTML_SHELL ${URHO3D_HOME}/bin/shell.html) + elseif (EXISTS ${EMSCRIPTEN_ROOT_PATH}/src/shell.html) + # Finally create a shell from the emscripten one that embeds the Urho project logo + message (WARNING "Deprecated: Could not find '\${URHO3D_HOME}/bin/shell.html'. Falling back to '${EMSCRIPTEN_ROOT_PATH}/src/shell.html'. This behavior will be removed in a future release.") + file (READ ${EMSCRIPTEN_ROOT_PATH}/src/shell.html HTML_SHELL) + string (REPLACE "" "\n\n" HTML_SHELL "${HTML_SHELL}") # Stringify to preserve semicolons + string (REPLACE "" "\n\n\"link\n" HTML_SHELL "${HTML_SHELL}") + file (WRITE ${CMAKE_BINARY_DIR}/Source/shell.html "${HTML_SHELL}") + set (HTML_SHELL ${CMAKE_BINARY_DIR}/Source/shell.html) else () - # Create Urho3D custom HTML shell that also embeds our own project logo - if (NOT EXISTS ${CMAKE_SOURCE_DIR}/bin/shell.html) - file (READ ${EMSCRIPTEN_ROOT_PATH}/src/shell.html HTML_SHELL) - string (REPLACE "" "\n\n" HTML_SHELL "${HTML_SHELL}") # Stringify to preserve semicolons - string (REPLACE "" "\n\n\"link\n" HTML_SHELL "${HTML_SHELL}") - file (WRITE ${CMAKE_BINARY_DIR}/Source/shell.html "${HTML_SHELL}") - set (HTML_SHELL ${CMAKE_BINARY_DIR}/Source/shell.html) - else () - set (HTML_SHELL ${CMAKE_SOURCE_DIR}/bin/shell.html) - endif () + message (ERROR "Deducing HTML_SHELL failed. \nPlease add \${CMAKE_SOURCE_DIR}/bin/shell.html or update Urho so it provides \${URHO3D_HOME}/bin/shell.html") endif () + if (NOT EXISTS "${HTML_SHELL}") + message (ERROR "Could not find html shell '${HTML_SHELL}'") + endif() list (APPEND SOURCE_FILES ${HTML_SHELL}) set_source_files_properties (${HTML_SHELL} PROPERTIES EMCC_OPTION shell-file) endif () From 5a872e6d6ce7efec14b116e9d77fc03150e71c66 Mon Sep 17 00:00:00 2001 From: Nathanial Lydick Date: Wed, 25 Oct 2023 20:59:39 -0400 Subject: [PATCH 2/5] Remove custom Emscripten toolachain file. Use emcmake instead to use the emsdk version. --- Docs/GettingStarted.dox | 4 +- cmake/Modules/UrhoCommon.cmake | 4 +- cmake/Toolchains/Emscripten.cmake | 196 ------------------------------ script/cmake_generic.bat | 1 - script/cmake_generic.sh | 3 - 5 files changed, 4 insertions(+), 204 deletions(-) delete mode 100644 cmake/Toolchains/Emscripten.cmake diff --git a/Docs/GettingStarted.dox b/Docs/GettingStarted.dox index 14a30e8f7..054eeec54 100644 --- a/Docs/GettingStarted.dox +++ b/Docs/GettingStarted.dox @@ -300,9 +300,9 @@ Execute cmake_mingw.sh then go to the build tree to execute make command. After This section assumes you have already updated, installed, and activated the latest Emscripten cross-compiler toolchain with upstream LLVM WASM backend on your host system as per described in https://emscripten.org/docs/getting_started/downloads.html. -Set the EMSCRIPTEN_ROOT_PATH environment variable or build option to point to the root path of Emscripten cross-compiler tools. Alternatively, call the emsdk_env script to set the EMSCRIPTEN environment variable for you. The Emscripten sysroot path will be derived from the root path, usually from 'system' subdir relative to the root path. However, you can optionally set the EMSCRIPTEN_SYSROOT environment variable or build option to point to another system root path. +Use the emcmake or emcmake.bat wrapper to set the emscripten toolchain file for you. This will set the needed cmake build options for the Emscripten cross-compiler tools. This can be called from the installed emsdk as an absolute path within the emsdk or you can source the emsdk_env script (extension depending on your shell) to add the tools to the path. -On Windows host, execute cmake_emscripten.bat. On MacOS or Linux host, execute cmake_emscripten.sh. Then go to the build tree and execute the 'make' command to start the build as usual. You may want to set the URHO3D_SAMPLES build option to build all the samples. You may also optionally set the URHO3D_LUA build option to enable Lua scripting support. If you encounter "Too many open files" warning when archiving the Urho3D static library, follow by "Unresolved symbol" errors on MacOS then you have to increase the soft-limit in your host system before rebuilding the library and all the main targets. +On Windows host, execute "emcmake.bat cmake_emscripten.bat". On MacOS or Linux host, execute "emcmake cmake_emscripten.sh". Then go to the build tree and execute the 'make' command to start the build as usual. If you encounter "Too many open files" warning when archiving the Urho3D static library, follow by "Unresolved symbol" errors on MacOS then you have to increase the soft-limit in your host system before rebuilding the library and all the main targets. For example, to double the limit (which normally defaults to 256 on MacOS): \verbatim diff --git a/cmake/Modules/UrhoCommon.cmake b/cmake/Modules/UrhoCommon.cmake index 17880e83b..fc5293f03 100644 --- a/cmake/Modules/UrhoCommon.cmake +++ b/cmake/Modules/UrhoCommon.cmake @@ -353,8 +353,8 @@ if (RPI) set (RPI_ABI ${RPI_ABI} CACHE STRING "Specify target ABI (RPI platform only), possible values are RPI0, RPI1, RPI2, RPI3, RPI4" FORCE) endif () if (EMSCRIPTEN) # CMAKE_CROSSCOMPILING is always true for Emscripten - set (EMSCRIPTEN_ROOT_PATH "" CACHE PATH "Root path to Emscripten cross-compiler tools (Emscripten only)") - set (EMSCRIPTEN_SYSROOT "" CACHE PATH "Path to Emscripten system root (Emscripten only)") + set (EMSCRIPTEN_ROOT_PATH "${EMSCRIPTEN_ROOT_PATH}" CACHE PATH "Root path to Emscripten cross-compiler tools (Emscripten only)") + set (EMSCRIPTEN_SYSROOT "${EMSCRIPTEN_SYSROOT}" CACHE PATH "Path to Emscripten system root (Emscripten only)") option (EMSCRIPTEN_AUTO_SHELL "Auto adding a default HTML shell-file when it is not explicitly specified (Emscripten only)" TRUE) option (EMSCRIPTEN_ALLOW_MEMORY_GROWTH "Enable memory growing based on application demand, default to true as there should be little or no overhead (Emscripten only)" TRUE) math (EXPR EMSCRIPTEN_TOTAL_MEMORY "128 * 1024 * 1024") diff --git a/cmake/Toolchains/Emscripten.cmake b/cmake/Toolchains/Emscripten.cmake deleted file mode 100644 index 389369811..000000000 --- a/cmake/Toolchains/Emscripten.cmake +++ /dev/null @@ -1,196 +0,0 @@ -# -# Copyright (c) 2008-2022 the Urho3D project. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -# Workaround try_compile() limitation where it cannot yet see cache variables during initial configuration -get_property (IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) -if (IN_TRY_COMPILE) - foreach (VAR $ENV{VARS}) - set (${VAR} $ENV{${VAR}}) - endforeach () -else () - # Prevent critical variables from changing after the initial configuration - if (CMAKE_CROSSCOMPILING) - set (SAVED_EMSCRIPTEN_ROOT_PATH ${EMSCRIPTEN_ROOT_PATH} CACHE INTERNAL "Initial value for EMSCRIPTEN_ROOT_PATH") - set (SAVED_EMSCRIPTEN_SYSROOT ${EMSCRIPTEN_SYSROOT} CACHE INTERNAL "Initial value for EMSCRIPTEN_SYSROOT") - # Save the initial values of CC and CXX environment variables - set (SAVED_CC $ENV{CC} CACHE INTERNAL "Initial value for CC") - set (SAVED_CXX $ENV{CXX} CACHE INTERNAL "Initial value for CXX") - return () - elseif ((SAVED_EMSCRIPTEN_ROOT_PATH AND NOT SAVED_EMSCRIPTEN_ROOT_PATH STREQUAL EMSCRIPTEN_ROOT_PATH) OR (SAVED_EMSCRIPTEN_SYSROOT AND NOT SAVED_EMSCRIPTEN_SYSROOT STREQUAL EMSCRIPTEN_SYSROOT)) - set (EMSCRIPTEN_ROOT_PATH ${SAVED_EMSCRIPTEN_ROOT_PATH} CACHE STRING "Root path to Emscripten cross-compiler tools (Emscripten only)" FORCE) - set (EMSCRIPTEN_SYSROOT ${SAVED_EMSCRIPTEN_SYSROOT} CACHE PATH "Path to Emscripten system root (Emscripten only)" FORCE) - message (FATAL_ERROR "EMSCRIPTEN_ROOT_PATH and EMSCRIPTEN_SYSROOT cannot be changed after the initial configuration/generation. " - "If you wish to change that then the build tree would have to be regenerated from scratch. Auto reverting to its initial value.") - endif () -endif () - -# Reference toolchain variable to suppress "unused variable" warning -if (CMAKE_TOOLCHAIN_FILE) - mark_as_advanced (CMAKE_TOOLCHAIN_FILE) -endif () - -# This one is important -set (CMAKE_SYSTEM_NAME Linux) -# This one not so much -set (CMAKE_SYSTEM_VERSION 1) - -# System root -if (NOT IN_TRY_COMPILE) - if (NOT SAVED_EMSCRIPTEN_ROOT_PATH) - if (NOT EMSCRIPTEN_ROOT_PATH) - if (DEFINED ENV{EMSCRIPTEN_ROOT_PATH}) - file (TO_CMAKE_PATH $ENV{EMSCRIPTEN_ROOT_PATH} EMSCRIPTEN_ROOT_PATH) - elseif (DEFINED ENV{EM_CONFIG}) - # Attempt to auto detect the Emscripten root path from the config file - file (STRINGS $ENV{EM_CONFIG} EMSCRIPTEN_ROOT_PATH REGEX "^EMSCRIPTEN_ROOT = '.*'$") - if (EMSCRIPTEN_ROOT_PATH) - string (REGEX REPLACE "^EMSCRIPTEN_ROOT = '(.*)'$" \\1 EMSCRIPTEN_ROOT_PATH ${EMSCRIPTEN_ROOT_PATH}) - else () - # Newer config file requires Python to actually evaluate it, basically, `cat $EM_CONFIG <(echo 'print(EMSCRIPTEN_ROOT)') |python -` - file (STRINGS $ENV{EM_CONFIG} EM_CONFIG NEWLINE_CONSUME) - execute_process (COMMAND ${CMAKE_COMMAND} -E echo "${EM_CONFIG}\nprint(EMSCRIPTEN_ROOT)" - COMMAND python - OUTPUT_VARIABLE EMSCRIPTEN_ROOT_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) - endif () - endif () - endif () - set (EMSCRIPTEN_ROOT_PATH ${EMSCRIPTEN_ROOT_PATH} CACHE STRING "Root path to Emscripten cross-compiler tools (Emscripten only)") - if (NOT EXISTS ${EMSCRIPTEN_ROOT_PATH}/emcc${TOOL_EXT}) - message (FATAL_ERROR "Could not find Emscripten cross compilation tool. " - "Use EMSCRIPTEN_ROOT_PATH environment variable or build option to specify the location of the toolchain. " - "Or use the canonical EMSCRIPTEN environment variable by calling emsdk_env script.") - endif () - endif () - if (NOT SAVED_EMSCRIPTEN_SYSROOT) - if (NOT EMSCRIPTEN_SYSROOT) - if (DEFINED ENV{EMSCRIPTEN_SYSROOT}) - file (TO_CMAKE_PATH $ENV{EMSCRIPTEN_SYSROOT} EMSCRIPTEN_SYSROOT) - else () - set (EMSCRIPTEN_SYSROOT ${EMSCRIPTEN_ROOT_PATH}/system) - endif () - endif () - set (EMSCRIPTEN_SYSROOT ${EMSCRIPTEN_SYSROOT} CACHE PATH "Path to Emscripten system root (Emscripten only)") - if (NOT EXISTS ${EMSCRIPTEN_SYSROOT}) - message (FATAL_ERROR "Could not find Emscripten system root. " - "Use EMSCRIPTEN_SYSROOT environment variable or build option to specify the location of system root.") - endif () - endif () -endif () -set (CMAKE_SYSROOT ${EMSCRIPTEN_SYSROOT}) -# Only search libraries and headers in sysroot -set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -# Cross compiler tools -if (CMAKE_HOST_WIN32) - set (TOOL_EXT .bat) -endif () -if (NOT EMSCRIPTEN_EMCC_VERSION) - execute_process (COMMAND ${EMSCRIPTEN_ROOT_PATH}/emcc${TOOL_EXT} --version RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE EMSCRIPTEN_EMCC_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (EXIT_CODE EQUAL 0) - message (${EMSCRIPTEN_EMCC_VERSION}) - string (REGEX MATCH "[^ .]+\\.[^.]+\\.[^ ]+" EMSCRIPTEN_EMCC_VERSION "${EMSCRIPTEN_EMCC_VERSION}") - else () - message (FATAL_ERROR "Could not determine the emcc version. Make sure you have installed and activated the Emscripten SDK correctly.") - endif () - set (EMSCRIPTEN_EMCC_VERSION ${EMSCRIPTEN_EMCC_VERSION} CACHE INTERNAL "emcc version being used in this build tree") - if (EMSCRIPTEN_EMCC_VERSION VERSION_LESS 1.39.0) - message (FATAL_ERROR "Emscripten SDK 1.39.0 or later is required.") - endif () -endif () -if (NOT EMSCRIPTEN_COMPILER_PATH) - set (EMSCRIPTEN_COMPILER_PATH ${EMSCRIPTEN_ROOT_PATH}) - if ("$ENV{USE_CCACHE}" AND NOT CMAKE_HOST_WIN32) - execute_process (COMMAND whereis -b ccache COMMAND grep -o \\S*lib\\S* OUTPUT_VARIABLE CCACHE_SYMLINK ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (CCACHE_SYMLINK AND EXISTS ${CCACHE_SYMLINK}/emcc AND EXISTS ${CCACHE_SYMLINK}/em++) - set (EMSCRIPTEN_COMPILER_PATH ${CCACHE_SYMLINK}) - else () - # Fallback to create the ccache symlink in the build tree itself - execute_process (COMMAND which ccache RESULT_VARIABLE EXIT_CODE OUTPUT_VARIABLE CCACHE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (EXIT_CODE EQUAL 0 AND CCACHE) - foreach (TOOL emcc em++) - execute_process (COMMAND ${CMAKE_COMMAND} -E create_symlink ${CCACHE} ${CMAKE_BINARY_DIR}/${TOOL}) - endforeach () - set (EMSCRIPTEN_COMPILER_PATH ${CMAKE_BINARY_DIR}) - else () - message (WARNING "ccache may not have been installed on this host system. " - "This is required to enable ccache support for Emscripten compiler toolchain. " - "CMake has been configured to use the actual compiler toolchain instead of ccache. " - "In order to rectify this, the build tree must be regenerated after installing ccache.") - endif () - endif () - if (NOT EMSCRIPTEN_COMPILER_PATH STREQUAL EMSCRIPTEN_ROOT_PATH AND NOT $ENV{PATH} MATCHES ${EMSCRIPTEN_ROOT_PATH}) - message (FATAL_ERROR "The bin directory containing the compiler toolchain (${EMSCRIPTEN_ROOT_PATH}) has not been added in the PATH environment variable. " - "This is required to enable ccache support for Emscripten compiler toolchain.") - endif () - endif () - set (EMSCRIPTEN_COMPILER_PATH ${EMSCRIPTEN_COMPILER_PATH} CACHE INTERNAL "Path to C/C++ compiler tool symlinks or to the actual tools if not using ccache") -endif () -set (CMAKE_C_COMPILER ${EMSCRIPTEN_COMPILER_PATH}/emcc${TOOL_EXT} CACHE PATH "C compiler") -set (CMAKE_CXX_COMPILER ${EMSCRIPTEN_COMPILER_PATH}/em++${TOOL_EXT} CACHE PATH "C++ compiler") -set (CMAKE_AR ${EMSCRIPTEN_ROOT_PATH}/emar${TOOL_EXT} CACHE PATH "archive") -set (CMAKE_RANLIB ${EMSCRIPTEN_ROOT_PATH}/emranlib${TOOL_EXT} CACHE PATH "ranlib") -set (CMAKE_LINKER ${EMSCRIPTEN_ROOT_PATH}/emlink.py CACHE PATH "linker") -# Specific to Emscripten -set (EMRUN ${EMSCRIPTEN_ROOT_PATH}/emrun${TOOL_EXT} CACHE PATH "emrun") -set (EMPACKAGER python ${EMSCRIPTEN_ROOT_PATH}/tools/file_packager.py CACHE PATH "file_packager.py") -set (EMBUILDER python ${EMSCRIPTEN_ROOT_PATH}/embuilder.py CACHE PATH "embuilder.py") - -# Still perform the compiler checks except for those stated otherwise below -foreach (LANG C CXX) - # Since currently CMake does not able to identify Emscripten compiler toolchain, set the compiler identification explicitly - set (CMAKE_${LANG}_COMPILER_ID_RUN TRUE) - set (CMAKE_${LANG}_COMPILER_ID Clang) - set (CMAKE_${LANG}_COMPILER_VERSION ${EMSCRIPTEN_EMCC_VERSION}) - # The ABI info could not be checked as per normal as CMake does not understand the test build output from Emscripten, so bypass it also - set (CMAKE_${LANG}_ABI_COMPILED TRUE) - set (CMAKE_${LANG}_SIZEOF_DATA_PTR 4) # Assume it is always 32-bit for now (we could have used our CheckCompilerToolChains.cmake module here) - # We could not set CMAKE_EXECUTABLE_SUFFIX directly because CMake processes platform configuration files after the toolchain file and since we tell CMake that we are cross-compiling for 'Linux' platform (Emscripten is not a valid platform yet in CMake) via CMAKE_SYSTEM_NAME variable, as such CMake force initializes the CMAKE_EXECUTABLE_SUFFIX to empty string (as expected for Linux platform); To workaround it we have to use CMAKE_EXECUTABLE_SUFFIX_C and CMAKE_EXECUTABLE_SUFFIX_CXX instead, which are fortunately not being touched by platform configuration files - set (CMAKE_EXECUTABLE_SUFFIX_${LANG} .js) -endforeach () - -# Set required compiler flags for various internal CMake checks which rely on the compiler/linker error to be occured for the check to be performed correctly -set (CMAKE_REQUIRED_FLAGS "-s ERROR_ON_UNDEFINED_SYMBOLS=1") - -# Use response files on Windows host -if (CMAKE_HOST_WIN32) - foreach (lang C CXX) - foreach (cat LIBRARIES OBJECTS INCLUDES) - set (CMAKE_${lang}_USE_RESPONSE_FILE_FOR_${cat} 1) - endforeach () - set (CMAKE_${lang}_CREATE_STATIC_LIBRARY " cr ") - endforeach () -endif () - -# Workaround try_compile() limitation where it cannot yet see cache variables during initial configuration -if (NOT IN_TRY_COMPILE) - get_cmake_property (CACHE_VARIABLES CACHE_VARIABLES) - foreach (VAR ${CACHE_VARIABLES}) - if (VAR MATCHES ^EMSCRIPTEN_|CMAKE_CX*_COMPILER) - set (ENV{${VAR}} ${${VAR}}) - list (APPEND VARS ${VAR}) - endif () - endforeach () - set (ENV{VARS} "${VARS}") # Stringify to keep the list together -endif () - -set (EMSCRIPTEN 1) diff --git a/script/cmake_generic.bat b/script/cmake_generic.bat index beb76e4ee..21d4b44bf 100644 --- a/script/cmake_generic.bat +++ b/script/cmake_generic.bat @@ -47,7 +47,6 @@ set "arch=" :loop if not "%~1" == "" ( if "%~1" == "-D" ( - if "%~2" == "WEB" if "%~3" == "1" set "OPTS=-G "MinGW Makefiles" -D CMAKE_TOOLCHAIN_FILE="%TOOLCHAINS%\Emscripten.cmake"" if "%~2" == "MINGW" if "%~3" == "1" set "OPTS=-G "MinGW Makefiles"" if "%~2" == "URHO3D_64BIT" if "%~3" == "1" set "arch=-A x64" if "%~2" == "URHO3D_64BIT" if "%~3" == "0" set "arch=-A Win32" diff --git a/script/cmake_generic.sh b/script/cmake_generic.sh index 744c8c563..abb34d3c0 100755 --- a/script/cmake_generic.sh +++ b/script/cmake_generic.sh @@ -47,9 +47,6 @@ for a in $@; do MINGW=1) OPTS=(-D CMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/MinGW.cmake) ;; - WEB=1) - OPTS=(-D CMAKE_TOOLCHAIN_FILE=$TOOLCHAINS/Emscripten.cmake) - ;; esac done From 3d5bbaeb40e000d977ad5b3ffd9b305ce9dbf587 Mon Sep 17 00:00:00 2001 From: Nathanial Lydick Date: Wed, 25 Oct 2023 21:06:16 -0400 Subject: [PATCH 3/5] Backport SDL setWindowTitle fix for newer emscripten versions. --- .../SDL/src/video/emscripten/SDL_emscriptenvideo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/ThirdParty/SDL/src/video/emscripten/SDL_emscriptenvideo.c b/Source/ThirdParty/SDL/src/video/emscripten/SDL_emscriptenvideo.c index 458d67afd..a29845160 100644 --- a/Source/ThirdParty/SDL/src/video/emscripten/SDL_emscriptenvideo.c +++ b/Source/ThirdParty/SDL/src/video/emscripten/SDL_emscriptenvideo.c @@ -347,8 +347,12 @@ Emscripten_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * di static void Emscripten_SetWindowTitle(_THIS, SDL_Window * window) { + // Urho3D: newer emscripten uses a free function and not one in the module. Taken from newer SDL. EM_ASM_INT({ - if (typeof Module['setWindowTitle'] !== 'undefined') { + if (typeof setWindowTitle !== 'undefined') { + setWindowTitle(UTF8ToString($0)); + } + else if (typeof Module['setWindowTitle'] !== 'undefined') { Module['setWindowTitle'](UTF8ToString($0)); } return 0; From 10a799cb6770323452c169175d8a33ebacc8241a Mon Sep 17 00:00:00 2001 From: Nathanial Lydick Date: Thu, 26 Oct 2023 18:01:20 -0400 Subject: [PATCH 4/5] Added click-to-play delay to shell.html to ensure audio will be allowed. --- bin/shell.html | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/bin/shell.html b/bin/shell.html index f6a4a16cd..2a59477e0 100644 --- a/bin/shell.html +++ b/bin/shell.html @@ -6,12 +6,23 @@ U3D