From 8370bdd954fdeeacd03a7dd4bdec8fab45cd0760 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 16 Jan 2025 00:47:03 +0800 Subject: [PATCH] Fix wasm64 build --- 1k/1kiss.ps1 | 51 +++++++++++-------- 1k/build.profiles | 2 +- .../manual/LuaBasicConversions.cpp | 4 +- .../lua-bindings/manual/LuaBasicConversions.h | 4 +- manifest.json | 2 +- tools/cmdline/axmol | 8 ++- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/1k/1kiss.ps1 b/1k/1kiss.ps1 index 866037a9bb8f..4f558f20ff4a 100644 --- a/1k/1kiss.ps1 +++ b/1k/1kiss.ps1 @@ -1494,9 +1494,8 @@ function setup_gclient() { } # preprocess methods: -# -inputOptions [CMAKE_OPTIONS] -function preprocess_win([string[]]$inputOptions) { - $outputOptions = $inputOptions +function preprocess_win() { + $outputOptions = @() if ($options.sdk) { $outputOptions += "-DCMAKE_SYSTEM_VERSION=$($options.sdk)" @@ -1551,21 +1550,22 @@ function preprocess_win([string[]]$inputOptions) { # Generate mingw $Script:cmake_generator = 'Ninja Multi-Config' } - return $outputOptions + # refer: https://devblogs.microsoft.com/powershell/array-literals-in-powershell + return ,$outputOptions } -function preprocess_linux([string[]]$inputOptions) { - $outputOptions = $inputOptions +function preprocess_linux() { + $outputOptions = @() if ($Global:is_clang) { $outputOptions += '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++' } - return $outputOptions + return ,$outputOptions } $ninja_prog = $null $is_gradlew = $options.xt.Contains('gradlew') -function preprocess_andorid([string[]]$inputOptions) { - $outputOptions = $inputOptions +function preprocess_andorid() { + $outputOptions = @() $t_archs = @{arm64 = 'arm64-v8a'; armv7 = 'armeabi-v7a'; x64 = 'x86_64'; x86 = 'x86'; } @@ -1605,11 +1605,11 @@ function preprocess_andorid([string[]]$inputOptions) { $outputOptions += '-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER' } - return $outputOptions + return ,$outputOptions } -function preprocess_osx([string[]]$inputOptions) { - $outputOptions = $inputOptions +function preprocess_osx() { + $outputOptions = @() $arch = $options.a if ($arch -eq 'x64') { $arch = 'x86_64' @@ -1619,12 +1619,12 @@ function preprocess_osx([string[]]$inputOptions) { if ($Global:target_minsdk) { $outputOptions += "-DCMAKE_OSX_DEPLOYMENT_TARGET=$Global:target_minsdk" } - return $outputOptions + return ,$outputOptions } # build ios famliy (ios,tvos,watchos) -function preprocess_ios([string[]]$inputOptions) { - $outputOptions = $inputOptions +function preprocess_ios() { + $outputOptions = @() $arch = $options.a if ($arch -eq 'x64') { $arch = 'x86_64' @@ -1642,12 +1642,11 @@ function preprocess_ios([string[]]$inputOptions) { $outputOptions += '-DSIMULATOR=TRUE' } } - return $outputOptions + return ,$outputOptions } -function preprocess_wasm([string[]]$inputOptions) { - if ($options.p -eq 'wasm64') { $inputOptions += '-DCMAKE_C_FLAGS="-Wno-experimental -sMEMORY64"', '-DCMAKE_CXX_FLAGS="-Wno-experimental -sMEMORY64"', '-DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64' } - return $inputOptions +function preprocess_wasm() { + return ,@() } function validHostAndToolchain() { @@ -1696,7 +1695,7 @@ function validHostAndToolchain() { } } -$proprocessTable = @{ +$preprocessTable = @{ 'win32' = ${function:preprocess_win}; 'winrt' = ${function:preprocess_win}; 'linux' = ${function:preprocess_linux}; @@ -1830,7 +1829,17 @@ if (!$setupOnly) { $1k.println("Building target $TARGET_OS on $HOST_OS_NAME with toolchain $TOOLCHAIN ...") # step1. preprocess cross make options - $CONFIG_ALL_OPTIONS = [array]$(& $proprocessTable[$TARGET_OS] -inputOptions @() ) + $CONFIG_ALL_OPTIONS = & $preprocessTable[$TARGET_OS] + + if (!$is_win_family) { + $cm_cflags = '-fPIC' + if ($TARGET_OS -eq 'wasm64') { + $cm_cflags += ' -sMEMORY64' + $CONFIG_ALL_OPTIONS += '-DEMSCRIPTEN_SYSTEM_PROCESSOR=x86_64', '-DCMAKE_CXX_FLAGS=-sMEMORY64' + } + + $CONFIG_ALL_OPTIONS += "-DCMAKE_C_FLAGS=$cm_cflags" + } if (!$CONFIG_ALL_OPTIONS) { $CONFIG_ALL_OPTIONS = @() diff --git a/1k/build.profiles b/1k/build.profiles index 1eb1637ee966..70bebca87de6 100644 --- a/1k/build.profiles +++ b/1k/build.profiles @@ -73,6 +73,6 @@ android-studio=2024.2.1+ # --- region platform:wasm -emsdk=3.1.72~4.0.0 +emsdk=3.1.72~4.0.1 # --- endregion diff --git a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp index e1a537621ec2..ed7066895092 100644 --- a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp +++ b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.cpp @@ -666,7 +666,7 @@ bool luaval_to_rect(lua_State* L, int lo, Rect* outValue, const char* funcName) return ok; } -bool luaval_to_Color32(lua_State* L, int lo, Color32* outValue, const char* funcName) +bool luaval_to_color32(lua_State* L, int lo, Color32* outValue, const char* funcName) { if (NULL == L || NULL == outValue) return false; @@ -2367,7 +2367,7 @@ void rect_to_luaval(lua_State* L, const Rect& rt) lua_rawset(L, -3); /* table[key] = value, L: table */ } -void Color32_to_luaval(lua_State* L, const Color32& color) +void color32_to_luaval(lua_State* L, const Color32& color) { if (NULL == L) return; diff --git a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h index bde83ab97fde..47f4d1fd43db 100644 --- a/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h +++ b/extensions/scripting/lua-bindings/manual/LuaBasicConversions.h @@ -295,7 +295,7 @@ extern AX_LUA_DLL bool luaval_to_color3b(lua_State* L, int lo, Color3B* outValue * @param funcName the name of calling function, it is used for error output in the debug model. * @return Return true if the value at the given acceptable index of stack is a table, otherwise return false. */ -extern bool luaval_to_Color32(lua_State* L, int lo, Color32* outValue, const char* funcName = ""); +extern bool luaval_to_color32(lua_State* L, int lo, Color32* outValue, const char* funcName = ""); /** * Get a ax::Color object value from the given acceptable index of stack. @@ -949,7 +949,7 @@ extern AX_LUA_DLL void color3b_to_luaval(lua_State* L, const Color3B& cc); * @param L the current lua_State. * @param cc a ax::Color32 object. */ -extern void Color32_to_luaval(lua_State* L, const Color32& cc); +extern void color32_to_luaval(lua_State* L, const Color32& cc); /** * Push a table converted from a ax::Color object into the Lua stack. diff --git a/manifest.json b/manifest.json index 6a75fa3f392f..6fd1fb536d91 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "versions": { - "1kdist": "v96", + "1kdist": "v97", "oboe": "1.9.3", "kcp": "v1.7-f2aa30e", "lz4": "v1.10.0", diff --git a/tools/cmdline/axmol b/tools/cmdline/axmol index 0a3999e002df..805b0f7f570b 100755 --- a/tools/cmdline/axmol +++ b/tools/cmdline/axmol @@ -1,13 +1,11 @@ #!/bin/bash -l -AXMOL_CONSOLE_BIN_DIRECTORY=$(dirname "$0") -AXMOL_CONSOLE_BIN_DIRECTORY=$(cd "$AXMOL_CONSOLE_BIN_DIRECTORY" && pwd -P) - +SCRIPT_ROOT=$(dirname "$0") +SCRIPT_ROOT=$(cd "$SCRIPT_ROOT" && pwd -P) if hash pwsh 2>/dev/null; then POWERSHELL=pwsh else echo "PowerShell 7+ required." exit 1 fi - -$POWERSHELL "$AXMOL_CONSOLE_BIN_DIRECTORY/axmol.ps1" "$@" +$POWERSHELL "$SCRIPT_ROOT/axmol.ps1" "$@"