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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 def compiler(self): | 44 def compiler(self): |
| 45 assert self.__config is not None | 45 assert self.__config is not None |
| 46 return self.__config['compiler'] | 46 return self.__config['compiler'] |
| 47 | 47 |
| 48 @property | 48 @property |
| 49 def configuration(self): | 49 def configuration(self): |
| 50 assert self.__config is not None | 50 assert self.__config is not None |
| 51 return self.__config['configuration'] | 51 return self.__config['configuration'] |
| 52 | 52 |
| 53 @property | 53 @property |
| 54 def using_gyp(self): | |
| 55 assert self.__config is not None | |
| 56 return not self.using_mb or self.__config.get('mb_type') == 'gyp' | |
| 57 | |
| 58 @property | |
| 59 def using_mb(self): | |
| 60 assert self.__config is not None | |
| 61 # MB and GN only work if we're doing ninja builds, so we will | |
| 62 # ignore the mb_type setting if compiler isn't set to ninja. | |
| 63 return self.__config['mb_type'] is not None and self.compiler == 'ninja' | |
| 64 | |
| 65 @property | |
| 54 def platform(self): | 66 def platform(self): |
| 55 assert self.__config is not None | 67 assert self.__config is not None |
| 56 if self.__config['sdk'].startswith('iphoneos'): | 68 if self.__config['sdk'].startswith('iphoneos'): |
| 57 return 'device' | 69 return 'device' |
| 58 elif self.__config['sdk'].startswith('iphonesimulator'): | 70 elif self.__config['sdk'].startswith('iphonesimulator'): |
| 59 return 'simulator' | 71 return 'simulator' |
| 60 | 72 |
| 61 def read_build_config( | 73 def read_build_config( |
| 62 self, | 74 self, |
| 63 master_name=None, | 75 master_name=None, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 123 |
| 112 for key in ( | 124 for key in ( |
| 113 'xcode version', | 125 'xcode version', |
| 114 'GYP_DEFINES', | 126 'GYP_DEFINES', |
| 115 'compiler', | 127 'compiler', |
| 116 'configuration', | 128 'configuration', |
| 117 'sdk', | 129 'sdk', |
| 118 ): | 130 ): |
| 119 self.__config[key] = parent_config[key] | 131 self.__config[key] = parent_config[key] |
| 120 | 132 |
| 121 # We set some default GYP_DEFINES so developers don't have to set them | 133 # In the older dict-based bot configs we didn't set these values |
| 122 # manually on every bot. Add them in here. | 134 # since they were the same on every bot. In the newer configs they |
| 123 self.__config['GYP_DEFINES']['component'] = 'static_library' | 135 # are set anyway since MB needs them as well. |
| 124 self.__config['GYP_DEFINES']['OS'] = 'ios' | 136 if isinstance(self.__config['GYP_DEFINES'], dict): |
| 137 self.__config['GYP_DEFINES']['component'] = 'static_library' | |
| 138 self.__config['GYP_DEFINES']['OS'] = 'ios' | |
| 125 | 139 |
| 126 # TODO(crbug.com/552146): Once 'all' works, the default should be ['all']. | 140 # TODO(crbug.com/552146): Once 'all' works, the default should be ['all']. |
| 127 self.__config.setdefault('additional_compile_targets', ['All']) | 141 self.__config.setdefault('additional_compile_targets', ['All']) |
| 128 self.__config.setdefault('use_mb', False) | |
| 129 | 142 |
| 130 # In order to simplify the code that uses the values of self.__config, here | 143 # 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 | 144 # 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 | 145 # we can iterate over them without having to check if they are in the dict |
| 133 # at all. | 146 # at all. |
| 134 self.__config['triggered bots'] = self.__config.get('triggered bots', {}) | 147 self.__config['triggered bots'] = self.__config.get('triggered bots', {}) |
| 135 self.__config['tests'] = self.__config.get('tests', []) | 148 self.__config['tests'] = self.__config.get('tests', []) |
| 136 self.__config['env'] = self.__config.get('env', {}) | 149 self.__config['env'] = self.__config.get('env', {}) |
| 137 | 150 |
| 151 self.__config.setdefault('mb_type', None) | |
| 152 | |
| 138 # Elements of the "tests" list are dicts. There are two types of elements, | 153 # Elements of the "tests" list are dicts. There are two types of elements, |
| 139 # determined by the presence of one of these mutually exclusive keys: | 154 # determined by the presence of one of these mutually exclusive keys: |
| 140 # "app": This says to run a particular app. | 155 # "app": This says to run a particular app. |
| 141 # "include": This says to include a common set of tests from include_dir. | 156 # "include": This says to include a common set of tests from include_dir. |
| 142 # So now we go through the "tests" list replacing any "include" keys. | 157 # So now we go through the "tests" list replacing any "include" keys. |
| 143 # The value of an "include" key is the name of a set of tests to include, | 158 # The value of an "include" key is the name of a set of tests to include, |
| 144 # which can be found as a .json file in include_dir. Read the contents | 159 # which can be found as a .json file in include_dir. Read the contents |
| 145 # lazily as needed into includes. | 160 # lazily as needed into includes. |
| 146 def read_include(includes): | 161 def read_include(includes): |
| 147 """Reads the contents of the given include. | 162 """Reads the contents of the given include. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 'scripts', | 216 'scripts', |
| 202 'slave', | 217 'slave', |
| 203 'ios', | 218 'ios', |
| 204 'find_xcode.py', | 219 'find_xcode.py', |
| 205 ), | 220 ), |
| 206 '--json-file', self.m.json.output(), | 221 '--json-file', self.m.json.output(), |
| 207 '--version', self.__config['xcode version'], | 222 '--version', self.__config['xcode version'], |
| 208 ], step_test_data=lambda: self.m.json.test_api.output({})) | 223 ], step_test_data=lambda: self.m.json.test_api.output({})) |
| 209 | 224 |
| 210 cfg = self.m.chromium.make_config() | 225 cfg = self.m.chromium.make_config() |
| 211 cfg.gyp_env.GYP_CROSSCOMPILE = 1 | 226 |
| 212 cfg.gyp_env.GYP_DEFINES = copy.deepcopy(self.__config['GYP_DEFINES']) | 227 if self.using_gyp: |
| 228 cfg.gyp_env.GYP_CROSSCOMPILE = 1 | |
| 229 cfg.gyp_env.GYP_DEFINES = copy.deepcopy(self.__config['GYP_DEFINES']) | |
| 213 self.m.chromium.c = cfg | 230 self.m.chromium.c = cfg |
| 214 | 231 |
| 215 def build(self, suffix=None): | 232 def build(self, suffix=None): |
| 216 """Builds from this bot's build config.""" | 233 """Builds from this bot's build config.""" |
| 217 assert self.__config is not None | 234 assert self.__config is not None |
| 218 | 235 |
| 219 suffix = ' (%s)' % suffix if suffix else '' | 236 suffix = ' (%s)' % suffix if suffix else '' |
| 220 | 237 |
| 221 # MB and GN only work if we're doing ninja builds, so we will | 238 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' | 239 self.m.chromium.c.project_generator.tool = 'mb' |
| 226 | 240 |
| 227 # Add the default GYP_DEFINES. | 241 # Add the default GYP_DEFINES. |
| 228 gyp_defines = [ | 242 if isinstance(self.__config['GYP_DEFINES'], dict): |
| 229 '%s=%s' % (k, v) for k, v in self.__config['GYP_DEFINES'].iteritems() | 243 gyp_defines = [ |
| 230 ] | 244 '%s=%s' % (k, v) for k, v in self.__config['GYP_DEFINES'].iteritems() |
| 245 ] | |
| 246 else: | |
| 247 gyp_defines = self.__config['GYP_DEFINES'] | |
| 231 | 248 |
| 232 env = { | 249 env = { |
| 233 'GYP_DEFINES': ' '.join(gyp_defines), | 250 'GYP_DEFINES': ' '.join(gyp_defines), |
| 234 'LANDMINES_VERBOSE': '1', | 251 'LANDMINES_VERBOSE': '1', |
| 235 } | 252 } |
| 236 | 253 |
| 237 # Add extra env variables. | 254 # Add extra env variables. |
| 238 env.update(self.__config['env']) | 255 env.update(self.__config['env']) |
| 239 | 256 |
| 240 sub_path = '' | 257 sub_path = '' |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 256 env['GYP_CROSSCOMPILE'] = '1' | 273 env['GYP_CROSSCOMPILE'] = '1' |
| 257 env['GYP_GENERATORS'] = 'ninja' | 274 env['GYP_GENERATORS'] = 'ninja' |
| 258 sub_path = '%s-%s' % (self.configuration, { | 275 sub_path = '%s-%s' % (self.configuration, { |
| 259 'simulator': 'iphonesimulator', | 276 'simulator': 'iphonesimulator', |
| 260 'device': 'iphoneos', | 277 'device': 'iphoneos', |
| 261 }[self.platform]) | 278 }[self.platform]) |
| 262 | 279 |
| 263 cwd = self.m.path['checkout'].join('out', sub_path) | 280 cwd = self.m.path['checkout'].join('out', sub_path) |
| 264 cmd = ['ninja', '-C', cwd] | 281 cmd = ['ninja', '-C', cwd] |
| 265 | 282 |
| 266 if use_mb: | 283 if self.using_mb: |
| 267 # if we're using MB to generate build files, make sure we don't | 284 # 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 | 285 # invoke GYP directly. We still want the GYP_DEFINES set in the |
| 269 # environment, though, so that other hooks can key off of them. | 286 # environment, though, so that other hooks can key off of them. |
| 270 env['GYP_CHROMIUM_NO_ACTION'] = '1' | 287 env['GYP_CHROMIUM_NO_ACTION'] = '1' |
| 271 | 288 |
| 272 step_result = self.m.gclient.runhooks(name='runhooks' + suffix, env=env) | 289 step_result = self.m.gclient.runhooks(name='runhooks' + suffix, env=env) |
| 273 step_result.presentation.step_text = ( | 290 step_result.presentation.step_text = ( |
| 274 '<br />GYP_DEFINES:<br />%s' % '<br />'.join(gyp_defines) | 291 '<br />GYP_DEFINES:<br />%s' % '<br />'.join(gyp_defines) |
| 275 ) | 292 ) |
| 293 if self.using_mb: | |
| 294 step_result.presentation.step_text += '<br />GYP_CHROMIUM_NO_ACTION=1' | |
| 276 | 295 |
| 277 if use_mb: | 296 if self.using_mb: |
| 278 self.m.chromium.run_mb(self.m.properties['mastername'], | 297 self.m.chromium.run_mb(self.m.properties['mastername'], |
| 279 self.m.properties['buildername'], | 298 self.m.properties['buildername'], |
| 280 name='generate_build_files' + suffix, | 299 name='generate_build_files' + suffix, |
| 281 build_dir='//out/' + sub_path) | 300 build_dir='//out/' + sub_path) |
|
Dirk Pranke
2015/11/18 04:28:34
We could present the GYP_DEFINES and/or gn_args an
smut
2015/11/19 20:58:50
Sure.
| |
| 282 | 301 |
| 283 if (self.compiler == 'ninja' and | 302 if (self.compiler == 'ninja' and |
| 284 self.m.tryserver.is_tryserver and | 303 self.m.tryserver.is_tryserver and |
| 285 'without patch' not in suffix): | 304 'without patch' not in suffix): |
| 286 affected_files = self.m.tryserver.get_files_affected_by_patch() | 305 affected_files = self.m.tryserver.get_files_affected_by_patch() |
| 287 # The same test may be configured to run on multiple simulators. | 306 # The same test may be configured to run on multiple simulators. |
| 288 # Only specify each test once for the analyzer. | 307 # Only specify each test once for the analyzer. |
| 289 tests = list(set(test['app'] for test in self.__config['tests'])) | 308 tests = list(set(test['app'] for test in self.__config['tests'])) |
| 290 | 309 |
| 291 requires_compile, test_targets, compile_targets = ( | 310 requires_compile, test_targets, compile_targets = ( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 454 self.configuration, | 473 self.configuration, |
| 455 'iossim', | 474 'iossim', |
| 456 ), | 475 ), |
| 457 'ninja': self.m.path.join( | 476 'ninja': self.m.path.join( |
| 458 'src', | 477 'src', |
| 459 build_dir, | 478 build_dir, |
| 460 '%s-%s' % (self.configuration, platform), | 479 '%s-%s' % (self.configuration, platform), |
| 461 'iossim', | 480 'iossim', |
| 462 ), | 481 ), |
| 463 }[self.compiler] | 482 }[self.compiler] |
| OLD | NEW |