2 # This script set darwin specific flags (GNU GCC)
8 from distutils.version import StrictVersion
12 target_arch = env.get('TARGET_ARCH')
13 target_os = env.get('TARGET_OS')
15 tc_path=commands.getoutput('xcode-select -p')
17 tc_sdks=commands.getoutput('xcodebuild -showsdks')
19 #Find the SDK's that are installed
21 for line in tc_sdks.split('\n'):
24 if (line[:10] == 'OS X SDKs:'):
25 bIn=(target_os == 'darwin')
26 elif (line[:9] == 'iOS SDKs:'):
27 bIn=(target_os == 'ios')
29 sdks.append(line[:14].strip())
35 p = sdk.rsplit(' ',1)[1]
36 if (StrictVersion(p)) > StrictVersion(maxsdk):
39 # SYS_VERSION build option
40 help_vars = Variables()
41 help_vars.Add('SYS_VERSION', 'MAC OS X SDK version / IOS SDK version', os.environ.get('SYS_VERSION'))
43 Help(help_vars.GenerateHelpText(env))
45 sys_version = env.get('SYS_VERSION')
47 #if they didn't explictly set it use the auto-detected one
48 if sys_version is None:
51 env['SYS_VERSION']=sys_version
53 # Set release/debug flags
54 if env.get('RELEASE'):
55 env.AppendUnique(CCFLAGS = ['-Os'])
56 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
58 env.AppendUnique(CCFLAGS = ['-g'])
59 env.AppendUnique(LINKFLAGS = ['-g'])
61 if env.get('LOGGING'):
62 env.AppendUnique(CPPDEFINES = ['-DTB_LOG'])
64 if target_os == 'darwin':
65 sys_root = tc_path + '/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
67 if target_arch in ['i386', 'x86_64']:
68 sys_root = tc_path + '/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + sys_version + '.sdk/'
70 sys_root = tc_path + '/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + sys_version + '.sdk/'
73 env.AppendUnique(CCFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
74 env.AppendUnique(LINKFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
76 if target_os == 'darwin':
77 flag = '-mmacosx-version-min=' + sys_version
78 env.AppendUnique(CCFLAGS = [flag])
79 env.AppendUnique(LINKFLAGS = [flag])