Skip to content

[build.ps1] remove Android API level from Dispatch.swiftmodule names #78800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 29, 2025

Conversation

andrurogerz
Copy link
Contributor

@andrurogerz andrurogerz commented Jan 22, 2025

Purpose

When determining output paths for Android binaries in the SDK, ensure that the Android API level integer is not included in paths. E.g. use the versionless "module triple" aarch64-unknown-linux-android instead of aarch64-unknown-linux-android28.

Overview

  • Add a new Get-TargetInfo $Arch method that returns the result of swift.exe -target $Arch.LLVMTarget -print-target-info as parsed JSON object using the newly built toolchain
    • Cache the result in the $Arch hashtable to avoid making multiple calls
  • Add a new Get-ModuleTriple $Arch method that calls Get-TargetInfo $Arch and returns the resulting .target.moduleTriple string
  • Use Get-ModuleTriple to calculate the target path in Install-Platform when copying .swiftmodule, .swiftdoc, and .swiftinterface files (this case includes Dispatch.swiftmodule).
  • Replace existing calls to $Arch.LLVMTarget.Replace("$AndroidAPILevel","") with a Get-ModuleTriple $Arch

Validation

Local toolchain build with -AndroidSDKs aarch64,x86_64 and verified the expected directory structure of the Dispatch module in the Android SDK:

S:\Program Files>dir /s /b "S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule"
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\aarch64-unknown-linux-android.swiftdoc
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\aarch64-unknown-linux-android.swiftmodule
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\armv7-unknown-linux-android.swiftdoc
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\armv7-unknown-linux-android.swiftmodule
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\i686-unknown-linux-android.swiftdoc
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\i686-unknown-linux-android.swiftmodule
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\x86_64-unknown-linux-android.swiftdoc
S:\Program Files\Swift\Platforms\Android.platform\Developer\SDKs\Android.sdk\usr\lib\swift\android\Dispatch.swiftmodule\x86_64-unknown-linux-android.swiftmodule

Successfully built this simple Swift program for Android using the locally built SDK.

@andrurogerz andrurogerz force-pushed the android-dispatch-module-fix branch from abc4865 to e4e83c5 Compare January 22, 2025 01:29
@andrurogerz andrurogerz force-pushed the android-dispatch-module-fix branch from e4e83c5 to cee51d4 Compare January 22, 2025 01:43
@andrurogerz andrurogerz marked this pull request as ready for review January 22, 2025 16:56
@compnerd
Copy link
Member

@swift-ci please smoke test

@compnerd
Copy link
Member

@swift-ci please test

@compnerd compnerd merged commit 43d8183 into swiftlang:main Jan 29, 2025
5 checks passed
@andrurogerz andrurogerz deleted the android-dispatch-module-fix branch January 29, 2025 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants