2023-08-30 08:34:33 +08:00
|
|
|
param(
|
2024-05-01 10:47:38 +08:00
|
|
|
[switch]$help,
|
|
|
|
[switch]$wait
|
2023-08-30 08:34:33 +08:00
|
|
|
)
|
2024-05-22 01:23:28 +08:00
|
|
|
|
|
|
|
# Set-StrictMode -Version Latest
|
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
# pwsh function alias
|
2024-01-20 16:16:53 +08:00
|
|
|
function println($message) { Write-Host "axmol: $message" }
|
2023-08-30 08:34:33 +08:00
|
|
|
|
|
|
|
$myRoot = $PSScriptRoot
|
|
|
|
|
|
|
|
# 0: windows, 1: linux, 2: macos
|
|
|
|
# $IsWin = $IsWindows -or ("$env:OS" -eq 'Windows_NT')
|
|
|
|
|
|
|
|
# parse engine version
|
|
|
|
$AX_ROOT = (Resolve-Path $myRoot/../..).Path
|
|
|
|
$axver_file = (Resolve-Path $AX_ROOT/core/axmolver.h.in).Path
|
2023-12-10 00:08:05 +08:00
|
|
|
$content = $(Get-Content -Path $axver_file)
|
|
|
|
|
|
|
|
function parse_axver($part) {
|
|
|
|
return ($content | Select-String "#define AX_VERSION_$part").Line.Split(' ')[2]
|
|
|
|
}
|
2024-01-20 16:16:53 +08:00
|
|
|
function realpath($path) {
|
|
|
|
return $Global:ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($path)
|
|
|
|
}
|
|
|
|
|
2023-12-10 00:08:05 +08:00
|
|
|
$axmolVersion = "$(parse_axver 'MAJOR').$(parse_axver 'MINOR').$(parse_axver 'PATCH')"
|
2023-08-30 08:34:33 +08:00
|
|
|
|
|
|
|
$git_prog = (Get-Command 'git' -ErrorAction SilentlyContinue).Source
|
|
|
|
if ($git_prog) {
|
2023-12-21 23:59:24 +08:00
|
|
|
$branchName = $(git -C $AX_ROOT branch --show-current 2>$null)
|
2023-08-30 08:34:33 +08:00
|
|
|
if ($branchName -eq 'dev') {
|
2023-12-21 23:59:24 +08:00
|
|
|
$commitHash = $(git -C $AX_ROOT rev-parse --short=7 HEAD 2>$null)
|
2023-08-30 08:34:33 +08:00
|
|
|
$axmolVersion += "-$commitHash"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-01 16:28:34 +08:00
|
|
|
$pwsh_ver = $PSVersionTable.PSVersion.ToString()
|
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
# tool usage
|
|
|
|
$tool_usage = @'
|
|
|
|
axmol-{0} console: A command line tool for axmol engine.
|
|
|
|
|
2023-09-01 16:28:34 +08:00
|
|
|
Using PowerShell {1}
|
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
Available commands:
|
|
|
|
new Creates a new project.
|
|
|
|
build Compile projects to binary.
|
|
|
|
deploy Compile and deploy a project to a device/simulator.
|
|
|
|
run Compiles, deploy and run project on the target.
|
|
|
|
|
|
|
|
Available arguments:
|
|
|
|
-h Show this help information.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
axmol new --help
|
|
|
|
axmol run --help
|
2023-09-01 16:28:34 +08:00
|
|
|
'@ -f $axmolVersion, $pwsh_ver
|
2023-08-30 08:34:33 +08:00
|
|
|
|
|
|
|
$cmdName = $args[0]
|
|
|
|
|
|
|
|
if ($IsMacOS) {
|
|
|
|
function find_simulator_id($plat, $deviceName = '') {
|
2024-04-09 02:42:25 +08:00
|
|
|
$selStr = @{ios = 'iPhone'; tvos = 'Apple TV' }[$plat]
|
2023-08-30 08:34:33 +08:00
|
|
|
[array]$emulators = (xcrun xctrace list devices | Select-String $selStr)
|
2024-04-09 02:42:25 +08:00
|
|
|
foreach ($emulator in $emulators) {
|
2023-08-30 08:34:33 +08:00
|
|
|
$emuInfoStr = $emulator.Line
|
|
|
|
if ($emuInfoStr.StartsWith($deviceName) -or !$deviceName) {
|
|
|
|
return ($emuInfoStr -split "\(|\)")[3], $emuInfoStr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_bundle_id($appPath) {
|
|
|
|
$plistFile = Join-Path $appPath 'Info.plist'
|
|
|
|
$appInfo = ConvertFrom-Json (plutil -convert json -o - $plistFile)
|
|
|
|
return $appInfo.CFBundleIdentifier
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function axmol_build() {
|
|
|
|
$sub_args = $args
|
|
|
|
println $sub_args
|
2024-04-24 01:39:49 +08:00
|
|
|
$build_script = Join-Path $PSScriptRoot 'build.ps1'
|
2024-03-22 23:37:16 +08:00
|
|
|
if ("$args".Contains('-d')) {
|
2023-08-30 08:34:33 +08:00
|
|
|
# have proj dir
|
2024-02-17 00:29:07 +08:00
|
|
|
. $build_script @sub_args
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
else {
|
2024-02-17 00:29:07 +08:00
|
|
|
. $build_script @sub_args -d (Get-Location).Path
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function axmol_deploy() {
|
|
|
|
$sub_args = $args
|
|
|
|
. axmol_build @sub_args
|
2024-01-06 01:09:31 +08:00
|
|
|
if ($TARGET_OS -eq 'winrt') {
|
2023-11-06 00:19:44 +08:00
|
|
|
$appxManifestFile = Join-Path $BUILD_DIR "bin/$cmake_target/$optimize_flag/Appx/AppxManifest.xml"
|
2023-09-06 12:23:33 +08:00
|
|
|
|
|
|
|
# deploy by visual studio major program: devenv.exe
|
|
|
|
$vswherePath = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
|
2024-04-09 02:42:25 +08:00
|
|
|
$devenvPath = &$vswherePath -latest -requires Microsoft.Component.MSBuild -find Common*\IDE\devenv.exe | select-object -first 1
|
2023-09-06 12:23:33 +08:00
|
|
|
|
|
|
|
if (Test-Path $devenvPath -PathType Leaf) {
|
|
|
|
$devenvRoot = Split-Path $devenvPath -Parent
|
|
|
|
$env:PATH = "$devenvRoot;$env:PATH"
|
2023-11-07 22:59:22 +08:00
|
|
|
$slnDir = $BUILD_DIR
|
2023-09-06 12:23:33 +08:00
|
|
|
$slnFileName = (Get-ChildItem $slnDir *.sln).Name
|
|
|
|
$slnFilePath = Join-Path $slnDir $slnFileName
|
|
|
|
devenv $slnFilePath /deploy $optimize_flag /project $cmake_target /projectconfig $optimize_flag
|
|
|
|
}
|
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
[XML]$appxManifest = Get-Content $appxManifestFile
|
|
|
|
$appxIdentity = $appxManifest.Package.Identity.Name
|
2023-09-06 12:23:33 +08:00
|
|
|
# $appxPkgFullName = (powershell -Command "(Get-AppxPackage -Name '$appxIdentity' | Select-Object -Unique 'PackageFullName').PackageFullName")
|
|
|
|
# if ($appxPkgFullName ) {
|
|
|
|
# if ($uninst) {
|
|
|
|
# println "Uninstalling $appxPkgFullName ..."
|
|
|
|
# powershell -Command "Remove-AppxPackage -Package '$appxPkgFullName'"
|
|
|
|
# powershell -Command "Add-AppxPackage -Register '$appxManifestFile'"
|
|
|
|
# }
|
|
|
|
# }
|
|
|
|
# else {
|
|
|
|
# powershell -Command "Add-AppxPackage -Register '$appxManifestFile'"
|
|
|
|
# }
|
2023-08-30 08:34:33 +08:00
|
|
|
$appxPkgName = (powershell -Command "(Get-AppxPackage -Name '$appxIdentity' | Select-Object -Unique 'PackageFamilyName').PackageFamilyName")
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Deploy $cmake_target done: $appxPkgName"
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'win32') {
|
2023-11-06 00:19:44 +08:00
|
|
|
$win32exePath = Join-Path $BUILD_DIR "bin/$cmake_target/$optimize_flag/$cmake_target.exe"
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Deploy $cmake_target done: $win32exePath"
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
2023-11-06 00:19:44 +08:00
|
|
|
elseif ($TARGET_OS -eq 'android') {
|
2023-08-30 08:34:33 +08:00
|
|
|
$optimize_flag_lower = $optimize_flag.ToLower()
|
|
|
|
$apkDir = Join-Path $proj_dir "proj.android/app/build/outputs/apk/$optimize_flag_lower"
|
|
|
|
$apkName = (Get-ChildItem -Path "$apkDir/*.apk").Name
|
|
|
|
$apkFullPath = Join-Path $apkDir $apkName
|
2023-12-11 23:28:21 +08:00
|
|
|
|
|
|
|
# read applicationId aka package name
|
|
|
|
$outputMetaFile = Join-Path $apkDir 'output-metadata.json'
|
|
|
|
$outputMeta = ConvertFrom-Json $(Get-Content $outputMetaFile -raw)
|
|
|
|
$androidAppId = $outputMeta.applicationId
|
|
|
|
|
|
|
|
# read activityName
|
2023-08-30 08:34:33 +08:00
|
|
|
$androidManifestFile = Join-Path $proj_dir 'proj.android/app/AndroidManifest.xml'
|
|
|
|
[XML]$androidManifest = Get-Content $androidManifestFile
|
|
|
|
$androidActivity = $androidManifest.manifest.application.activity.name
|
2023-12-11 23:28:21 +08:00
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
adb install -t -r $apkFullPath
|
|
|
|
if ($?) {
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Deploy $cmake_target done: $androidAppId/$androidActivity"
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
}
|
2023-11-06 00:19:44 +08:00
|
|
|
elseif ($TARGET_OS -eq 'ios' -or $TARGET_OS -eq 'tvos') {
|
2023-08-30 08:34:33 +08:00
|
|
|
if ($options.a -eq 'x64') {
|
2023-11-06 00:19:44 +08:00
|
|
|
$ios_app_path = Join-Path $BUILD_DIR "bin/$cmake_target/$optimize_flag/$cmake_target.app"
|
2023-08-30 08:34:33 +08:00
|
|
|
$ios_bundle_id = get_bundle_id($ios_app_path)
|
|
|
|
|
2024-01-20 16:16:53 +08:00
|
|
|
println 'Finding avaiable simualtor ...'
|
2023-11-06 00:19:44 +08:00
|
|
|
$ios_simulator_id, $simulator_info = find_simulator_id($TARGET_OS)
|
2023-08-30 08:34:33 +08:00
|
|
|
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Booting $simulator_info ..."
|
2023-08-30 08:34:33 +08:00
|
|
|
xcrun simctl boot $ios_simulator_id '--arch=x86_64'
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Installing $ios_app_path ..."
|
2023-08-30 08:34:33 +08:00
|
|
|
xcrun simctl install $ios_simulator_id $ios_app_path
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Deploy $cmake_target done: $ios_bundle_id"
|
2024-04-09 02:42:25 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# ios device
|
2023-08-30 08:34:33 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-01 10:47:38 +08:00
|
|
|
function is_console_app($path) {
|
|
|
|
# $peFile = [System.IO.FileStream]::new($path, 'Open', 'Read')
|
|
|
|
# $peReader = New-Object System.Reflection.PortableExecutable.PEReader -ArgumentList $peFile
|
|
|
|
# $isConsole = $peReader.PEHeaders.PEHeader.Subsystem -eq 3
|
|
|
|
# $peFile.Close()
|
|
|
|
# return $isConsole
|
|
|
|
$buffer = New-Object Byte[] 248
|
|
|
|
$fileStream = [System.IO.FileStream]::new($path, [IO.FileMode]::Open, [IO.FileAccess]::Read)
|
|
|
|
$fileStream.Seek(0x3C, [System.IO.SeekOrigin]::Begin) | Out-Null
|
|
|
|
$fileStream.Read($buffer, 0, 4) | Out-Null
|
|
|
|
$peHeaderOffset = [BitConverter]::ToInt32($buffer, 0)
|
|
|
|
$fileStream.Seek($peHeaderOffset, [System.IO.SeekOrigin]::Begin) | Out-Null
|
|
|
|
$fileStream.Read($buffer, 0, 248) | Out-Null
|
|
|
|
$fileStream.Seek($peHeaderOffset + 0x5C, [System.IO.SeekOrigin]::Begin) | Out-Null
|
|
|
|
$fileStream.Read($buffer, 0, 2) | Out-Null
|
|
|
|
$buffer[2] = 0
|
|
|
|
$fileStream.Close()
|
|
|
|
$subsystem = [BitConverter]::ToInt16($buffer, 0)
|
|
|
|
return $subsystem -eq 3
|
|
|
|
}
|
|
|
|
|
2023-08-30 08:34:33 +08:00
|
|
|
function axmol_run() {
|
|
|
|
$sub_args = $args
|
|
|
|
. axmol_deploy @sub_args
|
2024-05-01 22:24:53 +08:00
|
|
|
if($is_host_target -and $TARGET_CPU -ne $HOST_CPU) {
|
|
|
|
println "Skip launch $cmake_target, due to $TARGET_OS-$TARGET_CPU apps can't runs on $HOST_OS_NAME-$HOST_CPU"
|
|
|
|
return
|
|
|
|
}
|
2024-01-06 01:09:31 +08:00
|
|
|
if ($TARGET_OS -eq 'winrt') {
|
2023-08-30 08:34:33 +08:00
|
|
|
explorer.exe shell:AppsFolder\$appxPkgName!App
|
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'win32') {
|
2024-05-01 10:47:38 +08:00
|
|
|
$workdir = $(Split-Path $win32exePath -Parent)
|
|
|
|
$additional_args = @{}
|
|
|
|
if ($wait -or (is_console_app $win32exePath)) { $additional_args = @{NoNewWindow = $true; Wait = $true } }
|
|
|
|
Start-Process -FilePath $win32exePath -WorkingDirectory $workdir @additional_args
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'android') {
|
2023-12-11 23:28:21 +08:00
|
|
|
adb shell am start -n "$androidAppId/$androidActivity"
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'ios') {
|
2023-08-30 08:34:33 +08:00
|
|
|
if ($ios_bundle_id) {
|
2023-08-30 18:46:36 +08:00
|
|
|
println "Launching $cmake_target ..."
|
2023-11-28 10:24:33 +08:00
|
|
|
xcrun simctl launch $ios_simulator_id $ios_bundle_id
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'osx') {
|
2023-11-06 00:19:44 +08:00
|
|
|
$launch_macapp = Join-Path $BUILD_DIR "bin/$cmake_target/$optimize_flag/$cmake_target.app/Contents/MacOS/$cmake_target"
|
2023-08-30 08:34:33 +08:00
|
|
|
& $launch_macapp
|
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
elseif ($TARGET_OS -eq 'linux') {
|
2023-11-06 00:19:44 +08:00
|
|
|
$launch_linuxapp = Join-Path $BUILD_DIR "bin/$cmake_target/$cmake_target"
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Launching $launch_linuxapp ..."
|
2024-05-01 10:47:38 +08:00
|
|
|
$additional_args = @()
|
|
|
|
if ($wait) { $additional_args = @{NoNewWindow = $true; Wait = $true } }
|
|
|
|
Start-Process -FilePath $launch_linuxapp -WorkingDirectory $(Split-Path $launch_linuxapp -Parent) @additional_args
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
2024-04-12 20:34:59 +08:00
|
|
|
elseif ($TARGET_OS.startsWith('wasm')) {
|
2023-11-06 00:19:44 +08:00
|
|
|
$launch_wasmapp = Join-Path $BUILD_DIR "bin/$cmake_target/$cmake_target.html"
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Launching $launch_wasmapp ..."
|
2023-09-05 21:10:25 +08:00
|
|
|
emrun $launch_wasmapp
|
|
|
|
}
|
2024-01-20 16:16:53 +08:00
|
|
|
println "Launch $cmake_target done, target platform is $($TARGET_OS)"
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
$builtinPlugins = @{
|
|
|
|
new = @{
|
|
|
|
proc = (Join-Path $myRoot 'axmol_new.ps1');
|
|
|
|
usage = @"
|
2023-12-05 20:55:00 +08:00
|
|
|
usage: axmol new -p org.axmol.hellocpp -d path/to/project -l cpp --portrait <ProjectName>
|
2023-08-30 08:34:33 +08:00
|
|
|
Creates a new project.
|
|
|
|
|
|
|
|
positional arguments:
|
|
|
|
PROJECT_NAME Set the project name.
|
|
|
|
|
|
|
|
options:
|
|
|
|
-h Show this help message and exit
|
|
|
|
-p PACKAGE_NAME
|
|
|
|
Set a package name for project.
|
|
|
|
-d DIRECTORY
|
|
|
|
Set the path where to place the new project.
|
2023-11-28 10:24:33 +08:00
|
|
|
-l {cpp,lua}
|
2023-08-30 08:34:33 +08:00
|
|
|
Major programming language you want to use, should be [cpp | lua]
|
|
|
|
--portrait
|
|
|
|
Set the project be portrait.
|
2024-04-10 22:11:42 +08:00
|
|
|
-i[solated]
|
|
|
|
optionl, if present, will copy full engine sources to path/to/project/axmol
|
2023-08-30 08:34:33 +08:00
|
|
|
"@;
|
|
|
|
};
|
|
|
|
build = @{
|
|
|
|
proc = ${function:axmol_build};
|
|
|
|
usage = @"
|
2024-04-07 23:32:28 +08:00
|
|
|
usage: axmol [build] -p win32 -a x64
|
2023-08-30 08:34:33 +08:00
|
|
|
|
|
|
|
Build projects to binary.
|
|
|
|
|
|
|
|
options:
|
|
|
|
-h: show this help message and exit
|
2024-01-06 01:09:31 +08:00
|
|
|
-p: build target platform, valid value are: win32,winuwp(winrt),linux,android,osx,ios,tvos,wasm
|
2023-11-28 10:24:33 +08:00
|
|
|
for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first,
|
2023-08-30 08:34:33 +08:00
|
|
|
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'
|
2024-03-04 22:26:37 +08:00
|
|
|
-c: no build, only generate native project files (vs .sln, xcodeproj)
|
2023-08-30 08:34:33 +08:00
|
|
|
-d: specify project dir to compile, i.e. -d /path/your/project/
|
2024-03-04 22:26:37 +08:00
|
|
|
-f: force generate native project files. Useful if no changes are detected, such as with resource updates.
|
2024-04-09 02:42:25 +08:00
|
|
|
-u: request upgrade prebuilt 3rd
|
2023-08-30 08:34:33 +08:00
|
|
|
examples:
|
2023-11-28 10:24:33 +08:00
|
|
|
- win32:
|
2024-04-07 23:32:28 +08:00
|
|
|
- axmol [build] -p win32
|
|
|
|
- axmol [build] -p win32 -cc clang
|
2023-08-30 08:34:33 +08:00
|
|
|
- winuwp: axmol build -p winuwp
|
|
|
|
- linux: axmol build -p linux
|
2023-11-28 10:24:33 +08:00
|
|
|
- android:
|
2024-04-07 23:32:28 +08:00
|
|
|
- axmol [build] -p android -a arm64
|
|
|
|
- axmol [build] -p android -a 'arm64;x64'
|
2023-11-28 10:24:33 +08:00
|
|
|
- osx:
|
2024-04-07 23:32:28 +08:00
|
|
|
- axmol [build] -p osx -a x64
|
|
|
|
- axmol [build] -p osx -a arm64
|
|
|
|
- ios: axmol [build] -p ios -a x64
|
|
|
|
- tvos: axmol [build] -p tvos -a x64
|
|
|
|
- wasm: axmol [build] -p wasm
|
2023-08-30 08:34:33 +08:00
|
|
|
"@;
|
|
|
|
};
|
|
|
|
deploy = @{
|
|
|
|
proc = ${function:axmol_deploy};
|
|
|
|
usage = @"
|
|
|
|
usage: axmol install -p win32 -a x64
|
|
|
|
|
|
|
|
Build and install a project to a device/simulator.
|
|
|
|
|
|
|
|
options:
|
2023-09-08 22:05:16 +08:00
|
|
|
-p: build target platform: win32,winuwp,linux,android,osx,ios,tvos,wasm
|
2023-11-28 10:24:33 +08:00
|
|
|
for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first,
|
2023-08-30 08:34:33 +08:00
|
|
|
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'
|
2024-03-04 22:26:37 +08:00
|
|
|
-c: no build, only generate native project files (vs .sln, xcodeproj)
|
2023-08-30 08:34:33 +08:00
|
|
|
-d: specify project dir to compile, i.e. -d /path/your/project/
|
2024-03-04 22:26:37 +08:00
|
|
|
-f: force generate native project files. Useful if no changes are detected, such as with resource updates.
|
2023-08-30 08:34:33 +08:00
|
|
|
"@;
|
|
|
|
};
|
|
|
|
run = @{
|
|
|
|
proc = ${function:axmol_run};
|
|
|
|
usage = @"
|
|
|
|
usage: axmol run -p win32 -a x64
|
|
|
|
Build, deploy and run project on the target.
|
|
|
|
|
|
|
|
options:
|
2023-09-08 22:05:16 +08:00
|
|
|
-p: build target platform: win32,winuwp,linux,android,osx,ios,tvos,wasm
|
2023-11-28 10:24:33 +08:00
|
|
|
for android: will search ndk in sdk_root which is specified by env:ANDROID_HOME first,
|
2023-08-30 08:34:33 +08:00
|
|
|
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'
|
2024-03-04 22:26:37 +08:00
|
|
|
-c: no build, only generate native project files (vs .sln, xcodeproj)
|
2023-08-30 08:34:33 +08:00
|
|
|
-d: specify project dir to compile, i.e. -d /path/your/project/
|
2024-03-04 22:26:37 +08:00
|
|
|
-f: force generate native project files. Useful if no changes are detected, such as with resource updates.
|
2023-08-30 08:34:33 +08:00
|
|
|
"@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 16:16:53 +08:00
|
|
|
# print version message
|
2024-04-09 02:42:25 +08:00
|
|
|
if ($cmdName -eq '--version' -or $cmdName -eq '-V') {
|
2024-01-20 16:16:53 +08:00
|
|
|
$version_msg = @"
|
|
|
|
axmol version {0}
|
|
|
|
|
2024-03-14 23:29:26 +08:00
|
|
|
Axmol Engine maintained and supported by axmol community (axmol.dev)
|
2024-01-20 16:16:53 +08:00
|
|
|
"@ -f $axmolVersion
|
|
|
|
Write-Host $version_msg
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-04-07 23:32:28 +08:00
|
|
|
$plugin = $builtinPlugins["$cmdName"]
|
2024-04-09 02:42:25 +08:00
|
|
|
if ($plugin) {
|
2024-04-07 23:32:28 +08:00
|
|
|
# -h will consumed by param
|
|
|
|
# !!!Note: 3 condition statement: 'xxx = if(c) { v1 } else { v2 }' will lost array type if source array only 1 element
|
|
|
|
if ($args.Count -gt 1) {
|
|
|
|
$sub_args = $args[1..($args.Count - 1)]
|
|
|
|
}
|
|
|
|
else {
|
2024-04-30 21:07:10 +08:00
|
|
|
$sub_args = @()
|
2024-04-07 23:32:28 +08:00
|
|
|
}
|
2024-04-09 02:42:25 +08:00
|
|
|
}
|
|
|
|
else {
|
2024-04-07 23:32:28 +08:00
|
|
|
$sub_args = $args
|
2023-08-30 08:34:33 +08:00
|
|
|
}
|
|
|
|
|
2024-04-09 02:42:25 +08:00
|
|
|
if ($help -or ($sub_args -and $sub_args[0] -eq '--help')) {
|
|
|
|
if ($plugin) {
|
|
|
|
println $plugin.usage
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
println $tool_usage
|
|
|
|
}
|
2024-04-07 23:32:28 +08:00
|
|
|
return
|
2024-01-20 16:16:53 +08:00
|
|
|
}
|
2024-04-07 23:32:28 +08:00
|
|
|
|
2024-04-09 02:42:25 +08:00
|
|
|
if (!$plugin) { $plugin = $builtinPlugins['build'] }
|
2023-08-30 08:34:33 +08:00
|
|
|
|
2024-01-20 16:16:53 +08:00
|
|
|
# force convert sub_args to array if it's a single string
|
|
|
|
if ($sub_args -isnot [array]) {
|
|
|
|
$sub_args = @($sub_args)
|
|
|
|
}
|
|
|
|
|
2023-09-12 19:28:17 +08:00
|
|
|
$sub_opts = @{}
|
2024-03-22 23:37:16 +08:00
|
|
|
if (!$sub_args.Contains('-d')) {
|
2023-09-23 11:33:12 +08:00
|
|
|
$sub_opts['d'] = $(Get-Location).Path
|
2023-09-12 19:28:17 +08:00
|
|
|
}
|
|
|
|
|
2023-09-26 14:28:10 +08:00
|
|
|
if ($args[0] -eq 'new') {
|
2024-03-22 23:37:16 +08:00
|
|
|
if (!$sub_args.Contains('-p')) {
|
2023-09-26 14:28:10 +08:00
|
|
|
$sub_opts['p'] = 'org.axmol.demo'
|
|
|
|
}
|
2024-03-22 23:37:16 +08:00
|
|
|
if (!$sub_args.Contains('-l')) {
|
2023-09-26 14:28:10 +08:00
|
|
|
$sub_opts['l'] = 'cpp'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-20 16:16:53 +08:00
|
|
|
. $plugin.proc @sub_args @sub_opts
|
2024-05-22 01:23:28 +08:00
|
|
|
|
|
|
|
exit $LASTEXITCODE
|