Skip to content

Commit ed71791

Browse files
committed
Add post-install script to SDK bundle
1 parent 812cd40 commit ed71791

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ if [[ ${INCLUDE_NDK_SYSROOT} != 1 ]]; then
488488
mkdir scripts/
489489
cat > scripts/setup-android-sdk.sh <<'EOF'
490490
#/bin/sh
491+
# this script will setup the ndk-sysroot with links to the
492+
# local installation indicated by ANDROID_NDK_HOME
491493
set -e
492494
if [ -z "${ANDROID_NDK_HOME}" ]; then
493495
echo "$(basename $0): error: missing environment variable ANDROID_NDK_HOME"
@@ -501,14 +503,27 @@ fi
501503
DESTINATION=$(dirname $(dirname $(realpath $0)))/ndk-sysroot
502504
# clear out any previous NDK setup
503505
rm -rf ${DESTINATION}
504-
cp -a ${PREBUILT}/*/sysroot ${DESTINATION}
505506
506-
mkdir -p ${DESTINATION}/usr/lib/swift/android
507+
# copy vs. link the NDK files
508+
ANDROID_NDK_LINK=${ANDROID_NDK_LINK:-1}
509+
if [[ "${ANDROID_NDK_LINK}" != 1 ]]; then
510+
ANDROID_NDK_DESC="copied"
511+
cp -a ${PREBUILT}/*/sysroot ${DESTINATION}
512+
else
513+
ANDROID_NDK_DESC="linked"
514+
mkdir -p ${DESTINATION}/usr/lib
515+
ln -s $(realpath ${PREBUILT}/*/sysroot/usr/include) ${DESTINATION}/usr/include
516+
for triplePath in ${PREBUILT}/*/sysroot/usr/lib/*; do
517+
triple=$(basename ${triplePath})
518+
ln -s $(realpath ${triplePath}) ${DESTINATION}/usr/lib/${triple}
519+
done
520+
fi
507521
508522
# copy each architecture's swiftrt.o into the sysroot
523+
mkdir -p ${DESTINATION}/usr/lib/swift/android
509524
cp -a ${DESTINATION}/../swift-resources/usr/lib/swift-*/android/* ${DESTINATION}/usr/lib/swift/android/
510525
511-
echo "$(basename $0): success: ndk-sysroot copied to Android SDK"
526+
echo "$(basename $0): success: ndk-sysroot ${ANDROID_NDK_DESC} to Android SDK"
512527
EOF
513528
chmod +x scripts/setup-android-sdk.sh
514529
else

0 commit comments

Comments
 (0)