Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: scripts/slave/recipe_modules/chromium/config.py

Issue 24737002: Add Paths as first-class types in configs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 7
8 from slave.recipe_config_types import Path
agable 2013/09/26 21:46:02 No empty line above this.
iannucci 2013/09/27 02:08:20 Done.
9
8 # Because of the way that we use decorators, pylint can't figure out the proper 10 # 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. 11 # type signature of functions annotated with the @config_ctx decorator.
10 # pylint: disable=E1123 12 # pylint: disable=E1123
11 13
12 HOST_PLATFORMS = ('linux', 'win', 'mac') 14 HOST_PLATFORMS = ('linux', 'win', 'mac')
13 TARGET_PLATFORMS = HOST_PLATFORMS + ('ios', 'android', 'chromeos') 15 TARGET_PLATFORMS = HOST_PLATFORMS + ('ios', 'android', 'chromeos')
14 HOST_TARGET_BITS = (32, 64) 16 HOST_TARGET_BITS = (32, 64)
15 HOST_ARCHS = ('intel',) 17 HOST_ARCHS = ('intel',)
16 TARGET_ARCHS = HOST_ARCHS + ('arm', 'mips') 18 TARGET_ARCHS = HOST_ARCHS + ('arm', 'mips')
17 BUILD_CONFIGS = ('Release', 'Debug') 19 BUILD_CONFIGS = ('Release', 'Debug')
18 20
19 def check(val, potentials): 21 def check(val, potentials):
20 assert val in potentials 22 assert val in potentials
21 return val 23 return val
22 24
23 # Schema for config items in this module. 25 # Schema for config items in this module.
24 def BaseConfig(HOST_PLATFORM, HOST_ARCH, HOST_BITS, 26 def BaseConfig(HOST_PLATFORM, HOST_ARCH, HOST_BITS,
25 TARGET_PLATFORM, TARGET_ARCH, TARGET_BITS, 27 TARGET_PLATFORM, TARGET_ARCH, TARGET_BITS,
26 BUILD_CONFIG, **_kwargs): 28 BUILD_CONFIG, **_kwargs):
27 equal_fn = lambda tup: ('%s=%s' % tup) 29 equal_fn = lambda tup: ('%s=%s' % tup)
28 return ConfigGroup( 30 return ConfigGroup(
29 compile_py = ConfigGroup( 31 compile_py = ConfigGroup(
30 default_targets = Set(basestring), 32 default_targets = Set(basestring),
31 build_tool = Single(basestring), 33 build_tool = Single(basestring),
32 compiler = Single(basestring, required=False), 34 compiler = Single(basestring, required=False),
33 ), 35 ),
34 gyp_env = ConfigGroup( 36 gyp_env = ConfigGroup(
35 GYP_CROSSCOMPILE = Single(int, jsonish_fn=str, required=False), 37 GYP_CROSSCOMPILE = Single(int, jsonish_fn=str, required=False),
36 GYP_DEFINES = Dict(equal_fn, ' '.join, (basestring,int,list)), 38 GYP_DEFINES = Dict(equal_fn, ' '.join, (basestring,int,Path)),
agable 2013/09/26 21:46:02 Realizing that these are a bit obtuse and it might
iannucci 2013/09/27 02:08:20 Yes, I agree :). Another CL?
agable 2013/09/27 17:48:16 SG.
37 GYP_GENERATORS = Set(basestring, ','.join), 39 GYP_GENERATORS = Set(basestring, ','.join),
38 GYP_GENERATOR_FLAGS = Dict(equal_fn, ' '.join, (basestring,int)), 40 GYP_GENERATOR_FLAGS = Dict(equal_fn, ' '.join, (basestring,int)),
39 GYP_MSVS_VERSION = Single(basestring, required=False), 41 GYP_MSVS_VERSION = Single(basestring, required=False),
40 ), 42 ),
41 build_dir = Single(basestring), 43 build_dir = Single(Path),
42 44
43 # Some platforms do not have a 1:1 correlation of BUILD_CONFIG to what is 45 # Some platforms do not have a 1:1 correlation of BUILD_CONFIG to what is
44 # passed as --target on the command line. 46 # passed as --target on the command line.
45 build_config_fs = Single(basestring), 47 build_config_fs = Single(basestring),
46 48
47 BUILD_CONFIG = Static(check(BUILD_CONFIG, BUILD_CONFIGS)), 49 BUILD_CONFIG = Static(check(BUILD_CONFIG, BUILD_CONFIGS)),
48 50
49 HOST_PLATFORM = Static(check(HOST_PLATFORM, HOST_PLATFORMS)), 51 HOST_PLATFORM = Static(check(HOST_PLATFORM, HOST_PLATFORMS)),
50 HOST_ARCH = Static(check(HOST_ARCH, HOST_ARCHS)), 52 HOST_ARCH = Static(check(HOST_ARCH, HOST_ARCHS)),
51 HOST_BITS = Static(check(HOST_BITS, HOST_TARGET_BITS)), 53 HOST_BITS = Static(check(HOST_BITS, HOST_TARGET_BITS)),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 raise BadConf('Can not compile "%s" on "%s"' % 111 raise BadConf('Can not compile "%s" on "%s"' %
110 (c.TARGET_PLATFORM, c.HOST_PLATFORM)) 112 (c.TARGET_PLATFORM, c.HOST_PLATFORM))
111 113
112 if c.HOST_BITS < c.TARGET_BITS: 114 if c.HOST_BITS < c.TARGET_BITS:
113 raise BadConf('host bits < targ bits') 115 raise BadConf('host bits < targ bits')
114 116
115 c.build_config_fs = c.BUILD_CONFIG 117 c.build_config_fs = c.BUILD_CONFIG
116 if c.HOST_PLATFORM == 'win': 118 if c.HOST_PLATFORM == 'win':
117 if c.TARGET_BITS == 64: 119 if c.TARGET_BITS == 64:
118 # Windows requires 64-bit builds to be in <dir>_x64. 120 # Windows requires 64-bit builds to be in <dir>_x64.
119 c.build_config_fs += '_x64' 121 c.build_config_fs = c.BUILD_CONFIG + '_x64'
120 c.gyp_env.GYP_MSVS_VERSION = '2012' 122 c.gyp_env.GYP_MSVS_VERSION = '2012'
121 c.gyp_env.GYP_DEFINES['target_arch'] = 'x64' 123 c.gyp_env.GYP_DEFINES['target_arch'] = 'x64'
122 else: 124 else:
123 c.gyp_env.GYP_MSVS_VERSION = '2010' 125 c.gyp_env.GYP_MSVS_VERSION = '2010'
124 126
125 if c.BUILD_CONFIG == 'Release': 127 if c.BUILD_CONFIG == 'Release':
126 static_library(c, final=False) 128 static_library(c, final=False)
127 elif c.BUILD_CONFIG == 'Debug': 129 elif c.BUILD_CONFIG == 'Debug':
128 shared_library(c, final=False) 130 shared_library(c, final=False)
129 else: # pragma: no cover 131 else: # pragma: no cover
130 raise BadConf('Unknown build config "%s"' % c.BUILD_CONFIG) 132 raise BadConf('Unknown build config "%s"' % c.BUILD_CONFIG)
131 133
132 @config_ctx() 134 @config_ctx()
133 def disable_aura(c): 135 def disable_aura(c):
134 if c.TARGET_PLATFORM == 'win': 136 if c.TARGET_PLATFORM == 'win':
135 c.gyp_env.GYP_DEFINES['use_aura'] = 0 137 c.gyp_env.GYP_DEFINES['use_aura'] = 0
136 138
137 @config_ctx(group='builder') 139 @config_ctx(group='builder')
138 def ninja(c): 140 def ninja(c):
139 c.gyp_env.GYP_GENERATORS.add('ninja') 141 c.gyp_env.GYP_GENERATORS.add('ninja')
140 c.compile_py.build_tool = 'ninja' 142 c.compile_py.build_tool = 'ninja'
141 c.build_dir = 'out' 143 c.build_dir = Path('checkout', 'out')
agable 2013/09/26 21:46:02 This just looks so much like it's going to constru
iannucci 2013/09/27 02:08:20 All caps? I could also make the pieces argument ex
agable 2013/09/27 17:48:16 See comments in recipe_config_types.
142 144
143 @config_ctx(group='builder') 145 @config_ctx(group='builder')
144 def msvs(c): 146 def msvs(c):
145 if c.HOST_PLATFORM != 'win': 147 if c.HOST_PLATFORM != 'win':
146 raise BadConf('can not use msvs on "%s"' % c.HOST_PLATFORM) 148 raise BadConf('can not use msvs on "%s"' % c.HOST_PLATFORM)
147 c.gyp_env.GYP_GENERATORS.add('msvs') 149 c.gyp_env.GYP_GENERATORS.add('msvs')
148 c.gyp_env.GYP_GENERATOR_FLAGS['msvs_error_on_missing_sources'] = 1 150 c.gyp_env.GYP_GENERATOR_FLAGS['msvs_error_on_missing_sources'] = 1
149 c.compile_py.build_tool = 'msvs' 151 c.compile_py.build_tool = 'msvs'
150 c.build_dir = 'out' 152 c.build_dir = Path('checkout', 'build')
151 153
152 @config_ctx(group='builder') 154 @config_ctx(group='builder')
153 def xcodebuild(c): 155 def xcodebuild(c):
154 if c.HOST_PLATFORM != 'mac': 156 if c.HOST_PLATFORM != 'mac':
155 raise BadConf('can not use xcodebuild on "%s"' % c.HOST_PLATFORM) 157 raise BadConf('can not use xcodebuild on "%s"' % c.HOST_PLATFORM)
156 c.gyp_env.GYP_GENERATORS.add('xcodebuild') 158 c.gyp_env.GYP_GENERATORS.add('xcodebuild')
157 159
158 @config_ctx(group='compiler') 160 @config_ctx(group='compiler')
159 def clang(c): 161 def clang(c):
160 c.compile_py.compiler = 'clang' 162 c.compile_py.compiler = 'clang'
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 @config_ctx(includes=['ninja', 'default_compiler', 'goma']) 213 @config_ctx(includes=['ninja', 'default_compiler', 'goma'])
212 def chromium(c): 214 def chromium(c):
213 c.compile_py.default_targets = ['All', 'chromium_builder_tests'] 215 c.compile_py.default_targets = ['All', 'chromium_builder_tests']
214 216
215 @config_ctx(includes=['chromium']) 217 @config_ctx(includes=['chromium'])
216 def blink(c): 218 def blink(c):
217 c.compile_py.default_targets = ['all_webkit'] 219 c.compile_py.default_targets = ['all_webkit']
218 if c.TARGET_PLATFORM == 'win': 220 if c.TARGET_PLATFORM == 'win':
219 c.gyp_env.GYP_DEFINES['use_ash'] = 0 221 c.gyp_env.GYP_DEFINES['use_ash'] = 0
220 c.gyp_env.GYP_DEFINES['use_aura'] = 0 222 c.gyp_env.GYP_DEFINES['use_aura'] = 0
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698