Skip to content

Commit

Permalink
Fix wasm64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Jan 17, 2025
1 parent a59e15c commit 8370bdd
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 32 deletions.
51 changes: 30 additions & 21 deletions 1k/1kiss.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1494,9 +1494,8 @@ function setup_gclient() {
}

# preprocess methods:
# <param>-inputOptions</param> [CMAKE_OPTIONS]
function preprocess_win([string[]]$inputOptions) {
$outputOptions = $inputOptions
function preprocess_win() {
$outputOptions = @()

if ($options.sdk) {
$outputOptions += "-DCMAKE_SYSTEM_VERSION=$($options.sdk)"
Expand Down Expand Up @@ -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'; }

Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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() {
Expand Down Expand Up @@ -1696,7 +1695,7 @@ function validHostAndToolchain() {
}
}

$proprocessTable = @{
$preprocessTable = @{
'win32' = ${function:preprocess_win};
'winrt' = ${function:preprocess_win};
'linux' = ${function:preprocess_linux};
Expand Down Expand Up @@ -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 = @()
Expand Down
2 changes: 1 addition & 1 deletion 1k/build.profiles
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"versions": {
"1kdist": "v96",
"1kdist": "v97",
"oboe": "1.9.3",
"kcp": "v1.7-f2aa30e",
"lz4": "v1.10.0",
Expand Down
8 changes: 3 additions & 5 deletions tools/cmdline/axmol
Original file line number Diff line number Diff line change
@@ -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" "$@"

0 comments on commit 8370bdd

Please sign in to comment.