@@ -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
491493set -e
492494if [ -z "${ANDROID_NDK_HOME}" ]; then
493495 echo "$(basename $0): error: missing environment variable ANDROID_NDK_HOME"
501503DESTINATION=$(dirname $(dirname $(realpath $0)))/ndk-sysroot
502504# clear out any previous NDK setup
503505rm -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
509524cp -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"
512527EOF
513528 chmod +x scripts/setup-android-sdk.sh
514529else
0 commit comments