@@ -248,7 +248,6 @@ echo " - curl ${curl_version}"
248
248
echo " - BoringSSL ${boringssl_version} "
249
249
250
250
# make sure the products_dir is writeable
251
- mount
252
251
ls -lad $products_dir
253
252
touch $products_dir /products_dir_write_test.tmp
254
253
rm $products_dir /products_dir_write_test.tmp
@@ -494,15 +493,16 @@ for arch in $archs; do
494
493
rsync -a ${sdk_staging} /${arch} /usr ${swift_res_root}
495
494
done
496
495
496
+ rm -r ${swift_res_root} /usr/share/{doc,man}
497
+ rm -r ${sdk_staging}
498
+
499
+ # create an install script to set up the NDK links
500
+ # ANDROID_NDK_HOME="/opt/homebrew/share/android-ndk"
501
+ mkdir scripts/
502
+
497
503
ndk_sysroot=" ndk-sysroot"
498
504
499
- # whether to include the ndk-sysroot in the SDK bundle
500
- INCLUDE_NDK_SYSROOT=${INCLUDE_NDK_SYSROOT:- 0}
501
- if [[ ${INCLUDE_NDK_SYSROOT} != 1 ]]; then
502
- # if we do not include the NDK, then create an install script
503
- # ANDROID_NDK_HOME="/opt/homebrew/share/android-ndk"
504
- mkdir scripts/
505
- cat > scripts/setup-android-sdk.sh << 'EOF '
505
+ cat > scripts/setup-android-sdk.sh << 'EOF '
506
506
#/bin/bash
507
507
# this script will setup the ndk-sysroot with links to the
508
508
# local installation indicated by ANDROID_NDK_HOME
@@ -518,8 +518,6 @@ if [ ! -d "${ndk_prebuilt}" ]; then
518
518
exit 1
519
519
fi
520
520
521
- ndk_sysroot=${ndk_prebuilt}/linux-x86_64/sysroot
522
-
523
521
#Pkg.Revision = 27.0.12077973
524
522
#Pkg.Revision = 28.1.13356709
525
523
ndk_version=$(grep '^Pkg.Revision = ' "${ANDROID_NDK_HOME}/source.properties" | cut -f3- -d' ' | cut -f 1 -d '.')
@@ -528,7 +526,7 @@ if [[ "${ndk_version}" -lt 27 ]]; then
528
526
exit 1
529
527
fi
530
528
531
- cd $(dirname $(dirname $(realpath $0 )))
529
+ cd $(dirname $(dirname $(realpath -- "${BASH_SOURCE[0]}" )))
532
530
swift_resources=swift-resources
533
531
ndk_sysroot=ndk-sysroot
534
532
@@ -538,7 +536,6 @@ if [[ -d "${ndk_sysroot}" ]]; then
538
536
ndk_re="re-"
539
537
fi
540
538
541
-
542
539
# link vs. copy the NDK files
543
540
SWIFT_ANDROID_NDK_LINK=${SWIFT_ANDROID_NDK_LINK:-1}
544
541
if [[ "${SWIFT_ANDROID_NDK_LINK}" == 1 ]]; then
@@ -570,38 +567,8 @@ done
570
567
571
568
echo "$(basename $0): success: ndk-sysroot ${ndk_action} to Android NDK at ${ndk_prebuilt}"
572
569
EOF
573
- chmod +x scripts/setup-android-sdk.sh
574
- else
575
- COPY_NDK_SYSROOT=${COPY_NDK_SYSROOT:- 1}
576
- if [[ ${COPY_NDK_SYSROOT} == 1 ]]; then
577
- cp -a ${ndk_installation} /sysroot ${ndk_sysroot}
578
- else
579
- # rather than copying the sysroot, we can instead make links to
580
- # the various sub-folders this won't work for the distribution,
581
- # since the NDK is going to be located in different places
582
- # for different machines
583
- mkdir -p ${ndk_sysroot} /usr/lib
584
- ln -sv $( realpath ${ndk_installation} /sysroot/usr/include) ${ndk_sysroot} /usr/include
585
- for triplePath in ${ndk_installation} /sysroot/usr/lib/* ; do
586
- triple=$( basename ${triplePath} )
587
- ln -sv $( realpath ${triplePath} ) ${ndk_sysroot} /usr/lib/${triple}
588
- ls ${ndk_sysroot} /usr/lib/${triple} /
589
- done
590
- fi
591
570
592
- # need to manually copy over swiftrt.o or else:
593
- # error: link command failed with exit code 1 (use -v to see invocation)
594
- # clang: error: no such file or directory: '${HOME}/.swiftpm/swift-sdks/swift-6.2-DEVELOPMENT-SNAPSHOT-2025-04-24-a-android-0.1.artifactbundle/swift-android/ndk-sysroot/usr/lib/swift/android/x86_64/swiftrt.o'
595
- # see: https://github.com/swiftlang/swift-driver/pull/1822#issuecomment-2762811807
596
- # should be fixed by: https://github.com/swiftlang/swift/pull/79621
597
- for arch in $archs ; do
598
- mkdir -p ${ndk_sysroot} /usr/lib/swift/android/${arch}
599
- ln -srv ${swift_res_root} /usr/lib/swift-${arch} /android/${arch} /swiftrt.o ${ndk_sysroot} /usr/lib/swift/android/${arch} /swiftrt.o
600
- done
601
- fi
602
-
603
- rm -r ${swift_res_root} /usr/share/{doc,man}
604
- rm -r ${sdk_staging}
571
+ chmod +x scripts/setup-android-sdk.sh
605
572
606
573
cat > swift-sdk.json << EOF
607
574
{
@@ -659,7 +626,8 @@ header "Outputting compressed bundle"
659
626
660
627
quiet_pushd " ${build_dir} "
661
628
mkdir -p " ${products_dir} "
662
- tar czf " ${products_dir} /${bundle} .tar.gz" " ${bundle} "
629
+ tar czf " ${bundle} .tar.gz" " ${bundle} "
630
+ mv " ${bundle} .tar.gz" " ${products_dir} "
663
631
quiet_popd
664
632
665
633
groupend
0 commit comments