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', |
José Fonseca | 00b463f | 2009-12-18 22:40:33 +0000 | [diff] [blame] | 15 | 'win32': 'windows', |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 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 | |
Vinson Lee | d27d659 | 2009-09-09 08:21:05 -0600 | [diff] [blame] | 36 | if default_platform in ('linux', 'freebsd'): |
José Fonseca | 9409043 | 2008-02-27 17:36:28 +0900 | [diff] [blame] | 37 | default_dri = 'yes' |
Vinson Lee | d27d659 | 2009-09-09 08:21:05 -0600 | [diff] [blame] | 38 | elif default_platform in ('winddk', 'windows', 'wince', 'darwin'): |
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: |
José Fonseca | c9acd43 | 2008-05-01 00:58:04 +0900 | [diff] [blame] | 49 | from SCons.Variables.BoolVariable import BoolVariable as BoolOption |
José Fonseca | c9acd43 | 2008-05-01 00:58:04 +0900 | [diff] [blame] | 50 | except ImportError: |
José Fonseca | 0d0417c | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 51 | from SCons.Options.BoolOption import BoolOption |
| 52 | try: |
José Fonseca | c9acd43 | 2008-05-01 00:58:04 +0900 | [diff] [blame] | 53 | from SCons.Variables.EnumVariable import EnumVariable as EnumOption |
José Fonseca | 0d0417c | 2009-05-01 16:12:17 +0100 | [diff] [blame] | 54 | except ImportError: |
| 55 | from SCons.Options.EnumOption import 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 | 0f50c4f | 2009-06-02 18:23:12 -0700 | [diff] [blame] | 58 | opts.Add(BoolOption('quiet', 'quiet command lines', 'yes')) |
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, |
Vinson Lee | 2c307c7 | 2009-09-08 12:31:42 +0100 | [diff] [blame] | 62 | allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin'))) |
José Fonseca | 6cf59e1 | 2008-11-18 19:13:32 +0900 | [diff] [blame] | 63 | opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default', |
José Fonseca | 26e27ba | 2009-03-25 19:24:16 +0000 | [diff] [blame] | 64 | allowed_values=('default', 'crossmingw', 'winsdk', '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 | |