Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 import functools | 6 import functools |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import shlex | 9 import shlex |
| 10 import sys | 10 import sys |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 return memoizer | 26 return memoizer |
| 27 | 27 |
| 28 | 28 |
| 29 @memoize() | 29 @memoize() |
| 30 def IsWindows(): | 30 def IsWindows(): |
| 31 return sys.platform in ['win32', 'cygwin'] | 31 return sys.platform in ['win32', 'cygwin'] |
| 32 | 32 |
| 33 | 33 |
| 34 @memoize() | 34 @memoize() |
| 35 def IsLinux(): | 35 def IsLinux(): |
| 36 return sys.platform.startswith('linux') | 36 return sys.platform.startswith('linux') |
|
iannucci
2014/02/10 22:28:30
For the purposes of this file, I think it would ma
r.c.ladan
2014/02/10 22:31:33
What about platform() which cannot distinguish bet
iannucci
2014/02/10 22:38:39
I know they're different operating systems :)
The
| |
| 37 | 37 |
| 38 | 38 |
| 39 @memoize() | 39 @memoize() |
| 40 def IsMac(): | 40 def IsMac(): |
| 41 return sys.platform == 'darwin' | 41 return sys.platform == 'darwin' |
| 42 | 42 |
| 43 | 43 |
| 44 @memoize() | 44 @memoize() |
| 45 def IsFreeBSD(): | |
| 46 return sys.platform.startswith('freebsd') | |
| 47 | |
| 48 | |
| 49 @memoize() | |
| 45 def gyp_defines(): | 50 def gyp_defines(): |
| 46 """Parses and returns GYP_DEFINES env var as a dictionary.""" | 51 """Parses and returns GYP_DEFINES env var as a dictionary.""" |
| 47 return dict(arg.split('=', 1) | 52 return dict(arg.split('=', 1) |
| 48 for arg in shlex.split(os.environ.get('GYP_DEFINES', ''))) | 53 for arg in shlex.split(os.environ.get('GYP_DEFINES', ''))) |
| 49 | 54 |
| 50 @memoize() | 55 @memoize() |
| 51 def gyp_msvs_version(): | 56 def gyp_msvs_version(): |
| 52 return os.environ.get('GYP_MSVS_VERSION', '') | 57 return os.environ.get('GYP_MSVS_VERSION', '') |
| 53 | 58 |
| 54 @memoize() | 59 @memoize() |
| 55 def distributor(): | 60 def distributor(): |
| 56 """ | 61 """ |
| 57 Returns a string which is the distributed build engine in use (if any). | 62 Returns a string which is the distributed build engine in use (if any). |
| 58 Possible values: 'goma', 'ib', '' | 63 Possible values: 'goma', 'ib', '' |
| 59 """ | 64 """ |
| 60 if 'goma' in gyp_defines(): | 65 if 'goma' in gyp_defines(): |
| 61 return 'goma' | 66 return 'goma' |
| 62 elif IsWindows(): | 67 elif IsWindows(): |
| 63 if 'CHROME_HEADLESS' in os.environ: | 68 if 'CHROME_HEADLESS' in os.environ: |
| 64 return 'ib' # use (win and !goma and headless) as approximation of ib | 69 return 'ib' # use (win and !goma and headless) as approximation of ib |
| 65 | 70 |
| 66 | 71 |
| 67 @memoize() | 72 @memoize() |
| 68 def platform(): | 73 def platform(): |
| 69 """ | 74 """ |
| 70 Returns a string representing the platform this build is targetted for. | 75 Returns a string representing the platform this build is targetted for. |
| 71 Possible values: 'win', 'mac', 'linux', 'ios', 'android' | 76 Possible values: 'win', 'mac', 'linux', 'ios', 'android', 'freebsd' |
| 72 """ | 77 """ |
| 73 if 'OS' in gyp_defines(): | 78 if 'OS' in gyp_defines(): |
| 74 if 'android' in gyp_defines()['OS']: | 79 if 'android' in gyp_defines()['OS']: |
| 75 return 'android' | 80 return 'android' |
| 76 else: | 81 else: |
| 77 return gyp_defines()['OS'] | 82 return gyp_defines()['OS'] |
| 78 elif IsWindows(): | 83 elif IsWindows(): |
| 79 return 'win' | 84 return 'win' |
| 80 elif IsLinux(): | 85 elif IsLinux(): |
| 81 return 'linux' | 86 return 'linux' |
| 87 elif IsFreeBSD(): | |
| 88 return 'freebsd' | |
| 82 else: | 89 else: |
| 83 return 'mac' | 90 return 'mac' |
| 84 | 91 |
| 85 | 92 |
| 86 @memoize() | 93 @memoize() |
| 87 def builder(): | 94 def builder(): |
| 88 """ | 95 """ |
| 89 Returns a string representing the build engine (not compiler) to use. | 96 Returns a string representing the build engine (not compiler) to use. |
| 90 Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons' | 97 Possible values: 'make', 'ninja', 'xcode', 'msvs', 'scons' |
| 91 """ | 98 """ |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 103 # Good enough for now? Do any android bots use make? | 110 # Good enough for now? Do any android bots use make? |
| 104 return 'ninja' | 111 return 'ninja' |
| 105 elif platform() == 'ios': | 112 elif platform() == 'ios': |
| 106 return 'xcode' | 113 return 'xcode' |
| 107 elif IsWindows(): | 114 elif IsWindows(): |
| 108 return 'ninja' | 115 return 'ninja' |
| 109 elif IsLinux(): | 116 elif IsLinux(): |
| 110 return 'ninja' | 117 return 'ninja' |
| 111 elif IsMac(): | 118 elif IsMac(): |
| 112 return 'ninja' | 119 return 'ninja' |
| 120 elif IsFreeBSD(): | |
| 121 return 'ninja' | |
| 113 else: | 122 else: |
| 114 assert False, 'Don\'t know what builder we\'re using!' | 123 assert False, 'Don\'t know what builder we\'re using!' |
| OLD | NEW |