1 # -*- mode: python; python-indent-offset: 4; indent-tabs-mode: nil -*-
3 # This script set darwin specific flags (GNU GCC)
9 from distutils.version import StrictVersion
13 target_arch = env.get('TARGET_ARCH')
14 target_os = env.get('TARGET_OS')
16 tc_path=commands.getoutput('xcode-select -p')
18 tc_sdks=commands.getoutput('xcodebuild -showsdks')
20 #Find the SDK's that are installed
22 for line in tc_sdks.split('\n'):
25 if (line[:10] == 'OS X SDKs:'):
26 bIn=(target_os == 'darwin')
27 elif (line[:9] == 'iOS SDKs:'):
28 bIn=(target_os == 'ios')
30 sdks.append(line[:14].strip())
36 p = sdk.rsplit(' ',1)[1]
37 if (StrictVersion(p)) > StrictVersion(maxsdk):
40 # SYS_VERSION build option
41 help_vars = Variables()
42 help_vars.Add('SYS_VERSION', 'MAC OS X SDK version / IOS SDK version', os.environ.get('SYS_VERSION'))
44 Help(help_vars.GenerateHelpText(env))
46 sys_version = env.get('SYS_VERSION')
48 #if they didn't explictly set it use the auto-detected one
49 if sys_version is None:
52 env['SYS_VERSION']=sys_version
54 # Set release/debug flags
55 if env.get('RELEASE'):
56 env.AppendUnique(CCFLAGS = ['-Os'])
57 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
59 env.AppendUnique(CCFLAGS = ['-g'])
60 env.AppendUnique(LINKFLAGS = ['-g'])
62 if env.get('LOGGING'):
63 env.AppendUnique(CPPDEFINES = ['TB_LOG'])
65 if target_os == 'darwin':
66 sys_root = tc_path + '/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
68 if target_arch in ['i386', 'x86_64']:
69 sys_root = tc_path + '/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + sys_version + '.sdk/'
71 sys_root = tc_path + '/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + sys_version + '.sdk/'
74 env.AppendUnique(CCFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
75 env.AppendUnique(LINKFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
77 if target_os == 'darwin':
78 flag = '-mmacosx-version-min=' + sys_version
79 env.AppendUnique(CCFLAGS = [flag])
80 env.AppendUnique(LINKFLAGS = [flag])