OSDN Git Service

Merge branch 'master' into gallium-0.2
[android-x86/external-mesa.git] / common.py
1 #######################################################################
2 # Common SCons code
3
4 import os
5 import os.path
6 import sys
7 import platform as _platform
8
9
10 #######################################################################
11 # Defaults
12
13 _platform_map = {
14         'linux2': 'linux',
15         'win32': 'winddk',
16 }
17
18 default_platform = sys.platform
19 default_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 }
29 if 'PROCESSOR_ARCHITECTURE' in os.environ:
30         default_machine = os.environ['PROCESSOR_ARCHITECTURE']
31 else:
32         default_machine = _platform.machine()
33 default_machine = _machine_map.get(default_machine, 'generic')
34
35 if default_platform in ('linux', 'freebsd', 'darwin'):
36         default_dri = 'yes'
37 elif default_platform in ('winddk', 'windows', 'wince'):
38         default_dri = 'no'
39 else:
40         default_dri = 'no'
41
42
43 #######################################################################
44 # Common options
45
46 def AddOptions(opts):
47         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
55         opts.Add(BoolOption('debug', 'debug build', 'no'))
56         opts.Add(BoolOption('profile', 'profile build', 'no'))
57         #opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
58         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,
61                                                                                          allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince')))
62         opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
63         opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
64