1 #######################################################################
9 import platform
as _platform
11 import SCons
.Script
.SConscript
14 #######################################################################
17 host_platform
= _platform
.system().lower()
18 if host_platform
.startswith('cygwin'):
19 host_platform
= 'cygwin'
20 # MSYS2 default platform selection.
21 if host_platform
.startswith('mingw'):
22 host_platform
= 'windows'
24 # Search sys.argv[] for a "platform=foo" argument since we don't have
25 # an 'env' variable at this point.
26 if 'platform' in SCons
.Script
.ARGUMENTS
:
27 target_platform
= SCons
.Script
.ARGUMENTS
['platform']
29 target_platform
= host_platform
49 # find host_machine value
50 if 'PROCESSOR_ARCHITECTURE' in os
.environ
:
51 host_machine
= os
.environ
['PROCESSOR_ARCHITECTURE']
53 host_machine
= _platform
.machine()
54 host_machine
= _machine_map
.get(host_machine
, 'generic')
55 # MSYS2 default machine selection.
56 if _platform
.system().lower().startswith('mingw') and 'MSYSTEM' in os
.environ
:
57 if os
.environ
['MSYSTEM'] == 'MINGW32':
59 if os
.environ
['MSYSTEM'] == 'MINGW64':
60 host_machine
= 'x86_64'
62 default_machine
= host_machine
63 default_toolchain
= 'default'
64 # MSYS2 default toolchain selection.
65 if _platform
.system().lower().startswith('mingw'):
66 default_toolchain
= 'mingw'
68 if target_platform
== 'windows' and host_platform
!= 'windows':
69 default_machine
= 'x86'
70 default_toolchain
= 'crossmingw'
73 # find default_llvm value
74 if 'LLVM' in os
.environ
or 'LLVM_CONFIG' in os
.environ
:
79 if target_platform
!= 'windows' and \
80 subprocess
.call(['llvm-config', '--version'],
81 stdout
=subprocess
.PIPE
) == 0:
87 #######################################################################
92 from SCons
.Variables
.BoolVariable
import BoolVariable
as BoolOption
94 from SCons
.Options
.BoolOption
import BoolOption
96 from SCons
.Variables
.EnumVariable
import EnumVariable
as EnumOption
98 from SCons
.Options
.EnumOption
import EnumOption
99 opts
.Add(EnumOption('build', 'build type', 'debug',
100 allowed_values
=('debug', 'checked', 'profile',
102 opts
.Add(BoolOption('verbose', 'verbose output', 'no'))
103 opts
.Add(EnumOption('machine', 'use machine-specific assembly code',
105 allowed_values
=('generic', 'ppc', 'x86', 'x86_64')))
106 opts
.Add(EnumOption('platform', 'target platform', host_platform
,
107 allowed_values
=('cygwin', 'darwin', 'freebsd', 'haiku',
108 'linux', 'sunos', 'windows')))
109 opts
.Add(BoolOption('embedded', 'embedded build', 'no'))
110 opts
.Add(BoolOption('analyze',
111 'enable static code analysis where available', 'no'))
112 opts
.Add(BoolOption('asan', 'enable Address Sanitizer', 'no'))
113 opts
.Add('toolchain', 'compiler toolchain', default_toolchain
)
114 opts
.Add(BoolOption('llvm', 'use LLVM', default_llvm
))
115 opts
.Add(BoolOption('force_scons', 'Force enable scons on deprecated platforms', 'false'))
116 opts
.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)',
118 opts
.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
119 opts
.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
120 opts
.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))
121 opts
.Add(BoolOption('swr', 'Build OpenSWR', 'no'))
122 if host_platform
== 'windows':
123 opts
.Add('MSVC_VERSION', 'Microsoft Visual C/C++ version')
124 opts
.Add('MSVC_USE_SCRIPT', 'Microsoft Visual C/C++ vcvarsall script', True)