OSDN Git Service

Merge branch '7.8'
[android-x86/external-mesa.git] / common.py
1 #######################################################################
2 # Common SCons code
3
4 import os
5 import os.path
6 import subprocess
7 import sys
8 import platform as _platform
9
10
11 #######################################################################
12 # Defaults
13
14 _platform_map = {
15         'linux2': 'linux',
16         'win32': 'windows',
17 }
18
19 default_platform = sys.platform
20 default_platform = _platform_map.get(default_platform, default_platform)
21
22 _machine_map = {
23         'x86': 'x86',
24         'i386': 'x86',
25         'i486': 'x86',
26         'i586': 'x86',
27         'i686': 'x86',
28         'ppc' : 'ppc',
29         'x86_64': 'x86_64',
30 }
31 if 'PROCESSOR_ARCHITECTURE' in os.environ:
32         default_machine = os.environ['PROCESSOR_ARCHITECTURE']
33 else:
34         default_machine = _platform.machine()
35 default_machine = _machine_map.get(default_machine, 'generic')
36
37 if 'LLVM' in os.environ:
38     default_llvm = 'yes'
39 else:
40     default_llvm = 'no'
41     try:
42         if subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
43             default_llvm = 'yes'
44     except:
45         pass
46
47 if default_platform in ('linux', 'freebsd'):
48         default_dri = 'yes'
49 elif default_platform in ('winddk', 'windows', 'wince', 'darwin'):
50         default_dri = 'no'
51 else:
52         default_dri = 'no'
53
54
55 #######################################################################
56 # Common options
57
58 def AddOptions(opts):
59         try:
60                 from SCons.Variables.BoolVariable import BoolVariable as BoolOption
61         except ImportError:
62                 from SCons.Options.BoolOption import BoolOption
63         try:
64                 from SCons.Variables.EnumVariable import EnumVariable as EnumOption
65         except ImportError:
66                 from SCons.Options.EnumOption import EnumOption
67         opts.Add(BoolOption('debug', 'debug build', 'yes'))
68         opts.Add(BoolOption('profile', 'profile build', 'no'))
69         opts.Add(BoolOption('quiet', 'quiet command lines', 'yes'))
70         opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
71                                                                                          allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
72         opts.Add(EnumOption('platform', 'target platform', default_platform,
73                                                                                          allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
74         opts.Add('toolchain', 'compiler toolchain', 'default')
75         opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
76         opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))