-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[android] Get build scripts working natively, fix tests and install #29296
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
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 |
---|---|---|
|
@@ -460,6 +460,10 @@ function set_build_options_for_host() { | |
SWIFT_HOST_VARIANT_ARCH=$architecture | ||
|
||
case ${host} in | ||
android-aarch64) | ||
SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android" | ||
llvm_target_arch="AArch64" | ||
;; | ||
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 the intention of this function is for cross-compiled targets, which should not be your case, and it will also apply to the NDK compilation route unintentionally. I think the right point is probably closer to where the other usage of I will simply discard this part, and use something like the following there:
Unless I am misunderstanding something here, the values you provide are the defaults, and the only significant change is the API level (which is not applied to you because confusingly the 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. Yes, this is really meant for cross-compiling the host toolchain, but I need the host triple and API level when natively compiling the host toolchain on Android too, and since these flags are applied for native compilation of the host toolchain too, I went ahead and filled this out, following the instructions above to specify I need the host triple because I've always needed to set As for the API level, I needed it for native compilation so I stuck it here, but your suggestion is better so I will move that one alone, while keeping these other two here. 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. OK. I didn't know that LLVM didn't autodetect Android triple. As a workaround, we can accept this, but I would not mind a comment explain why it is needed. I would also suggest that this might be something that LLVM should actually do, and upstreaming such patch might be interesting. 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. No comment needed, as this triple is also definitely needed if cross-compiling the host toolchain, which will be the focus of my next pull. I have not looked into where LLVM auto-detects this, always manually specifying it instead, but you're right that it is worth adding. |
||
linux-armv6) | ||
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf" | ||
llvm_target_arch="ARM" | ||
|
@@ -1553,12 +1557,18 @@ for host in "${ALL_HOSTS[@]}"; do | |
|
||
swift) | ||
|
||
if [[ "${ANDROID_API_LEVEL}" ]]; then | ||
cmake_options=( | ||
"${cmake_options[@]}" | ||
-DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}" | ||
) | ||
fi | ||
|
||
if [[ ! "${SKIP_BUILD_ANDROID}" ]]; then | ||
cmake_options=( | ||
"${cmake_options[@]}" | ||
-DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK}" | ||
-DSWIFT_ANDROID_NDK_GCC_VERSION:STRING="${ANDROID_NDK_GCC_VERSION}" | ||
-DSWIFT_ANDROID_API_LEVEL:STRING="${ANDROID_API_LEVEL}" | ||
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC:STRING="${ANDROID_ICU_UC}" | ||
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_UC_INCLUDE:STRING="${ANDROID_ICU_UC_INCLUDE}" | ||
-DSWIFT_ANDROID_${ANDROID_ARCH}_ICU_I18N:STRING="${ANDROID_ICU_I18N}" | ||
|
@@ -2192,6 +2202,8 @@ for host in "${ALL_HOSTS[@]}"; do | |
HOST_CXX_HEADERS_DIR="$HOST_CXX_DIR/../../usr/include/c++" | ||
elif [[ "$(uname -s)" == "Haiku" ]] ; then | ||
HOST_CXX_HEADERS_DIR="/boot/system/develop/headers/c++" | ||
elif [[ "${ANDROID_DATA}" ]] ; then | ||
HOST_CXX_HEADERS_DIR="$PREFIX/include/c++" | ||
else # Linux | ||
HOST_CXX_HEADERS_DIR="/usr/include/c++" | ||
fi | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,7 +223,11 @@ def _apply_default_arguments(args): | |
args.test_watchos_simulator = False | ||
|
||
if not args.build_android: | ||
args.test_android = False | ||
# If building natively on an Android host, allow running the test suite | ||
# without the NDK config. | ||
if not StdlibDeploymentTarget.Android.contains(StdlibDeploymentTarget | ||
.host_target().name): | ||
args.test_android = False | ||
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 the problem is that a lot of logic is tied to In also think that you might want to move the check to the L248, instead of here, because otherwise the 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 found it confusing that there's a pair of seemingly redundant booleans to enable building for each platform, ie You are right that it's confusing that these variables really mean the Android NDK config, but I tried to clear that up with the comments and I doubt anyone will touch the native host config after this, so probably fine. If you have some suggestion to clarify it by internal variable renaming or something, e.g.
No, that was intentional, I don't want the host tests with adb to run. if |
||
args.test_android_host = False | ||
|
||
if not args.test_android: | ||
|
Uh oh!
There was an error while loading. Please reload this page.