Improve ci files (#1247)

* Improve ci files

* Fixup

* Fix ci

* Update DevSetup.md

* Remove duplicated code

* Fix setup_jdk

* Fix typo

* Check jdk setup

* Update build1k.ps1

* Update build.ps1

* Update build1k.ps1
This commit is contained in:
Deal(一线灵) 2023-07-01 08:52:14 +08:00 committed by GitHub
parent ccc7071b47
commit fab646c0d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 277 additions and 152 deletions

View File

@ -49,7 +49,7 @@ jobs:
shell: pwsh
run: |
$AX_ROOT = $(Get-Location).Path
tools/ci/build1k.ps1 -p android -a $env:BUILD_ARCH -d 'tests/cpp-tests/proj.android' -xt gradle -xc '-PAX_ENABLE_EXT_EFFEKSEER=ON',"-PRELEASE_STORE_FILE=$AX_ROOT/tools/ci/axmol-ci.jks",'-PRELEASE_STORE_PASSWORD=axmol-ci','-PRELEASE_KEY_ALIAS=axmol-ci','-PRELEASE_KEY_PASSWORD=axmol-ci'
./build.ps1 -p android -a $env:BUILD_ARCH
- uses: actions/upload-artifact@v3
with:

View File

@ -36,4 +36,4 @@ jobs:
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
shell: pwsh
run: tools/ci/build1k.ps1 -p ios -a 'x64' -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p ios -a 'x64'

View File

@ -40,4 +40,4 @@ jobs:
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
shell: pwsh
run: tools/ci/build1k.ps1 -p linux -a x64 -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p linux -a x64

View File

@ -41,4 +41,4 @@ jobs:
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
shell: pwsh
run: tools/ci/build1k.ps1 -p osx -a $env:BUILD_ARCH -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p osx -a $env:BUILD_ARCH

View File

@ -38,7 +38,7 @@ jobs:
arch: ${{ env.BUILD_ARCH }}
- name: Build
shell: pwsh
run: tools\ci\build1k.ps1 -p win32 -a $env:BUILD_ARCH -dll $env:BUILD_DLL -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p win32 -a $env:BUILD_ARCH -dll $env:BUILD_DLL
build-windows-clang:
runs-on: windows-latest
@ -62,7 +62,7 @@ jobs:
version: "16.0"
- name: Build
shell: pwsh
run: tools\ci\build1k.ps1 -p win32 -a x64 -cc clang -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p win32 -a x64 -cc clang
build-winuwp:
name: build-winuwp
@ -81,7 +81,7 @@ jobs:
uwp: true
- name: Build
shell: pwsh
run: tools\ci\build1k.ps1 -p winuwp -a x64 -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p winuwp -a x64
build-linux:
name: build-linux
@ -101,7 +101,7 @@ jobs:
echo -e "y" | bash $AX_ROOT/install-deps-linux.sh
- name: Build
shell: pwsh
run: tools/ci/build1k.ps1 -p linux -a x64 -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p linux -a x64
build-android:
name: build-android
@ -121,15 +121,11 @@ jobs:
- uses: actions/checkout@v3
with:
submodules: 'recursive'
- uses: actions/setup-java@v3
with:
distribution: 'microsoft' # See 'Supported distributions' for available options
java-version: '11'
- name: Build
shell: pwsh
run: |
$AX_ROOT = $(Get-Location).Path
tools/ci/build1k.ps1 -p android -a $env:BUILD_ARCH -d 'tests/cpp-tests/proj.android' -xt gradle -xc '-PAX_ENABLE_EXT_EFFEKSEER=ON',"-PRELEASE_STORE_FILE=$AX_ROOT/tools/ci/axmol-ci.jks",'-PRELEASE_STORE_PASSWORD=axmol-ci','-PRELEASE_KEY_ALIAS=axmol-ci','-PRELEASE_KEY_PASSWORD=axmol-ci'
./build.ps1 -p android -a $env:BUILD_ARCH
build-osx:
name: build-osx
@ -151,7 +147,7 @@ jobs:
- name: Build
shell: pwsh
run: |
tools/ci/build1k.ps1 -p osx -a $env:BUILD_ARCH -xb '--config','Release','--target','cpp_tests'
./build.ps1 -p osx -a $env:BUILD_ARCH
build-ios:
name: build-ios
@ -166,7 +162,7 @@ jobs:
- name: Build
shell: pwsh
run: tools/ci/build1k.ps1 -p ios -a 'x64' -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p ios -a 'x64'
build-tvos:
name: build-tvos
@ -182,4 +178,4 @@ jobs:
- name: Build
shell: pwsh
run: |
tools/ci/build1k.ps1 -p tvos -a 'x64' -xb '--config','Release','--target','cpp_tests'
./build.ps1 -p tvos -a 'x64'

View File

@ -36,4 +36,4 @@ jobs:
- name: Build
# Execute the build. You can specify a specific target with "--target <NAME>"
shell: pwsh
run: tools/ci/build1k.ps1 -p tvos -a 'x64' -xb '--config','Release','--target','cpp_tests'
run: ./build.ps1 -p tvos -a 'x64'

View File

@ -43,4 +43,4 @@ jobs:
version: "16.0"
- name: Build
run: tools/ci/build1k.ps1 -p win32 -a 'x64' -cc clang -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p win32 -a 'x64' -cc clang

View File

@ -44,4 +44,4 @@ jobs:
arch: ${{ env.BUILD_ARCH }}
- name: Build
run: tools\ci\build1k.ps1 -p win32 -a $env:BUILD_ARCH -dll $env:BUILD_DLL -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p win32 -a $env:BUILD_ARCH -dll $env:BUILD_DLL

View File

@ -43,7 +43,7 @@ jobs:
uwp: true
- name: Build
run: tools/ci/build1k.ps1 -p winuwp -a $env:BUILD_ARCH -xb '--config','Release','--target','cpp_tests'
run: .\build.ps1 -p winuwp -a $env:BUILD_ARCH
- uses: actions/upload-artifact@v3
with:

View File

@ -46,7 +46,7 @@ include(PreventInSourceBuilds)
include(AXBuildSet)
option(AX_BUILD_TESTS "Build cpp & lua tests" ON)
option(AX_BUILD_TOOLS "Build tools" OFF)
option(AX_BUILD_TOOLS "Build tools" ON)
add_subdirectory(${_AX_ROOT_PATH}/core ${ENGINE_BINARY_PATH}/axmol/core)

189
build.ps1 Normal file
View File

@ -0,0 +1,189 @@
#
# This script easy to build win32, linux, winuwp, ios, tvos, osx, android depends on $AX_ROOT/tools/ci/build1k.ps1
# usage: pwsh build.ps1 -p <targetPlatform> -a <arch>
# options
# -p: build target platform: win32,winuwp,linux,android,osx,ios,tvos,watchos
# for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first,
# if not found, by default will install ndk-r16b or can be specified by option: -cc 'ndk-r23c'
# -a: build arch: x86,x64,armv7,arm64; for android can be list by ';', i.e: 'arm64;x64'
# -cc: toolchain: for win32 you can specific -cc clang to use llvm-clang, please install llvm-clang from https://github.com/llvm/llvm-project/releases
# -xc: additional cmake options: i.e. -xc '-Dbuild','-DCMAKE_BUILD_TYPE=Release'
# -xb: additional cross build options: i.e. -xb '--config','Release'
# examples:
# - win32:
# - pwsh build.ps1 -p win32
# - pwsh build.ps1 -p win32 -cc clang
# - winuwp: pwsh build.ps1 -p winuwp
# - linux: pwsh build.ps1 -p linux
# - android:
# - pwsh build.ps1 -p android -a arm64
# - pwsh build.ps1 -p android -a 'arm64;x64'
# - osx:
# - pwsh build.ps1 -p osx -a x64
# - pwsh build.ps1 -p osx -a arm64
# - ios: pwsh build.ps1 -p ios -a x64
# - tvos: pwsh build.ps1 -p tvos -a x64
# build.ps1 without any arguments:
# - pwsh build.ps1
# on windows: target platform is win32, arch=x64
# on linux: target platform is linux, arch=x64
# on macos: target platform is osx, arch=x64
#
$options = @{p = $null; a = 'x64'; cc = $null; xc = @(); xb = @(); }
$optName = $null
foreach ($arg in $args) {
if (!$optName) {
if ($arg.StartsWith('-')) {
$optName = $arg.SubString(1)
}
}
else {
if ($options.Contains($optName)) {
$options[$optName] = $arg
}
$optName = $null
}
}
function add_quote($value) {
$ret = $null
$valueType = $value.GetType()
if ($valueType -eq [string]) {
$ret = "'$value'"
}
elseif ($valueType -eq [object[]]) {
$ret = ''
for ($i = 0; $i -lt $value.Count; ++$i) {
$subVal = $value[$i]
$ret += "'$subVal'"
if ($i -ne ($value.Count - 1)) {
$ret += ','
}
}
}
return $ret
}
$myRoot = $PSScriptRoot
$workDir = $(Get-Location).Path
$AX_ROOT = $env:AX_ROOT
if (!$AX_ROOT) {
if(Test-Path "$myRoot/core/axmolver.h.in" -PathType Leaf) {
$AX_ROOT = $myRoot
}
else {
throw "Can't determine axmol engine root, please run python setup.py first"
}
}
$is_engine = ($workDir -eq $AX_ROOT)
$is_android = $options.p -eq 'android'
$is_ci = $env:GITHUB_ACTIONS -eq 'true'
# start construct full cmd line
$fullCmdLine = @("$((Resolve-Path -Path "$AX_ROOT/tools/ci/build1k.ps1").Path)")
foreach ($option in $options.GetEnumerator()) {
if ($option.Value) {
$fullCmdLine += add_quote "-$($option.Key)"
$fullCmdLine += add_quote $option.Value
}
}
if ($options.p -eq 'android') {
$fullCmdLine += "'-xt'", "'gradle'"
}
$search_paths = @($workDir, $myRoot)
function search_proj($path, $type) {
foreach ($search_path in $search_paths) {
$full_path = Join-Path -Path $search_path -ChildPath $path
if (Test-Path $full_path -PathType $type) {
$ret_path = if ($type -eq 'Container') { $full_path } else { $search_path }
return $ret_path
}
}
return $null
}
$search_rules = @(
# others
@(
# project
@{
path = 'CMakeLists.txt';
type = 'Leaf'
},
# engine
@{
path = 'CMakeLists.txt';
type = 'Leaf'
}
),
# android
@(
# project
@{
path = 'proj.android';
type = 'Container';
},
# engine
@{
path = if ($is_ci) { 'tests/cpp-tests/proj.android' } else { 'templates/cpp-template-default/proj.android' };
type = 'Container'
}
)
)
$search_rule = $search_rules[$is_android][$is_engine]
$proj_dir = search_proj $search_rule.path $search_rule.type
$proj_name = (Get-Item $myRoot).BaseName
$optimize_flag = @('Debug', 'Release')[$is_ci]
if (!$is_android) {
# non android
if ("$($options.xb)".IndexOf('--target') -eq -1) {
# non android, specific cmake target
$cmake_targets = @(
# local developer
@(
# project
$proj_name,
# engine
'HelloCpp'
),
# github actions
@(
# project
$proj_name,
# engine
'cpp_tests'
)
)
$cmake_target = $cmake_targets[$is_ci][$is_engine]
$fullCmdLine += "'-xb'", "'--config','$optimize_flag','--target','$cmake_target'"
}
} else { # android
$fullCmdLine += "'-xb'", "'--config','$optimize_flag'"
# engine ci
if ($is_engine -and $is_ci) {
$fullCmdLine += "'-xc'", "'-PAX_ENABLE_EXT_EFFEKSEER=ON','-PRELEASE_STORE_FILE=$AX_ROOT/tools/ci/axmol-ci.jks','-PRELEASE_STORE_PASSWORD=axmol-ci','-PRELEASE_KEY_ALIAS=axmol-ci','-PRELEASE_KEY_PASSWORD=axmol-ci'"
}
}
if ($is_android) {
$fullCmdLine += "'-xt'", "'gradle'"
}
if ($proj_dir) {
$fullCmdLine += "'-d'", "'$proj_dir'"
}
$prefix = Join-Path -Path $AX_ROOT -ChildPath 'tools/external'
$fullCmdLine += "'-prefix'", "'$prefix'"
$strFullCmdLine = "$fullCmdLine"
Invoke-Expression -Command $strFullCmdLine

View File

@ -25,18 +25,22 @@ Examples:
- Cpp: `axmol new -p org.axmol.hellocpp -d D:\dev\projects\ -l cpp --portrait HelloCpp`
- Lua: `axmol new -p org.axmol.hellolua -d D:\dev\projects\ -l lua --portrait HelloLua`
## Quick building your new project by `build.ps1` for all target platforms
## Quick build your new project by `build.ps1` for all target platforms [`Recommended`]
If you use latest commits after 6/29/2023 18:50, once you crate a new project, there is a build script `build.ps1` in your project root directory,
then you can simply build your project for all platform targets, i.e.
- win32: `pwsh .\build.ps1 -p win32 -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on Windows with vs2022 installed
- winuwp: `pwsh .\build.ps1 -p winuwp -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on Windows with vs2022 installed
- linux: run the setup script `install-deps-linux.sh` once, then `pwsh .\build.ps1 -p linux -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on Linux with g++ installed
- osx: `pwsh .\build.ps1 -p osx -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on macOS with xcode13~14.2 installed
- win32: `pwsh .\build.ps1 -p win32 -a x64 -xc '--config','Debug'` can runs on Windows with vs2022 installed
- winuwp: `pwsh .\build.ps1 -p winuwp -a x64 -xc '--config','Debug'` can runs on Windows with vs2022 installed
- linux: run the setup script `install-deps-linux.sh` once, then `pwsh .\build.ps1 -p linux -a x64 -xc '--config','Debug'` can runs on Linux with g++ installed
- osx: `pwsh .\build.ps1 -p osx -a x64 -xc '--config','Debug'` can runs on macOS with xcode13~14.2 installed
- android: `pwsh .\build.ps1 -p android -a arm64` can runs on Windows,Linux,macOS and script will auto setup android sdk
- ios: `pwsh .\build.ps1 -p ios -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on macOS with xcode13~14.2 installed
- tvos: `pwsh .\build.ps1 -p tvos -a x64 -xc '--config','Debug','--target','HelloCpp'` can runs on macOS with xcode13~14.2 installed
- ios: `pwsh .\build.ps1 -p ios -a x64 -xc '--config','Debug'` can runs on macOS with xcode13~14.2 installed
- tvos: `pwsh .\build.ps1 -p tvos -a x64 -xc '--config','Debug'` can runs on macOS with xcode13~14.2 installed
## Quick build engine for host targets?
Goto axmol root directory, double click or run `build.ps1` without any parameters, it will build `HelloCpp` by default
## Windows (Visual Studio)

View File

@ -1,6 +1,6 @@
{
"common": [
],
"lua": [
"build.ps1",
"templates/run.bat.in"
]
}
}

View File

@ -106,10 +106,12 @@ else {
$HOST_OS = $HOST_MAC
}
else {
throw "Unsupported host OS for building target $(options.p)"
throw "Unsupported host OS to run build1k.ps1"
}
}
$IsWin = $HOST_OS -eq $HOST_WIN
$exeSuffix = if ($HOST_OS -eq 0) { '.exe' } else { '' }
$CONFIG_DEFAULT_OPTIONS = @()
@ -118,8 +120,10 @@ $HOST_OS_NAME = $('windows', 'linux', 'macos').Get($HOST_OS)
# determine build target os
$BUILD_TARGET = $options.p
if (!$BUILD_TARGET) {
# choose host target if not specified by command line automatically
$BUILD_TARGET = $('win32', 'linux', 'osx').Get($HOST_OS)
}
b1k_print "Building targetPlatform is $BUILD_TARGET"
# determine toolchain
$TOOLCHAIN = $options.cc
@ -305,33 +309,55 @@ function setup_nuget() {
}
function setup_jdk() {
$jdk_ver = '11.0.19+'
$IsGraterThan = if ($jdk_ver.EndsWith('+')) { '+' } else { $null }
if ($IsGraterThan) {
$jdk_ver = $jdk_ver.Substring(0, $jdk_ver.Length - 1)
}
$javac_prog = (Get-Command "javac" -ErrorAction SilentlyContinue).Source
if ($javac_prog) {
$jdk_ver = $(javac --version).Split(' ')[1].Trim()
if ($jdk_ver -ge '11.0.0') {
b1k_print "Using installed jdk: $javac_prog, version: $jdk_ver"
$_jdk_ver = $(javac --version).Split(' ')[1].Trim()
if (($IsGraterThan -and $_jdk_ver -ge $jdk_ver) -or ($_jdk_ver -eq $jdk_ver)) {
b1k_print "Using installed jdk: $javac_prog, version: $_jdk_ver"
return $javac_prog
}
}
$jdk_ver = '11.0.19'
$suffix = $('windows', 'linux', 'macOS').Get($HOST_OS)
$javac_bin = (Resolve-Path "$tools_dir/jdk-$jdk_ver/bin" -ErrorAction SilentlyContinue).Path
if (!$javac_bin) {
if (!(Test-Path "$tools_dir/microsoft-jdk-$jdk_ver-$suffix-x64.zip" -PathType Leaf)) {
download_file "https://aka.ms/download-jdk/microsoft-jdk-$jdk_ver-$suffix-x64.zip" "$tools_dir/microsoft-jdk-$jdk_ver-$suffix-x64.zip"
b1k_print "Not found suitable jdk: $_jdk_ver, installing $jdk_ver"
$suffix = $('windows-x64.zip', 'linux-x64.tar.gz', 'macOS-x64.tar.gz').Get($HOST_OS)
$java_home = Join-Path -Path $tools_dir -ChildPath jdk-$jdk_ver
if (!(Test-Path $java_home -PathType Container)) {
# refer to https://learn.microsoft.com/en-us/java/openjdk/download
if (!(Test-Path "$tools_dir/microsoft-jdk-$jdk_ver-$suffix" -PathType Leaf)) {
download_file "https://aka.ms/download-jdk/microsoft-jdk-$jdk_ver-$suffix" "$tools_dir/microsoft-jdk-$jdk_ver-$suffix"
}
$folderName = get_zip_folder_name("$tools_dir/microsoft-jdk-$jdk_ver-$suffix-x64.zip")
# uncompress
if ($IsWin) {
$folderName = get_zip_folder_name("$tools_dir/microsoft-jdk-$jdk_ver-$suffix")
Expand-Archive -Path "$tools_dir/microsoft-jdk-$jdk_ver-$suffix" -DestinationPath "$tools_dir/"
}
else {
tar xvf "$tools_dir/microsoft-jdk-$jdk_ver-$suffix" -C "$tools_dir/"
}
Expand-Archive -Path "$tools_dir/microsoft-jdk-$jdk_ver-$suffix-x64.zip" -DestinationPath "$tools_dir/"
Move-Item "$tools_dir/$folderName" "$tools_dir/jdk-$jdk_ver"
$javac_bin = (Resolve-Path "$tools_dir/jdk-$jdk_ver/bin" -ErrorAction SilentlyContinue).Path
# move to plain folder name
$folderName = (Get-ChildItem -Path $tools_dir -Filter "jdk-$jdk_ver+*").Name
if ($folderName) {
Move-Item "$tools_dir/$folderName" $java_home
}
}
if ($env:PATH.IndexOf($javac_bin) -eq -1) {
$env:PATH = "$javac_bin$envPathSep$env:PATH"
$env:JAVA_HOME = $java_home
$env:CLASSPATH=".;$java_home\lib\dt.jar;$java_home\lib\tools.jar"
$jdk_bin = Join-Path -Path $java_home -ChildPath 'bin'
if ($env:PATH.IndexOf($jdk_bin) -eq -1) {
$env:PATH = "$jdk_bin$envPathSep$env:PATH"
}
$javac_prog = (find_prog -name 'javac' -path $jdk_bin)
if (!$javac_prog) {
throw "Install jdk $jdk_ver fail"
}
$javac_prog = (Join-Path -Path $javac_bin -ChildPath javac$exeSuffix)
return $javac_prog
}
@ -364,7 +390,7 @@ function setup_android_sdk() {
$ndk_ver = 'r23c+'
}
$IsGraterThan = $ndk_ver.EndsWith('+')
$IsGraterThan = if ($ndk_ver.EndsWith('+')) { '+' } else { $null }
if ($IsGraterThan) {
$ndk_ver = $ndk_ver.Substring(0, $ndk_ver.Length - 1)
}
@ -377,7 +403,7 @@ function setup_android_sdk() {
$sdk_root = $null
foreach ($sdk_root_env in $sdk_root_envs) {
$sdk_dir = [Environment]::GetEnvironmentVariable($sdk_root_env)
b1k_print "Looking require ndk-$TOOLCHAIN_VER in env:$sdk_root_env=$sdk_dir"
b1k_print "Looking require $ndk_ver$IsGraterThan in env:$sdk_root_env=$sdk_dir"
if ("$sdk_dir" -ne '') {
$sdk_root = $sdk_dir
$ndk_root = $null

View File

@ -452,8 +452,17 @@ class TPCreator(object):
self.do_cmds(default_cmds)
def cp_ci_scripts(self):
tools_template = os.path.join(os.getenv('AX_ROOT'), 'tools', 'template')
axmol.copy_files_in_dir(tools_template, self.project_dir)
axroot = os.getenv('AX_ROOT')
axmol_files_path = os.path.join(axroot, 'templates', 'axmol_files.json')
f = open(axmol_files_path, encoding='utf8')
dict_files = json.load(f)
common_files = dict_files.get('common')
for filepath in common_files:
fullpath = os.path.realpath(os.path.join(axroot, filepath))
print("> Copying {0} to {1}".format(fullpath, self.project_dir))
shutil.copy(os.path.join(axroot, filepath), self.project_dir)
# axmol.copy_files_in_dir(tools_template, self.project_dir)
def do_other_step(self, step, not_existed_error=True):
if step not in self.tp_other_step:

View File

@ -22,7 +22,7 @@ processing file 4: /home/vmroot/dev/axmol/tests/cpp-tests/Content/hd/extensions/
#include <regex>
#include <iostream>
#include "base/posix_io.h"
#include "yasio/stl/string_view.hpp"
#include "yasio/string_view.hpp"
namespace stdfs = std::filesystem;

View File

@ -1,99 +0,0 @@
#
# This script easy to build win32, linux, winuwp, ios, tvos, osx, android
# usage: pwsh build.ps1 -p <targetPlatform> -a <arch>
# options
# -p: build target platform: win32,winuwp,linux,android,osx,ios,tvos,watchos
# for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first,
# if not found, by default will install ndk-r16b or can be specified by option: -cc 'ndk-r23c'
# -a: build arch: x86,x64,armv7,arm64; for android can be list by ';', i.e: 'arm64;x64'
# -cc: toolchain: for win32 you can specific -cc clang to use llvm-clang, please install llvm-clang from https://github.com/llvm/llvm-project/releases
# -xc: additional cmake options: i.e. -xc '-Dbuild','-DCMAKE_BUILD_TYPE=Release'
# -xb: additional cross build options: i.e. -xb '--config','Release'
# examples:
# - win32:
# - pwsh build.ps1 -p win32
# - pwsh build.ps1 -p win32 -cc clang
# - winuwp: pwsh build.ps1 -p winuwp
# - linux: pwsh build.ps1 -p linux
# - android:
# - pwsh build.ps1 -p android -a arm64
# - pwsh build.ps1 -p android -a 'arm64;x64'
# - osx:
# - pwsh build.ps1 -p osx -a x64
# - pwsh build.ps1 -p osx -a arm64
# - ios: pwsh build.ps1 -p ios -a x64
# - tvos: pwsh build.ps1 -p tvos -a x64
# build.ps1 without any arguments:
# - pwsh build.ps1
# on windows: target platform is win32, arch=x64
# on linux: target platform is linux, arch=x64
# on macos: target platform is osx, arch=x64
#
$fullCmdLine = @("$((Resolve-Path -Path "$env:AX_ROOT/tools/ci/build1k.ps1").Path)")
$options = @{p = ''; a = 'x64'; cc = ''; xc = @(); xb = @(); }
$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-Host "Warning: ignore unrecognized option: $optName"
}
$optName = $null
}
}
if (!$options.p) {
if ($IsWindows -or ("$env:OS" -eq 'Windows_NT')) {
$options.p = 'win32'
}
else {
if ($IsLinux) {
$options.p = 'linux'
}
elseif ($IsMacOS) {
$options.p = 'osx'
}
else {
throw "Unsupported host OS for building target $(options.p)"
}
}
}
function add_quote($value) {
$ret = "'"
$ret += $value
$ret += "'"
return $ret
}
foreach ($option in $options.GetEnumerator()) {
$fullCmdLine += add_quote "-$($option.Key)"
$fullCmdLine += add_quote $option.Value
}
if ($options.p -eq 'android') {
$fullCmdLine += "'-xt'", "'gradle'"
$proj_dir = (Resolve-Path "$PSScriptRoot/proj.android").Path
if(!$proj_dir) {
$proj_dir = (Resolve-Path "$((Get-Location).Path)/proj.android").Path
}
} else {
$proj_dir = $PSScriptRoot
}
$fullCmdLine += "'-d'", "'$proj_dir'"
$prefix = Join-Path -Path $env:AX_ROOT -ChildPath 'tools/external'
$fullCmdLine += "'-prefix'", "'$prefix'"
$strFullCmdLine = "$fullCmdLine"
Invoke-Expression -Command $strFullCmdLine