aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Ryan Gardner <ryan.gardner@coxautoinc.com>2021-05-17 19:43:51 -0400
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-05-20 15:10:52 -0700
commiteffd0dbae8bd7b21d386cb68653e80a87e82e6bf (patch)
tree3dd8b5196ba6962bb6d9071ea0dfe962f2aa2419
parent2d734c529b5eb389ca9526575c9520b444d21a30 (diff)
downloadsubsurface-effd0dbae8bd7b21d386cb68653e80a87e82e6bf.tar.gz
Make the Mac SDK detection in build.sh more robust
When trying to build on Big Sur, the xcode command-line tools install are installed in /Library/Developer/CommandLineTools/SDKs, and as of Xcode 12.5, it does not include a 10.x version of SDK. This changes it to search in the location of the command-line tools SDK for a 10.x version, and if it can't find a 10.x version it will find an explicit 11.x version of the SDK to use because it is conceivable that in the near future Apple will stop installing any 10.x SDK's as part of the command-line tool installer. If the SDK can't be found, the build script will exit now instead of continuing with an unset BASESDK version that causes a later failure. Signed-off-by: Ryan Gardner <ryan.gardner@coxautoinc.com>
-rwxr-xr-xscripts/build.sh16
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
index 52e30c0c9..133c483f2 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -147,6 +147,8 @@ fi
if [ "$PLATFORM" = Darwin ] ; then
if [ -d /Developer/SDKs ] ; then
SDKROOT=/Developer/SDKs
+ elif [ -d /Library/Developer/CommandLineTools/SDKs ] ; then
+ SDKROOT=/Library/Developer/CommandLineTools/SDKs
elif [ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ] ; then
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
else
@@ -154,10 +156,20 @@ if [ "$PLATFORM" = Darwin ] ; then
echo "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)"
exit 1;
fi
+ # find a 10.x base SDK to use, or if none can be found, find a numbered 11.x base SDK to use
BASESDK=$(ls $SDKROOT | grep "MacOSX10\.1.\.sdk" | head -1 | sed -e "s/MacOSX//;s/\.sdk//")
- OLDER_MAC="-mmacosx-version-min=10.11 -isysroot${SDKROOT}/MacOSX${BASESDK}.sdk"
+ if [ -z "$BASESDK" ] ; then
+ BASESDK=$(ls $SDKROOT | grep -E "MacOSX11\.[0-9]+\.sdk" | head -1 | sed -e "s/MacOSX//;s/\.sdk//")
+ if [ -z "$BASESDK" ] ; then
+ echo "Cannot find a base SDK of type 10.x or 11.x under the SDK root of ${SDKROOT}"
+ exit 1;
+ fi
+ fi
+ echo "Using ${BASESDK} as the BASESDK under ${SDKROOT}"
+
+ OLDER_MAC="-mmacosx-version-min=${BASESDK} -isysroot${SDKROOT}/MacOSX${BASESDK}.sdk"
OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=${BASESDK} -DCMAKE_OSX_SYSROOT=${SDKROOT}/MacOSX${BASESDK}.sdk/"
- if [[ ! -d /usr/include && ! -d "${SDKROOT}/MacOSX.sdk/usr/include" ]] ; then
+ if [[ ! -d /usr/include && ! -d "${SDKROOT}/MacOSX${BASESDK}.sdk/usr/include" ]] ; then
echo "Error: Xcode Command Line Tools are not installed"
echo ""
echo "Please run:"