Skip to content

Commit

Permalink
Add experimental wasm64 support
Browse files Browse the repository at this point in the history
really experimental, just build, can't run yet
  • Loading branch information
halx99 committed Apr 12, 2024
1 parent a0f2c4e commit 1fff0fa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
29 changes: 19 additions & 10 deletions 1k/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ $options = @{
sdk = ''
minsdk = $null
dll = $false
u = $false # whether delete 1kdist cross-platform prebuilt folder: path/to/_x
u = $false # whether delete 1kdist cross-platform prebuilt folder: path/to/_x
}

$optName = $null
foreach ($arg in $args) {
if (!$optName) {
if ($arg.StartsWith('-')) {
$optName = $arg.SubString(1)
if($optName.EndsWith(':')) {
if ($optName.EndsWith(':')) {
$optName = $optName.TrimEnd(':')
}
if ($optName.startsWith('j')) {
Expand Down Expand Up @@ -305,8 +305,8 @@ else {
}

$Global:target_minsdk = $options.minsdk
if(!$Global:target_minsdk) {
$Global:target_minsdk = @{osx = '10.15'; winrt = '10.0.17763.0'}[$TARGET_OS]
if (!$Global:target_minsdk) {
$Global:target_minsdk = @{osx = '10.15'; winrt = '10.0.17763.0' }[$TARGET_OS]
}

# define some useful global vars
Expand All @@ -331,7 +331,7 @@ function create_symlink($sourcePath, $destPath) {
}
}

$Global:is_wasm = $TARGET_OS -eq 'wasm'
$Global:is_wasm = $TARGET_OS.StartsWith('wasm')
$Global:is_win32 = $TARGET_OS -eq 'win32'
$Global:is_winrt = $TARGET_OS -eq 'winrt'
$Global:is_mac = $TARGET_OS -eq 'osx'
Expand Down Expand Up @@ -394,6 +394,7 @@ $toolchains = @{
'tvos' = 'clang'; # xcode clang
'watchos' = 'clang'; # xcode clang
'wasm' = 'clang'; # emcc clang
'wasm64' = 'clang'; # emcc clang
}
if (!$TOOLCHAIN) {
$TOOLCHAIN = $toolchains[$TARGET_OS]
Expand Down Expand Up @@ -1307,7 +1308,7 @@ function preprocess_win([string[]]$inputOptions) {
# platform
if ($Global:is_winrt) {
$outputOptions += '-DCMAKE_SYSTEM_NAME=WindowsStore', '-DCMAKE_SYSTEM_VERSION=10.0'
if($Global:target_minsdk) {
if ($Global:target_minsdk) {
$outputOptions += "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION=$Global:target_minsdk"
}
}
Expand Down Expand Up @@ -1389,7 +1390,7 @@ function preprocess_osx([string[]]$inputOptions) {
}

$outputOptions += "-DCMAKE_OSX_ARCHITECTURES=$arch"
if($Global:target_minsdk) {
if ($Global:target_minsdk) {
$outputOptions += "-DCMAKE_OSX_DEPLOYMENT_TARGET=$Global:target_minsdk"
}
return $outputOptions
Expand All @@ -1411,14 +1412,15 @@ function preprocess_ios([string[]]$inputOptions) {
elseif ($Global:is_watchos) {
$outputOptions += '-DPLAT=watchOS'
}
if($Global:is_ios_sim) {
if ($Global:is_ios_sim) {
$outputOptions += '-DSIMULATOR=TRUE'
}
}
return $outputOptions
}

function preprocess_wasm([string[]]$inputOptions) {
if ($options.p -eq 'wasm64') { $inputOptions += '-DCMAKE_C_FLAGS="-sMEMORY64 -Wno-experimental"', '-DCMAKE_CXX_FLAGS=-sMEMORY64 -Wno-experimental'}
return $inputOptions
}

Expand Down Expand Up @@ -1452,6 +1454,10 @@ function validHostAndToolchain() {
'host' = @{'windows' = $True; 'linux' = $True; 'macos' = $True };
'toolchain' = @{'clang' = $True; };
};
'wasm64' = @{
'host' = @{'windows' = $True; 'linux' = $True; 'macos' = $True };
'toolchain' = @{'clang' = $True; };
};
}
$validInfo = $validTable[$TARGET_OS]
$validOS = $validInfo.host[$HOST_OS_NAME]
Expand All @@ -1474,6 +1480,7 @@ $proprocessTable = @{
'tvos' = ${function:preprocess_ios};
'watchos' = ${function:preprocess_ios};
'wasm' = ${Function:preprocess_wasm};
'wasm64' = ${Function:preprocess_wasm};
}

validHostAndToolchain
Expand Down Expand Up @@ -1600,7 +1607,7 @@ if (!$setupOnly) {
$CONFIG_ALL_OPTIONS = @()
}

if($options.u) {
if ($options.u) {
$CONFIG_ALL_OPTIONS += '-D_1KFETCH_DIST_UPGRADE=TRUE'
}

Expand All @@ -1613,6 +1620,7 @@ if (!$setupOnly) {
'linux' = 'Unix Makefiles'
'android' = 'Ninja'
'wasm' = 'Ninja'
'wasm64' = 'Ninja'
'osx' = 'Xcode'
'ios' = 'Xcode'
'tvos' = 'Xcode'
Expand Down Expand Up @@ -1710,7 +1718,8 @@ if (!$setupOnly) {
else {
if ($optimize_flag -eq 'Debug') {
& $build_tool configureCMakeDebug prepareKotlinBuildScriptModel $CONFIG_ALL_OPTIONS | Out-Host
} else {
}
else {
& $build_tool configureCMakeRelWithDebInfo prepareKotlinBuildScriptModel $CONFIG_ALL_OPTIONS | Out-Host
}
}
Expand Down
10 changes: 7 additions & 3 deletions 1k/platforms.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
set(PLATFORM_NAME linux)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(WASM TRUE)
set(EMSCRIPTEN TRUE)
set(PLATFORM_NAME wasm)
set(WASM TRUE)
set(EMSCRIPTEN TRUE)
if ("${CMAKE_LIBRARY_ARCHITECTURE}" MATCHES "64")
set(PLATFORM_NAME wasm64)
else()
set(PLATFORM_NAME wasm)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(APPLE TRUE)
set(MACOSX TRUE)
Expand Down
4 changes: 2 additions & 2 deletions cmake/Modules/AXConfigDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ if(EMSCRIPTEN)
# must via CMAKE_C_FLAGS and CMAKE_CXX_FLAGS?
set(_AX_EMCC_FLAGS "-sUSE_LIBJPEG=1 -sUSE_ZLIB=1")

set(CMAKE_C_FLAGS ${_AX_EMCC_FLAGS})
set(CMAKE_CXX_FLAGS ${_AX_EMCC_FLAGS})
set(CMAKE_C_FLAGS "${_AX_EMCC_FLAGS} ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${_AX_EMCC_FLAGS} ${CMAKE_CXX_FLAGS}")
endif()

# apply axmol spec compile options
Expand Down
2 changes: 1 addition & 1 deletion tools/console/axmol.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function axmol_run() {
println "Launching $launch_linuxapp ..."
Start-Process -FilePath $launch_linuxapp -WorkingDirectory $(Split-Path $launch_linuxapp -Parent)
}
elseif ($TARGET_OS -eq 'wasm') {
elseif ($TARGET_OS.startsWith('wasm')) {
$launch_wasmapp = Join-Path $BUILD_DIR "bin/$cmake_target/$cmake_target.html"
println "Launching $launch_wasmapp ..."
emrun $launch_wasmapp
Expand Down

0 comments on commit 1fff0fa

Please sign in to comment.