blob: dd64e0f434de0c6e9b8475cc174f95db43e0aa4e [file] [log] [blame]
José Fonseca94090432008-02-27 17:36:28 +09001#######################################################################
2# Common SCons code
3
4import os
5import os.path
6import sys
7import platform as _platform
8
9
10#######################################################################
11# Defaults
12
13_platform_map = {
14 'linux2': 'linux',
15 'win32': 'winddk',
16}
17
18default_platform = sys.platform
19default_platform = _platform_map.get(default_platform, default_platform)
20
21_machine_map = {
22 'x86': 'x86',
23 'i386': 'x86',
24 'i486': 'x86',
25 'i586': 'x86',
26 'i686': 'x86',
27 'x86_64': 'x86_64',
28}
29if 'PROCESSOR_ARCHITECTURE' in os.environ:
30 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
31else:
32 default_machine = _platform.machine()
33default_machine = _machine_map.get(default_machine, 'generic')
34
35if default_platform in ('linux', 'freebsd', 'darwin'):
36 default_dri = 'yes'
José Fonsecab215d7d2008-05-28 01:24:06 +090037elif default_platform in ('winddk', 'windows', 'wince'):
José Fonseca94090432008-02-27 17:36:28 +090038 default_dri = 'no'
39else:
40 default_dri = 'no'
41
42
43#######################################################################
44# Common options
45
José Fonseca13174c12008-03-03 18:52:37 +010046def AddOptions(opts):
José Fonsecac9acd432008-05-01 00:58:04 +090047 try:
48 from SCons.Options.BoolOption import BoolOption
49 except ImportError:
50 from SCons.Variables.BoolVariable import BoolVariable as BoolOption
51 try:
52 from SCons.Options.EnumOption import EnumOption
53 except ImportError:
54 from SCons.Variables.EnumVariable import EnumVariable as EnumOption
José Fonseca059a6522008-05-24 19:25:02 +090055 opts.Add(BoolOption('debug', 'debug build', 'no'))
56 opts.Add(BoolOption('profile', 'profile build', 'no'))
José Fonseca5aa10822008-03-04 14:29:27 +010057 #opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
José Fonseca94090432008-02-27 17:36:28 +090058 opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
59 allowed_values=('generic', 'x86', 'x86_64')))
60 opts.Add(EnumOption('platform', 'target platform', default_platform,
José Fonsecab215d7d2008-05-28 01:24:06 +090061 allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince')))
José Fonseca94090432008-02-27 17:36:28 +090062 opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
63 opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
José Fonseca94090432008-02-27 17:36:28 +090064