José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 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', |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 27 | 'ppc' : 'ppc', |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 28 | 'x86_64': 'x86_64', |
| 29 | } |
| 30 | if 'PROCESSOR_ARCHITECTURE' in os.environ: |
| 31 | default_machine = os.environ['PROCESSOR_ARCHITECTURE'] |
| 32 | else: |
| 33 | default_machine = _platform.machine() |
| 34 | default_machine = _machine_map.get(default_machine, 'generic') |
| 35 | |
| 36 | if default_platform in ('linux', 'freebsd', 'darwin'): |
| 37 | default_dri = 'yes' |
José Fonseca | b215d7d | 2008-05-28 01:24:06 +0900 | [diff] [blame] | 38 | elif default_platform in ('winddk', 'windows', 'wince'): |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 39 | default_dri = 'no' |
| 40 | else: |
| 41 | default_dri = 'no' |
| 42 | |
| 43 | |
| 44 | ####################################################################### |
| 45 | # Common options |
| 46 | |
José Fonseca | 13174c1 | 2008-03-03 18:52:37 +0100 | [diff] [blame] | 47 | def AddOptions(opts): |
José Fonseca | c9acd43 | 2008-05-01 00:58:04 +0900 | [diff] [blame] | 48 | try: |
| 49 | from SCons.Options.BoolOption import BoolOption |
| 50 | except ImportError: |
| 51 | from SCons.Variables.BoolVariable import BoolVariable as BoolOption |
| 52 | try: |
| 53 | from SCons.Options.EnumOption import EnumOption |
| 54 | except ImportError: |
| 55 | from SCons.Variables.EnumVariable import EnumVariable as EnumOption |
José Fonseca | 059a652 | 2008-05-24 19:25:02 +0900 | [diff] [blame] | 56 | opts.Add(BoolOption('debug', 'debug build', 'no')) |
| 57 | opts.Add(BoolOption('profile', 'profile build', 'no')) |
José Fonseca | 5aa1082 | 2008-03-04 14:29:27 +0100 | [diff] [blame] | 58 | #opts.Add(BoolOption('quiet', 'quiet command lines', 'no')) |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 59 | opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine, |
Michel Dänzer | 6b69e3c | 2008-10-23 10:28:48 +0200 | [diff] [blame] | 60 | allowed_values=('generic', 'ppc', 'x86', 'x86_64'))) |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 61 | opts.Add(EnumOption('platform', 'target platform', default_platform, |
José Fonseca | b215d7d | 2008-05-28 01:24:06 +0900 | [diff] [blame] | 62 | allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince'))) |
José Fonseca | 6cf59e1 | 2008-11-18 19:13:32 +0900 | [diff] [blame] | 63 | opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', |
José Fonseca | fa6ee2c | 2008-12-12 09:44:47 +0900 | [diff] [blame] | 64 | allowed_values=('default', 'crossmingw', 'winddk'))) |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 65 | opts.Add(BoolOption('llvm', 'use LLVM', 'no')) |
| 66 | opts.Add(BoolOption('dri', 'build DRI drivers', default_dri)) |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 67 | |