Auto-detect OS X/iOS SDK versions.
authorCharlie Lenahan <charlie.lenahan@intel.com>
Wed, 27 May 2015 00:21:42 +0000 (20:21 -0400)
committerErich Keane <erich.keane@intel.com>
Thu, 28 May 2015 16:35:00 +0000 (16:35 +0000)
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 <charlie.lenahan@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1117
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Caiwen Zhang <caiwen.zhang@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
build_common/darwin/SConscript
tools/darwin/build-ios.sh

index 4d99761..4cbb981 100644 (file)
@@ -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=<arch> TARGET_OS=<os> SYS_VERSION=<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/ *
-*   <arch> is 'armv7','armv7s','arm64','i386', 'x86_64'
-*   <os> is 'darwin','ios'
-*******************************************************************************
-'''
-       Exit(1)
+    sys_version=maxsdk
+
+env['SYS_VERSION']=sys_version
 
 # Set release/debug flags
 if env.get('RELEASE'):
index 1a4ee9e..2b6abb8 100755 (executable)
@@ -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