-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[android] Modify test scripts for aarch64 and modern NDKs. #19503
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 |
---|---|---|
|
@@ -930,39 +930,68 @@ elif run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'windows-cygnus', 'wi | |
"clang++ -target %s %s" % | ||
(config.variant_triple, clang_mcp_opt)) | ||
config.target_ld = "ld -L%r" % (make_path(test_resource_dir, config.target_sdk_name)) | ||
elif run_os == 'linux-androideabi': | ||
elif run_os == 'linux-androideabi' or run_os == 'linux-android': | ||
def get_architecture_value(**kwargs): | ||
result = kwargs[run_cpu] | ||
if result is None: | ||
if run_cpu == "armv7s" or run_cpu == "armv7k": | ||
result = kwargs["armv7"] | ||
elif run_cpu == "arm64": | ||
result = kwards["aarch64"] | ||
return result | ||
|
||
ndk_platform_tuple = get_architecture_value(armv7="armeabi-v7a", | ||
aarch64="arm64-v8a") | ||
ndk_platform_triple = get_architecture_value(armv7="arm-linux-androideabi", | ||
aarch64="aarch64-linux-android") | ||
toolchain_directory_name = "{}-{}".format(ndk_platform_triple, config.android_ndk_gcc_version) | ||
tools_directory = make_path(config.android_ndk_path, "toolchains", | ||
toolchain_directory_name, "prebuilt", "linux-x86_64", | ||
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.
|
||
ndk_platform_triple, "bin") | ||
lit_config.note("Testing Android " + config.variant_triple) | ||
config.target_object_format = "elf" | ||
config.target_shared_library_prefix = 'lib' | ||
config.target_shared_library_suffix = ".so" | ||
config.target_swiftmodule_name = get_architecture_value(armv7="arm.swiftmodule", | ||
aarch64="arm64.swiftmodule") | ||
config.target_swiftdoc_name = get_architecture_value(armv7="arm.swiftdoc", | ||
aarch64="arm64.swiftdoc") | ||
config.target_runtime = "native" | ||
config.target_swift_autolink_extract = inferSwiftBinary("swift-autolink-extract") | ||
config.target_sdk_name = "android" | ||
android_linker_opt = "-L {libcxx} -L {libgcc}".format( | ||
android_link_paths_opt = "-L {libcxx} -L {libgcc}".format( | ||
libcxx=make_path(config.android_ndk_path, | ||
"sources", "cxx-stl", "llvm-libc++", "libs", | ||
"armeabi-v7a"), | ||
"sources", "cxx-stl", "llvm-libc++", "libs", ndk_platform_tuple), | ||
libgcc=make_path(config.android_ndk_path, | ||
"toolchains", | ||
"arm-linux-androideabi-{}".format(config.android_ndk_gcc_version), | ||
"prebuilt", "linux-x86_64", "lib", "gcc", | ||
"arm-linux-androideabi", | ||
"toolchains", toolchain_directory_name, "prebuilt", | ||
"linux-x86_64", "lib", "gcc", ndk_platform_triple, | ||
"{}.x".format(config.android_ndk_gcc_version))) | ||
# Since NDK r14 the headers are unified under $NDK_PATH/sysroot, so the -sdk | ||
# switch is not enough. Additionally we have to include both the unified | ||
# sysroot, and the architecture sysroot. | ||
android_include_paths_opt = "-I {sysroot} -I {sysroot_arch}".format( | ||
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 that we should use |
||
sysroot=make_path(config.android_ndk_path, "sysroot", "usr", "include"), | ||
sysroot_arch=make_path(config.android_ndk_path, "sysroot", "usr", | ||
"include", ndk_platform_triple)) | ||
config.target_build_swift = ( | ||
'%s -target %s -sdk %r %s -Xlinker -pie %s %s %s %s %s' | ||
% (config.swiftc, config.variant_triple, config.variant_sdk, | ||
android_linker_opt, resource_dir_opt, mcp_opt, | ||
config.swift_test_options, | ||
'%s -target %s -sdk %r -tools-directory %r %s %s ' | ||
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. Why not the |
||
'-use-ld=%s %s %s %s %s %s' | ||
% (config.swiftc, | ||
config.variant_triple, config.variant_sdk, | ||
tools_directory, android_include_paths_opt, android_link_paths_opt, | ||
config.android_linker_name, | ||
resource_dir_opt, mcp_opt, config.swift_test_options, | ||
config.swift_driver_test_options, swift_execution_tests_extra_flags)) | ||
config.target_codesign = "echo" | ||
config.target_build_swift_dylib = ( | ||
"%s -parse-as-library -emit-library -o '\\1'" | ||
% (config.target_build_swift)) | ||
config.target_add_rpath = r'-Xlinker -rpath -Xlinker \1' | ||
config.target_swift_frontend = ( | ||
'%s -frontend -target %s -sdk %r %s %s %s %s' | ||
'%s -frontend -target %s -sdk %r %s %s %s %s %s %s' | ||
% (config.swift, config.variant_triple, config.variant_sdk, | ||
android_linker_opt, resource_dir_opt, mcp_opt, | ||
android_include_paths_opt, android_link_paths_opt, resource_dir_opt, | ||
mcp_opt, config.swift_test_options, | ||
config.swift_frontend_test_options)) | ||
subst_target_swift_frontend_mock_sdk = config.target_swift_frontend | ||
subst_target_swift_frontend_mock_sdk_after = "" | ||
|
@@ -978,19 +1007,18 @@ elif run_os == 'linux-androideabi': | |
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test | ||
subst_target_swift_ide_test_mock_sdk_after = "" | ||
config.target_swiftc_driver = ( | ||
"%s -target %s -sdk %r %s %s %s" % | ||
"%s -target %s -sdk %r -tools-directory %s %s %s %s -use-ld=%s" % | ||
(config.swiftc, config.variant_triple, config.variant_sdk, | ||
android_linker_opt, resource_dir_opt, mcp_opt)) | ||
tools_directory, android_link_paths_opt, resource_dir_opt, mcp_opt, | ||
config.android_linker_name)) | ||
config.target_swift_modulewrap = ( | ||
'%s -modulewrap -target %s' % | ||
(config.swiftc, config.variant_triple)) | ||
config.target_clang = ( | ||
"clang++ -target %s %s" % | ||
(config.variant_triple, clang_mcp_opt)) | ||
"clang++ -target %s %s %s" % | ||
(config.variant_triple, clang_mcp_opt, android_include_paths_opt)) | ||
config.target_ld = "{} -L{}".format( | ||
make_path(config.android_ndk_path, 'toolchains', | ||
'arm-linux-androideabi-{}'.format(config.android_ndk_gcc_version), | ||
'prebuilt', 'linux-x86_64', 'arm-linux-androideabi', 'bin'), | ||
tools_directory, | ||
make_path(test_resource_dir, config.target_sdk_name)) | ||
# The Swift interpreter is not available when targeting Android. | ||
config.available_features.remove('swift_interpreter') | ||
|
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.
I would rewrite this as:
if run_cpu.startswith('armv7'): return kwargs["armv7"]