riscv64: Add support for RISC-V
[platform/upstream/iotivity.git] / build_common / darwin / SConscript
1 # -*- mode: python; python-indent-offset: 4; indent-tabs-mode: nil -*-
2 ##
3 # This script set darwin specific flags (GNU GCC)
4 #
5 ##
6 import os
7 import platform
8 import commands
9 from distutils.version import StrictVersion
10
11 Import('env')
12
13 target_arch = env.get('TARGET_ARCH')
14 target_os = env.get('TARGET_OS')
15
16 tc_path=commands.getoutput('xcode-select -p')
17
18 tc_sdks=commands.getoutput('xcodebuild -showsdks')
19
20 #Find the SDK's that are installed
21 sdks=[]
22 for line in tc_sdks.split('\n'):
23     if (line == ''):
24         bIn=False
25     if (line[:10] == 'OS X SDKs:'):
26         bIn=(target_os == 'darwin')
27     elif (line[:9] == 'iOS SDKs:'):
28         bIn=(target_os == 'ios')
29     elif bIn:
30         sdks.append(line[:14].strip())
31
32 #find the latest
33 maxsdk='0.0'
34 if len(sdks) > 0:
35     for sdk in sdks:
36         p = sdk.rsplit(' ',1)[1]
37         if (StrictVersion(p)) > StrictVersion(maxsdk):
38             maxsdk=p
39
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'))
43 help_vars.Update(env)
44 Help(help_vars.GenerateHelpText(env))
45
46 sys_version = env.get('SYS_VERSION')
47
48 #if they didn't explictly set it use the auto-detected one
49 if sys_version is None:
50     sys_version=maxsdk
51
52 env['SYS_VERSION']=sys_version
53
54 # Set release/debug flags
55 if env.get('RELEASE'):
56         env.AppendUnique(CCFLAGS = ['-Os'])
57         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
58 else:
59         env.AppendUnique(CCFLAGS = ['-g'])
60         env.AppendUnique(LINKFLAGS = ['-g'])
61
62 if env.get('LOGGING'):
63     env.AppendUnique(CPPDEFINES = ['TB_LOG'])
64
65 if target_os == 'darwin':
66         sys_root = tc_path + '/Platforms/MacOSX.platform/Developer/SDKs/MacOSX' + sys_version + '.sdk/'
67 else:
68         if target_arch in ['i386', 'x86_64']:
69                 sys_root = tc_path + '/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator' + sys_version + '.sdk/'
70         else:
71                 sys_root = tc_path + '/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS' + sys_version + '.sdk/'
72
73 # Set arch flags
74 env.AppendUnique(CCFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
75 env.AppendUnique(LINKFLAGS = ['-arch', target_arch, '-isysroot', sys_root])
76
77 if target_os == 'darwin':
78         flag = '-mmacosx-version-min=' + sys_version
79         env.AppendUnique(CCFLAGS = [flag])
80         env.AppendUnique(LINKFLAGS = [flag])