| 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 from slave.recipe_config import config_item_context, ConfigGroup | 5 from slave.recipe_config import config_item_context, ConfigGroup |
| 6 from slave.recipe_config import Dict, Single, Static, Set, BadConf | 6 from slave.recipe_config import Dict, Single, Static, Set, BadConf |
| 7 from slave.recipe_config_types import Path |
| 7 | 8 |
| 8 # Because of the way that we use decorators, pylint can't figure out the proper | 9 # Because of the way that we use decorators, pylint can't figure out the proper |
| 9 # type signature of functions annotated with the @config_ctx decorator. | 10 # type signature of functions annotated with the @config_ctx decorator. |
| 10 # pylint: disable=E1123 | 11 # pylint: disable=E1123 |
| 11 | 12 |
| 12 HOST_PLATFORMS = ('linux', 'win', 'mac') | 13 HOST_PLATFORMS = ('linux', 'win', 'mac') |
| 13 TARGET_PLATFORMS = HOST_PLATFORMS + ('ios', 'android', 'chromeos') | 14 TARGET_PLATFORMS = HOST_PLATFORMS + ('ios', 'android', 'chromeos') |
| 14 HOST_TARGET_BITS = (32, 64) | 15 HOST_TARGET_BITS = (32, 64) |
| 15 HOST_ARCHS = ('intel',) | 16 HOST_ARCHS = ('intel',) |
| 16 TARGET_ARCHS = HOST_ARCHS + ('arm', 'mips') | 17 TARGET_ARCHS = HOST_ARCHS + ('arm', 'mips') |
| 17 BUILD_CONFIGS = ('Release', 'Debug') | 18 BUILD_CONFIGS = ('Release', 'Debug') |
| 18 | 19 |
| 19 def check(val, potentials): | 20 def check(val, potentials): |
| 20 assert val in potentials | 21 assert val in potentials |
| 21 return val | 22 return val |
| 22 | 23 |
| 23 # Schema for config items in this module. | 24 # Schema for config items in this module. |
| 24 def BaseConfig(HOST_PLATFORM, HOST_ARCH, HOST_BITS, | 25 def BaseConfig(HOST_PLATFORM, HOST_ARCH, HOST_BITS, |
| 25 TARGET_PLATFORM, TARGET_ARCH, TARGET_BITS, | 26 TARGET_PLATFORM, TARGET_ARCH, TARGET_BITS, |
| 26 BUILD_CONFIG, **_kwargs): | 27 BUILD_CONFIG, **_kwargs): |
| 27 equal_fn = lambda tup: ('%s=%s' % tup) | 28 equal_fn = lambda tup: ('%s=%s' % tup) |
| 28 return ConfigGroup( | 29 return ConfigGroup( |
| 29 compile_py = ConfigGroup( | 30 compile_py = ConfigGroup( |
| 30 default_targets = Set(basestring), | 31 default_targets = Set(basestring), |
| 31 build_tool = Single(basestring), | 32 build_tool = Single(basestring), |
| 32 compiler = Single(basestring, required=False), | 33 compiler = Single(basestring, required=False), |
| 33 ), | 34 ), |
| 34 gyp_env = ConfigGroup( | 35 gyp_env = ConfigGroup( |
| 35 GYP_CROSSCOMPILE = Single(int, jsonish_fn=str, required=False), | 36 GYP_CROSSCOMPILE = Single(int, jsonish_fn=str, required=False), |
| 36 GYP_DEFINES = Dict(equal_fn, ' '.join, (basestring,int,list)), | 37 GYP_DEFINES = Dict(equal_fn, ' '.join, (basestring,int,Path)), |
| 37 GYP_GENERATORS = Set(basestring, ','.join), | 38 GYP_GENERATORS = Set(basestring, ','.join), |
| 38 GYP_GENERATOR_FLAGS = Dict(equal_fn, ' '.join, (basestring,int)), | 39 GYP_GENERATOR_FLAGS = Dict(equal_fn, ' '.join, (basestring,int)), |
| 39 GYP_MSVS_VERSION = Single(basestring, required=False), | 40 GYP_MSVS_VERSION = Single(basestring, required=False), |
| 40 ), | 41 ), |
| 41 build_dir = Single(basestring), | 42 build_dir = Single(Path), |
| 42 | 43 |
| 43 # Some platforms do not have a 1:1 correlation of BUILD_CONFIG to what is | 44 # Some platforms do not have a 1:1 correlation of BUILD_CONFIG to what is |
| 44 # passed as --target on the command line. | 45 # passed as --target on the command line. |
| 45 build_config_fs = Single(basestring), | 46 build_config_fs = Single(basestring), |
| 46 | 47 |
| 47 BUILD_CONFIG = Static(check(BUILD_CONFIG, BUILD_CONFIGS)), | 48 BUILD_CONFIG = Static(check(BUILD_CONFIG, BUILD_CONFIGS)), |
| 48 | 49 |
| 49 HOST_PLATFORM = Static(check(HOST_PLATFORM, HOST_PLATFORMS)), | 50 HOST_PLATFORM = Static(check(HOST_PLATFORM, HOST_PLATFORMS)), |
| 50 HOST_ARCH = Static(check(HOST_ARCH, HOST_ARCHS)), | 51 HOST_ARCH = Static(check(HOST_ARCH, HOST_ARCHS)), |
| 51 HOST_BITS = Static(check(HOST_BITS, HOST_TARGET_BITS)), | 52 HOST_BITS = Static(check(HOST_BITS, HOST_TARGET_BITS)), |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 raise BadConf('Can not compile "%s" on "%s"' % | 110 raise BadConf('Can not compile "%s" on "%s"' % |
| 110 (c.TARGET_PLATFORM, c.HOST_PLATFORM)) | 111 (c.TARGET_PLATFORM, c.HOST_PLATFORM)) |
| 111 | 112 |
| 112 if c.HOST_BITS < c.TARGET_BITS: | 113 if c.HOST_BITS < c.TARGET_BITS: |
| 113 raise BadConf('host bits < targ bits') | 114 raise BadConf('host bits < targ bits') |
| 114 | 115 |
| 115 c.build_config_fs = c.BUILD_CONFIG | 116 c.build_config_fs = c.BUILD_CONFIG |
| 116 if c.HOST_PLATFORM == 'win': | 117 if c.HOST_PLATFORM == 'win': |
| 117 if c.TARGET_BITS == 64: | 118 if c.TARGET_BITS == 64: |
| 118 # Windows requires 64-bit builds to be in <dir>_x64. | 119 # Windows requires 64-bit builds to be in <dir>_x64. |
| 119 c.build_config_fs += '_x64' | 120 c.build_config_fs = c.BUILD_CONFIG + '_x64' |
| 120 c.gyp_env.GYP_MSVS_VERSION = '2012' | 121 c.gyp_env.GYP_MSVS_VERSION = '2012' |
| 121 c.gyp_env.GYP_DEFINES['target_arch'] = 'x64' | 122 c.gyp_env.GYP_DEFINES['target_arch'] = 'x64' |
| 122 else: | 123 else: |
| 123 c.gyp_env.GYP_MSVS_VERSION = '2010' | 124 c.gyp_env.GYP_MSVS_VERSION = '2010' |
| 124 | 125 |
| 125 if c.BUILD_CONFIG == 'Release': | 126 if c.BUILD_CONFIG == 'Release': |
| 126 static_library(c, final=False) | 127 static_library(c, final=False) |
| 127 elif c.BUILD_CONFIG == 'Debug': | 128 elif c.BUILD_CONFIG == 'Debug': |
| 128 shared_library(c, final=False) | 129 shared_library(c, final=False) |
| 129 else: # pragma: no cover | 130 else: # pragma: no cover |
| 130 raise BadConf('Unknown build config "%s"' % c.BUILD_CONFIG) | 131 raise BadConf('Unknown build config "%s"' % c.BUILD_CONFIG) |
| 131 | 132 |
| 132 @config_ctx() | 133 @config_ctx() |
| 133 def disable_aura(c): | 134 def disable_aura(c): |
| 134 if c.TARGET_PLATFORM == 'win': | 135 if c.TARGET_PLATFORM == 'win': |
| 135 c.gyp_env.GYP_DEFINES['use_aura'] = 0 | 136 c.gyp_env.GYP_DEFINES['use_aura'] = 0 |
| 136 | 137 |
| 137 @config_ctx(group='builder') | 138 @config_ctx(group='builder') |
| 138 def ninja(c): | 139 def ninja(c): |
| 139 c.gyp_env.GYP_GENERATORS.add('ninja') | 140 c.gyp_env.GYP_GENERATORS.add('ninja') |
| 140 c.compile_py.build_tool = 'ninja' | 141 c.compile_py.build_tool = 'ninja' |
| 141 c.build_dir = 'out' | 142 c.build_dir = Path('checkout', ('out',)) |
| 142 | 143 |
| 143 @config_ctx(group='builder') | 144 @config_ctx(group='builder') |
| 144 def msvs(c): | 145 def msvs(c): |
| 145 if c.HOST_PLATFORM != 'win': | 146 if c.HOST_PLATFORM != 'win': |
| 146 raise BadConf('can not use msvs on "%s"' % c.HOST_PLATFORM) | 147 raise BadConf('can not use msvs on "%s"' % c.HOST_PLATFORM) |
| 147 c.gyp_env.GYP_GENERATORS.add('msvs') | 148 c.gyp_env.GYP_GENERATORS.add('msvs') |
| 148 c.gyp_env.GYP_GENERATOR_FLAGS['msvs_error_on_missing_sources'] = 1 | 149 c.gyp_env.GYP_GENERATOR_FLAGS['msvs_error_on_missing_sources'] = 1 |
| 149 c.compile_py.build_tool = 'msvs' | 150 c.compile_py.build_tool = 'msvs' |
| 150 c.build_dir = 'out' | 151 c.build_dir = Path('checkout', ('build',)) |
| 151 | 152 |
| 152 @config_ctx(group='builder') | 153 @config_ctx(group='builder') |
| 153 def xcodebuild(c): | 154 def xcodebuild(c): |
| 154 if c.HOST_PLATFORM != 'mac': | 155 if c.HOST_PLATFORM != 'mac': |
| 155 raise BadConf('can not use xcodebuild on "%s"' % c.HOST_PLATFORM) | 156 raise BadConf('can not use xcodebuild on "%s"' % c.HOST_PLATFORM) |
| 156 c.gyp_env.GYP_GENERATORS.add('xcodebuild') | 157 c.gyp_env.GYP_GENERATORS.add('xcodebuild') |
| 157 | 158 |
| 158 @config_ctx(group='compiler') | 159 @config_ctx(group='compiler') |
| 159 def clang(c): | 160 def clang(c): |
| 160 c.compile_py.compiler = 'clang' | 161 c.compile_py.compiler = 'clang' |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 @config_ctx(includes=['ninja', 'default_compiler', 'goma']) | 212 @config_ctx(includes=['ninja', 'default_compiler', 'goma']) |
| 212 def chromium(c): | 213 def chromium(c): |
| 213 c.compile_py.default_targets = ['All', 'chromium_builder_tests'] | 214 c.compile_py.default_targets = ['All', 'chromium_builder_tests'] |
| 214 | 215 |
| 215 @config_ctx(includes=['chromium']) | 216 @config_ctx(includes=['chromium']) |
| 216 def blink(c): | 217 def blink(c): |
| 217 c.compile_py.default_targets = ['all_webkit'] | 218 c.compile_py.default_targets = ['all_webkit'] |
| 218 if c.TARGET_PLATFORM == 'win': | 219 if c.TARGET_PLATFORM == 'win': |
| 219 c.gyp_env.GYP_DEFINES['use_ash'] = 0 | 220 c.gyp_env.GYP_DEFINES['use_ash'] = 0 |
| 220 c.gyp_env.GYP_DEFINES['use_aura'] = 0 | 221 c.gyp_env.GYP_DEFINES['use_aura'] = 0 |
| OLD | NEW |