@@ -384,10 +384,6 @@ for arch in $archs; do
384
384
--swift-testing --install-swift-testing \
385
385
--cross-compile-append-host-target-to-destdir=False
386
386
387
- # --clean-install-destdir \
388
- # --clean \
389
-
390
-
391
387
# need to remove symlink that gets created in the NDK to the previous arch's build
392
388
# or else we get errors like:
393
389
# error: could not find module '_Builtin_float' for target 'x86_64-unknown-linux-android'; found: aarch64-unknown-linux-android, at: /home/runner/work/_temp/swift-android-sdk/ndk/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/swift/android/_Builtin_float.swiftmodule
@@ -432,16 +428,89 @@ cat > info.json <<EOF
432
428
}
433
429
EOF
434
430
431
+ quiet_pushd " $sdk_name /$sdk_base "
432
+
433
+ # ndk_sysroot_path="ndk-sysroot"
434
+ ndk_sysroot_path=" android-27c-sysroot"
435
435
436
- cd " $sdk_name /$sdk_base "
436
+ cp -a ${ndk_toolchain} /sysroot ${ndk_sysroot_path}
437
+
438
+ cat > $ndk_sysroot_path /SDKSettings.json << EOF
439
+ {
440
+ "DisplayName": "Swift Android SDK",
441
+ "Version": "${android_sdk_version} ",
442
+ "VersionMap": {},
443
+ "CanonicalName": "linux-android"
444
+ }
445
+ EOF
437
446
438
- cp -a ${ndk_toolchain} /sysroot ndk-sysroot
439
447
440
448
# quiet_pushd ndk-sysroot/usr/lib
441
449
# FIXME: need to merge the multiple x86_64 archs
442
450
# ln -s ../../../swift-android.sdk/x86_64/usr/lib/swift
443
451
# quiet_popd
444
452
453
+ # mkdir "${sdk_root}"
454
+ # quiet_pushd "${sdk_root}"
455
+ # cp -R ${build_dir}/sdk_root/* .
456
+ # quiet_popd
457
+
458
+ cp -a ${build_dir} /sdk_root sdk_root
459
+ # Copy necessary headers and libraries from the toolchain and NDK clang resource directories
460
+ SYSROOT=${ndk_sysroot_path}
461
+ TOOLCHAIN=$host_toolchain
462
+ mkdir -pv $SYSROOT /usr/lib/swift/clang/lib
463
+ cp -rv $TOOLCHAIN /lib/clang/* /include $SYSROOT /usr/lib/swift/clang
464
+
465
+ for arch in $archs ; do
466
+ quiet_pushd sdk_root/${arch} /usr
467
+ rm -r bin
468
+ rm -r include/*
469
+ cp -r ${source_dir} /swift-project/swift/lib/ClangImporter/SwiftBridging/{module.modulemap,swift} include/
470
+
471
+ arch_triple=" $arch -linux-android"
472
+ if [[ $arch == ' armv7' ]]; then
473
+ arch_triple=" arm-linux-androideabi"
474
+ fi
475
+
476
+ sdk_root_arch=../../../sdk_root/$arch /usr
477
+
478
+ mkdir lib/${arch_triple}
479
+ mv $sdk_root_arch /lib/pkgconfig $sdk_root_arch /lib/swift/android/lib* .{a,so} lib/${arch_triple}
480
+
481
+ mv lib/swift_static lib/swift_static-$arch
482
+ mv lib/lib* .a lib/swift_static-$arch /android
483
+ rm -r lib/swift{,_static-$arch }/clang
484
+ mkdir -p lib/swift/clang/lib
485
+ cp -a ${ndk_toolchain} /lib/clang/* /lib/linux lib/swift/clang/lib
486
+ ln -s ../swift/clang lib/swift_static-$arch /clang
487
+ quiet_popd
488
+
489
+ # now sync the massaged sdk_root into the ndk_sysroot_path
490
+ rsync -a sdk_root/${arch} /usr ${ndk_sysroot_path}
491
+ done
492
+
493
+ rm -r ${ndk_sysroot_path} /usr/share/{doc,man}
494
+ rm -r ${ndk_sysroot_path} /usr/{include,lib}/{i686,riscv64}-linux-android
495
+ rm -r sdk_root
496
+
497
+ # validate that some expected paths exists
498
+ quiet_pushd ${ndk_sysroot_path} /usr
499
+ ls lib/swift/android
500
+ ls lib/swift/android/x86_64
501
+ ls lib/swift/android/x86_64/swiftrt.o
502
+
503
+ ls lib/swift_static-x86_64
504
+ ls lib/swift_static-x86_64/android
505
+ ls lib/swift_static-x86_64/android/libFoundationEssentials.a
506
+
507
+ ls lib/swift/clang/lib
508
+ ls lib/swift/clang/lib/linux
509
+ ls lib/swift/clang/lib/linux/x86_64
510
+ ls lib/swift/clang/lib/linux/x86_64/libunwind.a
511
+ ls lib/x86_64-linux-android/28/crtbegin_dynamic.o
512
+ quiet_popd
513
+
445
514
cat > swift-sdk.json << EOF
446
515
{
447
516
"schemaVersion": "4.0",
462
531
fi
463
532
cat >> swift-sdk.json << EOF
464
533
"${arch} -unknown-linux-android${api} ": {
465
- "sdkRootPath": "ndk-sysroot ",
466
- "swiftResourcesPath": "${sdk_root} / ${arch } /usr/lib/swift",
467
- "swiftStaticResourcesPath": "${sdk_root} / ${arch} / usr/lib/swift_static",
534
+ "sdkRootPath": "${ndk_sysroot_path} ",
535
+ "swiftResourcesPath": "${ndk_sysroot_path } /usr/lib/swift",
536
+ "swiftStaticResourcesPath": "${ndk_sysroot_path} / usr/lib/swift_static- ${arch} ",
468
537
"toolsetPaths": [ "swift-toolset.json" ]
469
538
EOF
470
539
done
@@ -476,11 +545,6 @@ cat >> swift-sdk.json <<EOF
476
545
}
477
546
EOF
478
547
479
- mkdir " ${sdk_root} "
480
- quiet_pushd " ${sdk_root} "
481
- cp -R ${build_dir} /sdk_root/* .
482
- quiet_popd
483
-
484
548
cat > swift-toolset.json << EOF
485
549
{
486
550
"cCompiler": { "extraCLIOptions": ["-fPIC"] },
0 commit comments