Skip to content

Commit 2972a4e

Browse files
committed
1 parent 634929f commit 2972a4e

File tree

2 files changed

+13
-44
lines changed

2 files changed

+13
-44
lines changed

swift-ci/sdks/android/build-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ source ./scripts/toolchain-vars.sh
2424
./scripts/patch-sources.sh ${WORKDIR}/source
2525

2626
mkdir -p ${WORKDIR}/products
27+
chmod ugo+rwx ${WORKDIR}/products
2728

2829
if [[ "$DOCKER" == "" ]]; then
2930
DOCKER=docker

swift-ci/sdks/android/scripts/build.sh

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ echo " - curl ${curl_version}"
248248
echo " - BoringSSL ${boringssl_version}"
249249

250250
# make sure the products_dir is writeable
251-
mount
252251
ls -lad $products_dir
253252
touch $products_dir/products_dir_write_test.tmp
254253
rm $products_dir/products_dir_write_test.tmp
@@ -494,15 +493,16 @@ for arch in $archs; do
494493
rsync -a ${sdk_staging}/${arch}/usr ${swift_res_root}
495494
done
496495

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+
497503
ndk_sysroot="ndk-sysroot"
498504

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'
506506
#/bin/bash
507507
# this script will setup the ndk-sysroot with links to the
508508
# local installation indicated by ANDROID_NDK_HOME
@@ -518,8 +518,6 @@ if [ ! -d "${ndk_prebuilt}" ]; then
518518
exit 1
519519
fi
520520
521-
ndk_sysroot=${ndk_prebuilt}/linux-x86_64/sysroot
522-
523521
#Pkg.Revision = 27.0.12077973
524522
#Pkg.Revision = 28.1.13356709
525523
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
528526
exit 1
529527
fi
530528
531-
cd $(dirname $(dirname $(realpath $0)))
529+
cd $(dirname $(dirname $(realpath -- "${BASH_SOURCE[0]}")))
532530
swift_resources=swift-resources
533531
ndk_sysroot=ndk-sysroot
534532
@@ -538,7 +536,6 @@ if [[ -d "${ndk_sysroot}" ]]; then
538536
ndk_re="re-"
539537
fi
540538
541-
542539
# link vs. copy the NDK files
543540
SWIFT_ANDROID_NDK_LINK=${SWIFT_ANDROID_NDK_LINK:-1}
544541
if [[ "${SWIFT_ANDROID_NDK_LINK}" == 1 ]]; then
@@ -570,38 +567,8 @@ done
570567
571568
echo "$(basename $0): success: ndk-sysroot ${ndk_action} to Android NDK at ${ndk_prebuilt}"
572569
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
591570

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
605572

606573
cat > swift-sdk.json <<EOF
607574
{
@@ -659,7 +626,8 @@ header "Outputting compressed bundle"
659626

660627
quiet_pushd "${build_dir}"
661628
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}"
663631
quiet_popd
664632

665633
groupend

0 commit comments

Comments
 (0)