From d5d8af3478282ffa09295714f66d9e7382517e19 Mon Sep 17 00:00:00 2001 From: Charlie Lenahan Date: Tue, 26 May 2015 20:21:42 -0400 Subject: [PATCH] Auto-detect OS X/iOS SDK versions. Detects the latest SDK installed and uses that if no SYS_VERSION param is passed to scons. Change-Id: I5387c704df5d7649485c9c90a55f98f652da50fc Signed-off-by: Charlie Lenahan Reviewed-on: https://gerrit.iotivity.org/gerrit/1117 Tested-by: jenkins-iotivity Reviewed-by: Caiwen Zhang Reviewed-by: Erich Keane --- build_common/darwin/SConscript | 40 +++++++++++++++++++++++++++------------- tools/darwin/build-ios.sh | 11 +++++------ 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/build_common/darwin/SConscript b/build_common/darwin/SConscript index 4d99761..4cbb981 100644 --- a/build_common/darwin/SConscript +++ b/build_common/darwin/SConscript @@ -5,6 +5,7 @@ import os import platform import commands +from distutils.version import StrictVersion Import('env') @@ -13,28 +14,41 @@ target_os = env.get('TARGET_OS') tc_path=commands.getoutput('xcode-select -p') +tc_sdks=commands.getoutput('xcodebuild -showsdks') + +#Find the SDK's that are installed +sdks=[] +for line in tc_sdks.split('\n'): + if (line == ''): + bIn=False + if (line[:10] == 'OS X SDKs:'): + bIn=(target_os == 'darwin') + elif (line[:9] == 'iOS SDKs:'): + bIn=(target_os == 'ios') + elif bIn: + sdks.append(line[:14].strip()) + +#find the latest +maxsdk='0.0' +if len(sdks) > 0: + for sdk in sdks: + p = sdk.rsplit(' ',1)[1] + if (StrictVersion(p)) > StrictVersion(maxsdk): + maxsdk=p # SYS_VERSION build option help_vars = Variables() -help_vars.Add('SYS_VERSION', 'MAC OS X version / IOS version', os.environ.get('SYS_VERSION')) +help_vars.Add('SYS_VERSION', 'MAC OS X SDK version / IOS SDK version', os.environ.get('SYS_VERSION')) help_vars.Update(env) Help(help_vars.GenerateHelpText(env)) sys_version = env.get('SYS_VERSION') +#if they didn't explictly set it use the auto-detected one if sys_version is None: - print ''' -*********************************** Error ************************************* -* MAC OSX/IOS version isn't set, please set it in command line as : * -* # scons TARGET_ARCH= TARGET_OS= SYS_VERSION= ... * -* To get the version, please see: * -* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ * -* /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/ * -* is 'armv7','armv7s','arm64','i386', 'x86_64' -* is 'darwin','ios' -******************************************************************************* -''' - Exit(1) + sys_version=maxsdk + +env['SYS_VERSION']=sys_version # Set release/debug flags if env.get('RELEASE'): diff --git a/tools/darwin/build-ios.sh b/tools/darwin/build-ios.sh index 1a4ee9e..2b6abb8 100755 --- a/tools/darwin/build-ios.sh +++ b/tools/darwin/build-ios.sh @@ -1,10 +1,9 @@ #!/bin/bash # change this to what version of Xcode you have installed -SDKVER=8.3 -scons TARGET_OS=ios TARGET_ARCH=armv7 SYS_VERSION=$SDKVER RELEASE=false -scons TARGET_OS=ios TARGET_ARCH=armv7s SYS_VERSION=$SDKVER RELEASE=false -scons TARGET_OS=ios TARGET_ARCH=arm64 SYS_VERSION=$SDKVER RELEASE=false -scons TARGET_OS=ios TARGET_ARCH=i386 SYS_VERSION=$SDKVER RELEASE=false -scons TARGET_OS=ios TARGET_ARCH=x86_64 SYS_VERSION=$SDKVER RELEASE=false +scons TARGET_OS=ios TARGET_ARCH=armv7 RELEASE=false +scons TARGET_OS=ios TARGET_ARCH=armv7s RELEASE=false +scons TARGET_OS=ios TARGET_ARCH=arm64 RELEASE=false +scons TARGET_OS=ios TARGET_ARCH=i386 RELEASE=false +scons TARGET_OS=ios TARGET_ARCH=x86_64 RELEASE=false -- 2.7.4