-
Notifications
You must be signed in to change notification settings - Fork 47
Fix Android build for non-default NDKs with new swift-build build system, by updating ANDROID_NDK_ROOT too #280
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -815,12 +815,16 @@ build() { | |
|
|
||
| alias swift='$SWIFT_EXECUTABLE_FOR_ANDROID_SDK' | ||
|
|
||
| log "Using NDK at $ANDROID_NDK_HOME" | ||
|
|
||
| # This can become a single invocation in the future when `swift build` supports multiple Android triples at once | ||
| for android_sdk_triple in "${ANDROID_SDK_TRIPLES[@]}" ; do | ||
| if [[ "$SWIFT_VERSION_INPUT" == "6.3" || "$SWIFT_VERSION_INPUT" == "nightly-6.3" ]]; then | ||
| local build_command="$SWIFT_BUILD_COMMAND --swift-sdk ${android_sdk_triple}" | ||
| else | ||
| local build_command="$SWIFT_BUILD_COMMAND --swift-sdk ${sdk_name} --triple ${android_sdk_triple}" | ||
| # Work around swift-build issue with ANDROID_NDK_ROOT overriding ANDROID_NDK_HOME | ||
| export ANDROID_NDK_ROOT="${ANDROID_NDK_HOME}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please put this closer to line 667 so both vars are in the same place?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put it here so it isn't messed with for 6.3 builds. I'd like to get rid of this instead for
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine, there's no reason it needs to be excluded for 6.3 builds.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're probably right, but given stuff like swift-driver incorrectly invoking it before 6.3, I played it safe. |
||
| fi | ||
| if [[ -n "$SWIFT_BUILD_FLAGS" ]]; then | ||
| build_command="$build_command $SWIFT_BUILD_FLAGS" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakepetroules,
swift-buildis not using this environment variable properly on the GitHub CI, where it is correctly set to 28c before the build starts, but the internal compile shows it using NDK 27 instead. I tried setting it in$GITHUB_ENValso in the next line, but that made no difference.This is why I pushed to not have these flaky env vars be the primary way we configure the NDK for SwiftPM, and to always notify the user that the env var is being used and with which NDK path.
Let me know if you have any idea about this bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift Build checks both ANDROID_NDK_ROOT and ANDROID_NDK_HOME, with the first taking precedence. Since GitHub Actions sets both, _ROOT is pointing to 27 still.
Go ahead and update GitHub actions to set both variables.
It's probably a good idea to emit a diagnostic in Swift Build if those two are set to different values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that was it, will clean this up and submit as a workaround for now.