2023-03-11 22:10:18 +08:00
|
|
|
######## the 1k build script for targets: win32, winuwp
|
|
|
|
## examples:
|
2023-04-02 16:04:19 +08:00
|
|
|
## - build win32 x64: tools\win-ci\build.ps1 -arch x64
|
|
|
|
## - build win32 x64 dll: tools\win-ci\build.ps1 -arch x64 -is_dll true
|
|
|
|
## - build winuwp x64: tools\win-ci\build.ps1 -arch x64 -is_dll false -is_uwp true
|
|
|
|
## - cross build winuwp arm64: tools\win-ci\build.ps1 -arch arm64 -is_dll false -is_uwp true
|
2023-03-11 22:10:18 +08:00
|
|
|
##
|
|
|
|
|
2023-04-02 16:04:19 +08:00
|
|
|
## parsing options
|
2023-04-02 21:34:45 +08:00
|
|
|
$options = @{ arch = 'x64'; is_dll = 'false'; is_uwp = 'false'; is_clang = 'false'; target = $null; config='Release' }
|
2023-04-02 16:04:19 +08:00
|
|
|
|
|
|
|
$optName = $null
|
|
|
|
foreach ($arg in $args) {
|
|
|
|
if (!$optName) {
|
|
|
|
if ($arg.StartsWith('-')) {
|
|
|
|
$optName = $arg.SubString(1)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ($options.Contains($optName)) {
|
|
|
|
$options[$optName] = $arg
|
|
|
|
} else {
|
|
|
|
Write-Output "Warning: ignore unrecognized option: $optName"
|
|
|
|
}
|
|
|
|
$optName = $null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $options
|
|
|
|
|
|
|
|
## read options
|
|
|
|
$BUILD_ARCH = $options.arch
|
|
|
|
$BUILD_DLL = ($options.is_dll -eq 'true')
|
|
|
|
$UWP = ($options.is_uwp -eq 'true')
|
|
|
|
$CLANG = ($options.is_clang -eq 'true')
|
2023-03-11 22:10:18 +08:00
|
|
|
|
2023-04-02 16:04:19 +08:00
|
|
|
## process options
|
2023-03-11 22:10:18 +08:00
|
|
|
$optArch = $BUILD_ARCH
|
|
|
|
|
|
|
|
if ($optArch -eq 'x86') {
|
|
|
|
$optArch = 'Win32'
|
|
|
|
}
|
|
|
|
elseif ($optArch -eq 'amd64_arm64') {
|
|
|
|
$optArch = 'arm64'
|
2023-04-20 08:11:14 +08:00
|
|
|
$BUILD_ARCH = 'arm64'
|
2023-03-11 22:10:18 +08:00
|
|
|
}
|
|
|
|
|
2021-08-27 12:34:24 +08:00
|
|
|
# CONFIG_ALL_OPTIONS
|
|
|
|
$CONFIG_ALL_OPTIONS=@()
|
|
|
|
|
2023-04-02 16:04:19 +08:00
|
|
|
# cmake generator, default is latest Visual Studio installed on target machine, such as "Visual Studio 17 2022"
|
|
|
|
if ($CLANG) {
|
|
|
|
clang --version
|
|
|
|
$CONFIG_ALL_OPTIONS += '-G', 'Ninja Multi-Config', '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++'
|
|
|
|
}
|
|
|
|
|
2023-03-11 22:10:18 +08:00
|
|
|
# arch
|
2023-04-20 08:11:14 +08:00
|
|
|
if (!$CLANG) {
|
2023-04-02 16:04:19 +08:00
|
|
|
$CONFIG_ALL_OPTIONS += '-A', $optArch
|
|
|
|
$CONFIG_ALL_OPTIONS += '-Thost=x64'
|
|
|
|
} # TODO: how to specific arch for clang-cl toolchain?
|
2023-03-11 22:10:18 +08:00
|
|
|
|
|
|
|
# cxx_std, if $UWP, must be c++17, C++/CX not support c++20 or later yet.
|
2023-04-02 16:04:19 +08:00
|
|
|
if ($UWP) {
|
2023-03-11 22:10:18 +08:00
|
|
|
$CONFIG_ALL_OPTIONS += '-DCMAKE_CXX_STANDARD=17'
|
2021-08-27 12:34:24 +08:00
|
|
|
}
|
|
|
|
|
2023-03-11 22:10:18 +08:00
|
|
|
# sdkver require xxx, but 10.0.22621.0 recommanded
|
|
|
|
# empty, cmake will choose same with runner windows OS build version
|
|
|
|
if ("$env:WINSDK_VER" -ne '') {
|
|
|
|
$CONFIG_ALL_OPTIONS += "-DCMAKE_SYSTEM_VERSION=$env:WINSDK_VER"
|
|
|
|
}
|
|
|
|
|
|
|
|
# target
|
2023-04-02 16:04:19 +08:00
|
|
|
if ($UWP) {
|
2023-03-11 22:10:18 +08:00
|
|
|
$CONFIG_ALL_OPTIONS += '-DCMAKE_SYSTEM_NAME=WindowsStore', '-DCMAKE_SYSTEM_VERSION=10.0'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Enable extensions not enabled by engine default
|
|
|
|
$CONFIG_ALL_OPTIONS += '-DAX_ENABLE_EXT_LIVE2D=TRUE', '-DAX_ENABLE_EXT_EFFEKSEER=TRUE'
|
2023-04-02 16:04:19 +08:00
|
|
|
if (!$UWP) { # The extensions ImGui not support UWP yet
|
2023-03-11 22:10:18 +08:00
|
|
|
$CONFIG_ALL_OPTIONS += '-DAX_ENABLE_EXT_IMGUI=TRUE'
|
|
|
|
}
|
|
|
|
|
|
|
|
# dll
|
2023-04-02 16:04:19 +08:00
|
|
|
if ($BUILD_DLL) {
|
2023-01-08 22:04:14 +08:00
|
|
|
$CONFIG_ALL_OPTIONS += '-DBUILD_SHARED_LIBS=TRUE'
|
|
|
|
}
|
|
|
|
|
2023-03-11 22:10:18 +08:00
|
|
|
# output all options for debugging
|
|
|
|
Write-Output ("CONFIG_ALL_OPTIONS=$CONFIG_ALL_OPTIONS, Count={0}" -f $CONFIG_ALL_OPTIONS.Count)
|
2023-01-03 14:34:10 +08:00
|
|
|
|
2023-03-11 22:10:18 +08:00
|
|
|
# print cmake version for debugging purpose
|
|
|
|
cmake --version
|
|
|
|
|
|
|
|
# geneate .sln
|
2023-04-20 08:11:14 +08:00
|
|
|
cmake -S . -B build_$BUILD_ARCH $CONFIG_ALL_OPTIONS
|
2021-08-27 12:34:24 +08:00
|
|
|
|
2023-04-02 21:34:45 +08:00
|
|
|
$target = $options.target
|
2022-10-13 21:44:42 +08:00
|
|
|
|
2023-04-02 21:34:45 +08:00
|
|
|
if ($target) {
|
2023-04-20 08:11:14 +08:00
|
|
|
cmake --build build_$BUILD_ARCH --config $options.config --target $target
|
2023-04-02 21:34:45 +08:00
|
|
|
} else { # for github actions
|
|
|
|
# build cpp_test
|
2023-04-20 08:11:14 +08:00
|
|
|
cmake --build build_$BUILD_ARCH --config Release --target cpp_tests
|
2023-04-02 21:34:45 +08:00
|
|
|
|
|
|
|
# biuld lua_tests if not pull request
|
|
|
|
if ( !($env:PULL_REQUEST -eq 'yes') ) {
|
2023-04-20 08:11:14 +08:00
|
|
|
cmake --build build_$BUILD_ARCH --config Release --target lua_tests
|
2023-04-02 21:34:45 +08:00
|
|
|
}
|
2022-10-13 21:44:42 +08:00
|
|
|
}
|