Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 import copy | 5 import copy |
| 6 | 6 |
| 7 from recipe_engine import recipe_api | 7 from recipe_engine import recipe_api |
| 8 | 8 |
| 9 | 9 |
| 10 class iOSApi(recipe_api.RecipeApi): | 10 class iOSApi(recipe_api.RecipeApi): |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 111 |
| 112 for key in ( | 112 for key in ( |
| 113 'xcode version', | 113 'xcode version', |
| 114 'GYP_DEFINES', | 114 'GYP_DEFINES', |
| 115 'compiler', | 115 'compiler', |
| 116 'configuration', | 116 'configuration', |
| 117 'sdk', | 117 'sdk', |
| 118 ): | 118 ): |
| 119 self.__config[key] = parent_config[key] | 119 self.__config[key] = parent_config[key] |
| 120 | 120 |
| 121 # We set some default GYP_DEFINES so developers don't have to set them | 121 if self._using_gyp(): |
| 122 # manually on every bot. Add them in here. | 122 # We set some default GYP_DEFINES so developers don't have to set them |
| 123 self.__config['GYP_DEFINES']['component'] = 'static_library' | 123 # manually on every bot. Add them in here. |
| 124 self.__config['GYP_DEFINES']['OS'] = 'ios' | 124 self.__config['GYP_DEFINES']['component'] = 'static_library' |
| 125 self.__config['GYP_DEFINES']['OS'] = 'ios' | |
|
Dirk Pranke
2015/11/10 02:03:31
note that I'm not generally a fan of this. I can u
smut
2015/11/10 22:01:18
These are immutable for iOS. I guess I can just pu
Dirk Pranke
2015/11/10 22:34:15
As long as we're doing this approach for just the
| |
| 125 | 126 |
| 126 # TODO(crbug.com/552146): Once 'all' works, the default should be ['all']. | 127 # TODO(crbug.com/552146): Once 'all' works, the default should be ['all']. |
| 127 self.__config.setdefault('additional_compile_targets', ['All']) | 128 self.__config.setdefault('additional_compile_targets', ['All']) |
| 128 self.__config.setdefault('use_mb', False) | |
| 129 | 129 |
| 130 # In order to simplify the code that uses the values of self.__config, here | 130 # In order to simplify the code that uses the values of self.__config, here |
| 131 # we default to empty values of their respective types, so in other places | 131 # we default to empty values of their respective types, so in other places |
| 132 # we can iterate over them without having to check if they are in the dict | 132 # we can iterate over them without having to check if they are in the dict |
| 133 # at all. | 133 # at all. |
| 134 self.__config['triggered bots'] = self.__config.get('triggered bots', {}) | 134 self.__config['triggered bots'] = self.__config.get('triggered bots', {}) |
| 135 self.__config['tests'] = self.__config.get('tests', []) | 135 self.__config['tests'] = self.__config.get('tests', []) |
| 136 self.__config['env'] = self.__config.get('env', {}) | 136 self.__config['env'] = self.__config.get('env', {}) |
| 137 | 137 |
| 138 # Elements of the "tests" list are dicts. There are two types of elements, | 138 # Elements of the "tests" list are dicts. There are two types of elements, |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 'scripts', | 201 'scripts', |
| 202 'slave', | 202 'slave', |
| 203 'ios', | 203 'ios', |
| 204 'find_xcode.py', | 204 'find_xcode.py', |
| 205 ), | 205 ), |
| 206 '--json-file', self.m.json.output(), | 206 '--json-file', self.m.json.output(), |
| 207 '--version', self.__config['xcode version'], | 207 '--version', self.__config['xcode version'], |
| 208 ], step_test_data=lambda: self.m.json.test_api.output({})) | 208 ], step_test_data=lambda: self.m.json.test_api.output({})) |
| 209 | 209 |
| 210 cfg = self.m.chromium.make_config() | 210 cfg = self.m.chromium.make_config() |
| 211 cfg.gyp_env.GYP_CROSSCOMPILE = 1 | 211 |
| 212 cfg.gyp_env.GYP_DEFINES = copy.deepcopy(self.__config['GYP_DEFINES']) | 212 if self._using_gyp(): |
| 213 cfg.gyp_env.GYP_CROSSCOMPILE = 1 | |
|
Dirk Pranke
2015/11/10 02:03:31
You don't actually need to set GYP_CROSSCOMPILE=1;
| |
| 214 cfg.gyp_env.GYP_DEFINES = copy.deepcopy(self.__config['GYP_DEFINES']) | |
| 213 self.m.chromium.c = cfg | 215 self.m.chromium.c = cfg |
| 214 | 216 |
| 215 def build(self, suffix=None): | 217 def build(self, suffix=None): |
| 216 """Builds from this bot's build config.""" | 218 """Builds from this bot's build config.""" |
| 217 assert self.__config is not None | 219 assert self.__config is not None |
| 218 | 220 |
| 219 suffix = ' (%s)' % suffix if suffix else '' | 221 suffix = ' (%s)' % suffix if suffix else '' |
| 220 | 222 |
| 221 # MB and GN only work if we're doing ninja builds, so we will | 223 if self._using_mb(): |
| 222 # ignore the use_mb setting if compiler isn't set to ninja. | |
| 223 use_mb = self.__config['use_mb'] and self.compiler == 'ninja' | |
| 224 if use_mb: | |
| 225 self.m.chromium.c.project_generator.tool = 'mb' | 224 self.m.chromium.c.project_generator.tool = 'mb' |
| 226 | 225 |
| 227 # Add the default GYP_DEFINES. | |
| 228 gyp_defines = [ | |
| 229 '%s=%s' % (k, v) for k, v in self.__config['GYP_DEFINES'].iteritems() | |
| 230 ] | |
| 231 | |
| 232 env = { | 226 env = { |
| 233 'GYP_DEFINES': ' '.join(gyp_defines), | |
| 234 'LANDMINES_VERBOSE': '1', | 227 'LANDMINES_VERBOSE': '1', |
| 235 } | 228 } |
| 236 | 229 |
| 230 if self._using_gyp(): | |
| 231 gyp_defines = [ | |
| 232 '%s=%s' % (k, v) for k, v in self.__config['GYP_DEFINES'].iteritems() | |
| 233 ] | |
| 234 env['GYP_DEFINES'] = ' '.join(gyp_defines) | |
| 235 | |
| 236 if self._using_mb(): | |
| 237 env['MB_TYPE'] = self.__config['mb_type'] | |
| 238 env['GN_ARGS'] = self.__config['gn_args'] | |
|
smut
2015/11/10 22:01:18
Do you need GN_ARGS in the environment when mb_typ
Dirk Pranke
2015/11/10 22:34:15
As noted in the src-side CL, no, we don't technica
| |
| 239 | |
| 237 # Add extra env variables. | 240 # Add extra env variables. |
| 238 env.update(self.__config['env']) | 241 env.update(self.__config['env']) |
| 239 | 242 |
| 240 sub_path = '' | 243 sub_path = '' |
| 241 | 244 |
| 242 if self.compiler == 'xcodebuild': | 245 if self.compiler == 'xcodebuild': |
| 243 env['GYP_GENERATORS'] = 'xcode' | 246 env['GYP_GENERATORS'] = 'xcode' |
| 244 env['GYP_GENERATOR_FLAGS'] = 'xcode_project_version=3.2' | 247 env['GYP_GENERATOR_FLAGS'] = 'xcode_project_version=3.2' |
| 245 cwd = self.m.path['checkout'].join('xcodebuild') | 248 cwd = self.m.path['checkout'].join('xcodebuild') |
| 246 cmd = [ | 249 cmd = [ |
| 247 'xcodebuild', | 250 'xcodebuild', |
| 248 '-configuration', self.configuration, | 251 '-configuration', self.configuration, |
| 249 '-project', self.m.path['checkout'].join( | 252 '-project', self.m.path['checkout'].join( |
| 250 'build', | 253 'build', |
| 251 'all.xcodeproj', | 254 'all.xcodeproj', |
| 252 ), | 255 ), |
| 253 '-sdk', self.__config['sdk'], | 256 '-sdk', self.__config['sdk'], |
| 254 ] | 257 ] |
| 255 elif self.compiler == 'ninja': | 258 elif self.compiler == 'ninja': |
| 256 env['GYP_CROSSCOMPILE'] = '1' | 259 env['GYP_CROSSCOMPILE'] = '1' |
| 257 env['GYP_GENERATORS'] = 'ninja' | 260 env['GYP_GENERATORS'] = 'ninja' |
| 258 sub_path = '%s-%s' % (self.configuration, { | 261 sub_path = '%s-%s' % (self.configuration, { |
| 259 'simulator': 'iphonesimulator', | 262 'simulator': 'iphonesimulator', |
| 260 'device': 'iphoneos', | 263 'device': 'iphoneos', |
| 261 }[self.platform]) | 264 }[self.platform]) |
| 262 | 265 |
| 263 cwd = self.m.path['checkout'].join('out', sub_path) | 266 cwd = self.m.path['checkout'].join('out', sub_path) |
| 264 cmd = ['ninja', '-C', cwd] | 267 cmd = ['ninja', '-C', cwd] |
| 265 | 268 |
| 266 if use_mb: | 269 if self._using_mb(): |
| 267 # if we're using MB to generate build files, make sure we don't | 270 # if we're using MB to generate build files, make sure we don't |
| 268 # invoke GYP directly. We still want the GYP_DEFINES set in the | 271 # invoke GYP directly. We still want the GYP_DEFINES set in the |
| 269 # environment, though, so that other hooks can key off of them. | 272 # environment, though, so that other hooks can key off of them. |
| 270 env['GYP_CHROMIUM_NO_ACTION'] = '1' | 273 env['GYP_CHROMIUM_NO_ACTION'] = '1' |
| 271 | 274 |
| 272 step_result = self.m.gclient.runhooks(name='runhooks' + suffix, env=env) | 275 step_result = self.m.gclient.runhooks(name='runhooks' + suffix, env=env) |
| 273 step_result.presentation.step_text = ( | 276 if self._using_gyp(): |
| 274 '<br />GYP_DEFINES:<br />%s' % '<br />'.join(gyp_defines) | 277 step_result.presentation.step_text = ( |
| 275 ) | 278 '<br />GYP_DEFINES:<br />%s' % '<br />'.join(gyp_defines) |
| 279 ) | |
| 280 else: | |
| 281 step_result.presentation.step_text = ( | |
| 282 '<br />gn args:<br />%s' % self.__config['gn_args'] | |
| 283 ) | |
| 276 | 284 |
| 277 if use_mb: | 285 if self._using_mb(): |
| 278 self.m.chromium.run_mb(self.m.properties['mastername'], | 286 self.m.chromium.run_mb(self.m.properties['mastername'], |
| 279 self.m.properties['buildername'], | 287 self.m.properties['buildername'], |
| 280 name='generate_build_files' + suffix, | 288 name='generate_build_files' + suffix, |
| 281 build_dir='//out/' + sub_path) | 289 build_dir='//out/' + sub_path) |
| 282 | 290 |
| 283 if (self.compiler == 'ninja' and | 291 if (self.compiler == 'ninja' and |
| 284 self.m.tryserver.is_tryserver and | 292 self.m.tryserver.is_tryserver and |
| 285 'without patch' not in suffix): | 293 'without patch' not in suffix): |
| 286 affected_files = self.m.tryserver.get_files_affected_by_patch() | 294 affected_files = self.m.tryserver.get_files_affected_by_patch() |
| 287 # The same test may be configured to run on multiple simulators. | 295 # The same test may be configured to run on multiple simulators. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 304 if test['app'] not in test_targets: | 312 if test['app'] not in test_targets: |
| 305 test['skip'] = True | 313 test['skip'] = True |
| 306 | 314 |
| 307 if requires_compile: # pragma: no cover | 315 if requires_compile: # pragma: no cover |
| 308 cmd.extend(compile_targets) | 316 cmd.extend(compile_targets) |
| 309 else: | 317 else: |
| 310 return | 318 return |
| 311 | 319 |
| 312 self.m.step('compile' + suffix, cmd, cwd=cwd) | 320 self.m.step('compile' + suffix, cmd, cwd=cwd) |
| 313 | 321 |
| 322 def _using_mb(self): | |
| 323 # MB and GN only work if we're doing ninja builds, so we will | |
| 324 # ignore the use_mb setting if compiler isn't set to ninja. | |
| 325 return 'mb_type' in self.__config and self.compiler == 'ninja' | |
|
smut
2015/11/10 22:01:18
How about moving these to line 60 and making them
Dirk Pranke
2015/11/10 22:34:15
Sure.
smut
2015/11/10 23:25:33
Just so it's summarized in one place. Right now yo
Dirk Pranke
2015/11/10 23:59:37
True, I need to change 'use_mb' to 'mb_type' in th
| |
| 326 | |
| 327 def _using_gyp(self): | |
| 328 return not self._using_mb() or self.__config['mb_type'] == 'gyp' | |
| 329 | |
| 314 def test(self, *args): | 330 def test(self, *args): |
| 315 """Runs tests as instructed by this bot's build config. | 331 """Runs tests as instructed by this bot's build config. |
| 316 | 332 |
| 317 Args: | 333 Args: |
| 318 *args: Any additional arguments to pass to the test harness. | 334 *args: Any additional arguments to pass to the test harness. |
| 319 """ | 335 """ |
| 320 assert self.__config is not None | 336 assert self.__config is not None |
| 321 test_failures = [] | 337 test_failures = [] |
| 322 infrastructure_failures = [] | 338 infrastructure_failures = [] |
| 323 | 339 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 self.configuration, | 470 self.configuration, |
| 455 'iossim', | 471 'iossim', |
| 456 ), | 472 ), |
| 457 'ninja': self.m.path.join( | 473 'ninja': self.m.path.join( |
| 458 'src', | 474 'src', |
| 459 build_dir, | 475 build_dir, |
| 460 '%s-%s' % (self.configuration, platform), | 476 '%s-%s' % (self.configuration, platform), |
| 461 'iossim', | 477 'iossim', |
| 462 ), | 478 ), |
| 463 }[self.compiler] | 479 }[self.compiler] |
| OLD | NEW |