Skip to content

Commit

Permalink
Add android cross-compile command (swiftcross).
Browse files Browse the repository at this point in the history
Signed-off-by: furby™ <[email protected]>
  • Loading branch information
furby-tm committed Sep 10, 2024
1 parent a00c5ca commit 5e912b9
Showing 1 changed file with 57 additions and 4 deletions.
61 changes: 57 additions & 4 deletions build_files/build_environment/KrakenDeveloperProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if ($IsMacOS) {
$SWIFT_SH_BUILD_PATH = "/usr/local/bin"
$RUST_CARGO_BINPATH = "/Users/$env:USER/.cargo/bin"
$POSTGRES_APP_PATH = "/Applications/Postgres.app/Contents/Versions/latest/bin"
$XCODE_TOOLCHAIN_BINPATH = "/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
# $XCODE_TOOLCHAIN_BINPATH = "/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"

# Apple Silicon (M1 Chip ---- /opt/homebrew/bin)
if (Test-Path -Path $ARM_HOMEBREW_PATH) {
Expand All @@ -63,9 +63,9 @@ if ($IsMacOS) {
}

# swift sourcekit-lsp
if (Test-Path -Path $XCODE_TOOLCHAIN_BINPATH) {
$env:PATH = '{0}{1}{2}' -f $env:PATH,[IO.Path]::PathSeparator,$XCODE_TOOLCHAIN_BINPATH
}
# if (Test-Path -Path $XCODE_TOOLCHAIN_BINPATH) {
# $env:PATH = '{0}{1}{2}' -f $env:PATH,[IO.Path]::PathSeparator,$XCODE_TOOLCHAIN_BINPATH
# }

# rust cargo
if (Test-Path -Path $RUST_CARGO_BINPATH) {
Expand Down Expand Up @@ -486,6 +486,56 @@ function BuildUnrealEngine5
}
}

# cross compile swift packages for android.
function WabiCrossCompileAndroidSwiftPackage
{
if(($Args[0] -eq 'build')) {
if(($Args[1] -eq '-c') -and ($Args[2] -eq 'release')) {
$targ = $Args[2]
$hasTarg = $false
if(($Args[1] -eq '--target')) {
$targ = $Args[2]
$hasTarg = $true
}
if(($Args[3] -eq '--target')) {
$targ = $Args[4]
$hasTarg = $true
}

if ($hasTarg) {
swift build -c release --target $targ `
--destination /Users/$env:USER/Wabi/swift-android-sdk/android-aarch64.json `
-Xlinker -rpath="`$ORIGIN/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android" 2> $null | xcbeautify --disable-logging
} else {
swift build -c release `
--destination /Users/$env:USER/Wabi/swift-android-sdk/android-aarch64.json `
-Xlinker -rpath="`$ORIGIN/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android" 2> $null | xcbeautify --disable-logging
}
} else {
$targ = $Args[2]
$hasTarg = $false
if(($Args[1] -eq '--target')) {
$targ = $Args[2]
$hasTarg = $true
}
if(($Args[3] -eq '--target')) {
$targ = $Args[4]
$hasTarg = $true
}

if ($hasTarg) {
swift build -c debug --target $targ `
--destination /Users/$env:USER/Wabi/swift-android-sdk/android-aarch64.json `
-Xlinker -rpath="`$ORIGIN/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android" 2> $null | xcbeautify --disable-logging
} else {
swift build -c debug `
--destination /Users/$env:USER/Wabi/swift-android-sdk/android-aarch64.json `
-Xlinker -rpath="`$ORIGIN/swift-5.10-android-24-sdk/usr/lib/aarch64-linux-android" 2> $null | xcbeautify --disable-logging
}
}
}
}

function WabiAnimationPreCommitHook
{
# hook.
Expand Down Expand Up @@ -1012,6 +1062,9 @@ function BuildOpenUSD
}
}

# Cross compile swift package for android.
Set-Alias swiftcross WabiCrossCompileAndroidSwiftPackage

# Build the openusd project.
Set-Alias buildusd BuildOpenUSD

Expand Down

0 comments on commit 5e912b9

Please sign in to comment.