OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Generates an Android Studio project from a GN target.""" | 6 """Generates an Android Studio project from a GN target.""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import codecs | 9 import codecs |
10 import logging | 10 import logging |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 | 115 |
116 | 116 |
117 class _ProjectEntry(object): | 117 class _ProjectEntry(object): |
118 """Helper class for various path transformations.""" | 118 """Helper class for various path transformations.""" |
119 def __init__(self, gn_target): | 119 def __init__(self, gn_target): |
120 assert gn_target.startswith('//'), gn_target | 120 assert gn_target.startswith('//'), gn_target |
121 if ':' not in gn_target: | 121 if ':' not in gn_target: |
122 gn_target = '%s:%s' % (gn_target, os.path.basename(gn_target)) | 122 gn_target = '%s:%s' % (gn_target, os.path.basename(gn_target)) |
123 self._gn_target = gn_target | 123 self._gn_target = gn_target |
124 self._build_config = None | 124 self._build_config = None |
125 self._test_entry = None | |
126 self._android_test_entry = None | |
125 | 127 |
126 @classmethod | 128 @classmethod |
127 def FromBuildConfigPath(cls, path): | 129 def FromBuildConfigPath(cls, path): |
128 prefix = 'gen/' | 130 prefix = 'gen/' |
129 suffix = '.build_config' | 131 suffix = '.build_config' |
130 assert path.startswith(prefix) and path.endswith(suffix), path | 132 assert path.startswith(prefix) and path.endswith(suffix), path |
131 subdir = path[len(prefix):-len(suffix)] | 133 subdir = path[len(prefix):-len(suffix)] |
132 return cls('//%s:%s' % (os.path.split(subdir))) | 134 return cls('//%s:%s' % (os.path.split(subdir))) |
133 | 135 |
134 def __hash__(self): | 136 def __hash__(self): |
135 return hash(self._gn_target) | 137 return hash(self._gn_target) |
136 | 138 |
137 def __eq__(self, other): | 139 def __eq__(self, other): |
138 return self._gn_target == other.GnTarget() | 140 return self._gn_target == other.GnTarget() |
139 | 141 |
142 def SetTest(self, test_entry): | |
agrieve
2017/01/12 21:28:35
It'd be more python-y to just make test_entry and
Peter Wen
2017/01/18 20:54:40
Done.
| |
143 self._test_entry = test_entry | |
144 | |
145 def SetAndroidTest(self, test_entry): | |
146 self._android_test_entry = test_entry | |
147 | |
148 def Test(self): | |
149 return self._test_entry | |
150 | |
151 def AndroidTest(self): | |
152 return self._android_test_entry | |
153 | |
154 def Srcjars(self, use_gradle_process_resources): | |
155 srcjars = _RebasePath(self.Gradle().get('bundled_srcjars', [])) | |
agrieve
2017/01/12 21:28:35
I think it'd be nicer to not rebase in these metho
Peter Wen
2017/01/18 20:54:41
Hmm... now that they're in GradleGenerator do you
| |
156 if not use_gradle_process_resources: | |
157 srcjars += _RebasePath(self.BuildConfig()['javac']['srcjars']) | |
158 return srcjars | |
159 | |
160 def JavaFiles(self): | |
161 java_sources_file = self.Gradle().get('java_sources_file') | |
162 java_files = [] | |
163 if java_sources_file: | |
164 java_sources_file = _RebasePath(java_sources_file) | |
165 java_files = build_utils.ReadSourcesList(java_sources_file) | |
166 return java_files | |
167 | |
168 def JavaDirs(self, gradle_output_dir, use_gradle_process_resources): | |
169 entry_output_dir = self.EntryOutputDir(gradle_output_dir) | |
170 java_dirs = _CreateJavaSourceDir( | |
agrieve
2017/01/12 21:28:35
This seems a bit odd as well. The method seems lik
Peter Wen
2017/01/18 20:54:41
Now it's called GenJavaDirs. :)
| |
171 constants.GetOutDirectory(), entry_output_dir, self.JavaFiles()) | |
172 if self.Srcjars(use_gradle_process_resources): | |
173 java_dirs.append(os.path.join(entry_output_dir, _SRCJARS_SUBDIR)) | |
174 return java_dirs | |
175 | |
176 def JniLibs(self, gradle_output_dir): | |
177 native_section = self.BuildConfig().get('native') | |
178 if native_section: | |
179 jni_libs = _CreateJniLibsDir( | |
180 constants.GetOutDirectory(), self.EntryOutputDir(gradle_output_dir), | |
181 native_section.get('libraries')) | |
182 else: | |
183 jni_libs = [] | |
184 return jni_libs | |
185 | |
186 def EntryOutputDir(self, gradle_output_dir): | |
187 return os.path.join(gradle_output_dir, self.GradleSubdir()) | |
188 | |
140 def GnTarget(self): | 189 def GnTarget(self): |
141 return self._gn_target | 190 return self._gn_target |
142 | 191 |
143 def NinjaTarget(self): | 192 def NinjaTarget(self): |
144 return self._gn_target[2:] | 193 return self._gn_target[2:] |
145 | 194 |
146 def GnBuildConfigTarget(self): | 195 def GnBuildConfigTarget(self): |
147 return '%s__build_config' % self._gn_target | 196 return '%s__build_config' % self._gn_target |
148 | 197 |
149 def NinjaBuildConfigTarget(self): | 198 def NinjaBuildConfigTarget(self): |
150 return '%s__build_config' % self.NinjaTarget() | 199 return '%s__build_config' % self.NinjaTarget() |
151 | 200 |
152 def GradleSubdir(self): | 201 def GradleSubdir(self): |
153 """Returns the output subdirectory.""" | 202 """Returns the output subdirectory.""" |
154 return self.NinjaTarget().replace(':', os.path.sep) | 203 return self.NinjaTarget().replace(':', os.path.sep) |
155 | 204 |
156 def ProjectName(self): | 205 def ProjectName(self): |
157 """Returns the Gradle project name.""" | 206 """Returns the Gradle project name.""" |
158 return self.GradleSubdir().replace(os.path.sep, '>') | 207 return self.GradleSubdir().replace(os.path.sep, '>') |
159 | 208 |
160 def BuildConfig(self): | 209 def BuildConfig(self): |
161 """Reads and returns the project's .build_config JSON.""" | 210 """Reads and returns the project's .build_config JSON.""" |
162 if not self._build_config: | 211 if not self._build_config: |
163 path = os.path.join('gen', self.GradleSubdir() + '.build_config') | 212 path = os.path.join('gen', self.GradleSubdir() + '.build_config') |
164 self._build_config = build_utils.ReadJson(_RebasePath(path)) | 213 self._build_config = build_utils.ReadJson(_RebasePath(path)) |
165 return self._build_config | 214 return self._build_config |
166 | 215 |
216 def DepsInfo(self): | |
217 return self.BuildConfig()['deps_info'] | |
218 | |
219 def Gradle(self): | |
220 return self.BuildConfig()['gradle'] | |
221 | |
222 def GeneratedInputs(self, use_gradle_process_resources): | |
223 generated_inputs = [] | |
224 generated_inputs.extend(self.Srcjars(use_gradle_process_resources)) | |
225 generated_inputs.extend( | |
226 p for p in self.JavaFiles() if not p.startswith('..')) | |
227 generated_inputs.extend(self.Gradle()['dependent_prebuilt_jars']) | |
228 return generated_inputs | |
229 | |
230 def Generate(self, gradle_output_dir, use_gradle_process_resources, | |
231 relativize): | |
232 variables = {} | |
233 android_test_manifest = self.Gradle().get( | |
234 'android_manifest', _DEFAULT_ANDROID_MANIFEST_PATH) | |
235 variables['android_manifest'] = relativize(android_test_manifest) | |
236 variables['java_dirs'] = relativize(self.JavaDirs( | |
237 gradle_output_dir, use_gradle_process_resources)) | |
238 variables['jni_libs'] = relativize(self.JniLibs(gradle_output_dir)) | |
239 deps = [_ProjectEntry.FromBuildConfigPath(p) | |
240 for p in self.Gradle()['dependent_android_projects']] | |
241 variables['android_project_deps'] = [d.ProjectName() for d in deps] | |
242 # TODO(agrieve): Add an option to use interface jars and see if that speeds | |
243 # things up at all. | |
244 variables['prebuilts'] = relativize( | |
245 self.Gradle()['dependent_prebuilt_jars']) | |
246 deps = [_ProjectEntry.FromBuildConfigPath(p) | |
247 for p in self.Gradle()['dependent_java_projects']] | |
248 variables['java_project_deps'] = [d.ProjectName() for d in deps] | |
249 return variables | |
250 | |
167 def GetType(self): | 251 def GetType(self): |
168 """Returns the target type from its .build_config.""" | 252 """Returns the target type from its .build_config.""" |
169 return self.BuildConfig()['deps_info']['type'] | 253 return self.DepsInfo()['type'] |
170 | 254 |
171 | 255 |
172 def _ComputeJavaSourceDirs(java_files): | 256 def _ComputeJavaSourceDirs(java_files): |
173 """Returns the list of source directories for the given files.""" | 257 """Returns the list of source directories for the given files.""" |
174 found_roots = set() | 258 found_roots = set() |
175 for path in java_files: | 259 for path in java_files: |
176 path_root = path | 260 path_root = path |
177 # Recognize these tokens as top-level. | 261 # Recognize these tokens as top-level. |
178 while True: | 262 while True: |
179 path_root = os.path.dirname(path_root) | 263 path_root = os.path.dirname(path_root) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 | 355 |
272 | 356 |
273 def _GenerateLocalProperties(sdk_dir): | 357 def _GenerateLocalProperties(sdk_dir): |
274 """Returns the data for project.properties as a string.""" | 358 """Returns the data for project.properties as a string.""" |
275 return '\n'.join([ | 359 return '\n'.join([ |
276 '# Generated by //build/android/gradle/generate_gradle.py', | 360 '# Generated by //build/android/gradle/generate_gradle.py', |
277 'sdk.dir=%s' % sdk_dir, | 361 'sdk.dir=%s' % sdk_dir, |
278 '']) | 362 '']) |
279 | 363 |
280 | 364 |
281 def _GenerateGradleFile(build_config, build_vars, java_dirs, jni_libs, | 365 def _GenerateGradleFile(entry, gradle_output_dir, build_vars, relativize, |
282 relativize, use_gradle_process_resources, | 366 use_gradle_process_resources, jinja_processor): |
283 jinja_processor): | |
284 """Returns the data for a project's build.gradle.""" | 367 """Returns the data for a project's build.gradle.""" |
285 deps_info = build_config['deps_info'] | 368 deps_info = entry.DepsInfo() |
286 gradle = build_config['gradle'] | 369 gradle = entry.Gradle() |
287 | 370 |
288 variables = { | 371 variables = { |
289 'sourceSetName': 'main', | 372 'sourceSetName': 'main', |
290 'depCompileName': 'compile', | 373 'depCompileName': 'compile', |
291 } | 374 } |
292 if deps_info['type'] == 'android_apk': | 375 if deps_info['type'] == 'android_apk': |
293 target_type = 'android_apk' | 376 target_type = 'android_apk' |
294 elif deps_info['type'] == 'java_library': | 377 elif deps_info['type'] == 'java_library': |
295 if deps_info['is_prebuilt'] or deps_info['gradle_treat_as_prebuilt']: | 378 if deps_info['is_prebuilt'] or deps_info['gradle_treat_as_prebuilt']: |
296 return None | 379 return None |
(...skipping 12 matching lines...) Expand all Loading... | |
309 variables['main_class'] = gradle['main_class'] | 392 variables['main_class'] = gradle['main_class'] |
310 else: | 393 else: |
311 return None | 394 return None |
312 | 395 |
313 variables['target_name'] = os.path.splitext(deps_info['name'])[0] | 396 variables['target_name'] = os.path.splitext(deps_info['name'])[0] |
314 variables['template_type'] = target_type | 397 variables['template_type'] = target_type |
315 variables['use_gradle_process_resources'] = use_gradle_process_resources | 398 variables['use_gradle_process_resources'] = use_gradle_process_resources |
316 variables['build_tools_version'] = ( | 399 variables['build_tools_version'] = ( |
317 build_vars['android_sdk_build_tools_version']) | 400 build_vars['android_sdk_build_tools_version']) |
318 variables['compile_sdk_version'] = build_vars['android_sdk_version'] | 401 variables['compile_sdk_version'] = build_vars['android_sdk_version'] |
319 android_manifest = gradle.get('android_manifest', | 402 variables['main'] = entry.Generate( |
320 _DEFAULT_ANDROID_MANIFEST_PATH) | 403 gradle_output_dir, use_gradle_process_resources, relativize) |
321 variables['android_manifest'] = relativize(android_manifest) | 404 if entry.Test(): |
322 variables['java_dirs'] = relativize(java_dirs) | 405 variables['test'] = entry.Test().Generate( |
323 variables['jni_libs'] = relativize(jni_libs) | 406 gradle_output_dir, use_gradle_process_resources, relativize) |
324 # TODO(agrieve): Add an option to use interface jars and see if that speeds | 407 if entry.AndroidTest(): |
325 # things up at all. | 408 variables['android_test'] = entry.AndroidTest().Generate( |
326 variables['prebuilts'] = relativize(gradle['dependent_prebuilt_jars']) | 409 gradle_output_dir, use_gradle_process_resources, relativize) |
327 deps = [_ProjectEntry.FromBuildConfigPath(p) | |
328 for p in gradle['dependent_android_projects']] | |
329 | |
330 variables['android_project_deps'] = [d.ProjectName() for d in deps] | |
331 deps = [_ProjectEntry.FromBuildConfigPath(p) | |
332 for p in gradle['dependent_java_projects']] | |
333 variables['java_project_deps'] = [d.ProjectName() for d in deps] | |
334 | 410 |
335 return jinja_processor.Render( | 411 return jinja_processor.Render( |
336 _TemplatePath(target_type.split('_')[0]), variables) | 412 _TemplatePath(target_type.split('_')[0]), variables) |
337 | 413 |
338 | 414 |
339 def _GenerateRootGradle(jinja_processor): | 415 def _GenerateRootGradle(jinja_processor): |
340 """Returns the data for the root project's build.gradle.""" | 416 """Returns the data for the root project's build.gradle.""" |
341 return jinja_processor.Render(_TemplatePath('root')) | 417 return jinja_processor.Render(_TemplatePath('root')) |
342 | 418 |
343 | 419 |
(...skipping 29 matching lines...) Expand all Loading... | |
373 | 449 |
374 def _FindAllProjectEntries(main_entries): | 450 def _FindAllProjectEntries(main_entries): |
375 """Returns the list of all _ProjectEntry instances given the root project.""" | 451 """Returns the list of all _ProjectEntry instances given the root project.""" |
376 found = set() | 452 found = set() |
377 to_scan = list(main_entries) | 453 to_scan = list(main_entries) |
378 while to_scan: | 454 while to_scan: |
379 cur_entry = to_scan.pop() | 455 cur_entry = to_scan.pop() |
380 if cur_entry in found: | 456 if cur_entry in found: |
381 continue | 457 continue |
382 found.add(cur_entry) | 458 found.add(cur_entry) |
383 build_config = cur_entry.BuildConfig() | 459 sub_config_paths = cur_entry.DepsInfo()['deps_configs'] |
384 sub_config_paths = build_config['deps_info']['deps_configs'] | |
385 to_scan.extend( | 460 to_scan.extend( |
386 _ProjectEntry.FromBuildConfigPath(p) for p in sub_config_paths) | 461 _ProjectEntry.FromBuildConfigPath(p) for p in sub_config_paths) |
387 return list(found) | 462 return list(found) |
388 | 463 |
389 | 464 |
465 def _CombineTestEntries(entries): | |
466 combined_entries = [] | |
467 test_entries = {} | |
468 android_test_entries = {} | |
469 for entry in entries: | |
470 target_name = entry.GnTarget() | |
471 if (target_name.endswith('_test_apk__apk') and | |
472 'apk_under_test' in entry.Gradle()): | |
473 apk_name = entry.Gradle()['apk_under_test'] | |
474 android_test_entries[apk_name] = entry | |
475 elif (target_name.endswith('_junit_tests__java_binary') and | |
476 'lib_under_test' in entry.Gradle()): | |
477 lib_name = entry.Gradle()['lib_under_test'] | |
478 test_entries[lib_name] = entry | |
479 else: | |
480 combined_entries.append(entry) | |
481 for entry in combined_entries: | |
482 target_name = entry.DepsInfo()['name'] | |
483 gn_target_name = entry.GnTarget() | |
484 if target_name in test_entries: | |
485 entry.SetTest(test_entries[gn_target_name]) | |
486 if target_name in android_test_entries: | |
487 entry.SetAndroidTest(android_test_entries[target_name]) | |
488 return combined_entries | |
agrieve
2017/01/12 21:28:35
From inspection, it seems like there's risk of the
Peter Wen
2017/01/18 20:54:40
Done.
| |
489 | |
490 | |
390 def main(): | 491 def main(): |
391 parser = argparse.ArgumentParser() | 492 parser = argparse.ArgumentParser() |
392 parser.add_argument('--output-directory', | 493 parser.add_argument('--output-directory', |
393 help='Path to the root build directory.') | 494 help='Path to the root build directory.') |
394 parser.add_argument('-v', | 495 parser.add_argument('-v', |
395 '--verbose', | 496 '--verbose', |
396 dest='verbose_count', | 497 dest='verbose_count', |
397 default=0, | 498 default=0, |
398 action='count', | 499 action='count', |
399 help='Verbose level') | 500 help='Verbose level') |
(...skipping 18 matching lines...) Expand all Loading... | |
418 output_dir = constants.GetOutDirectory() | 519 output_dir = constants.GetOutDirectory() |
419 devil_chromium.Initialize(output_directory=output_dir) | 520 devil_chromium.Initialize(output_directory=output_dir) |
420 run_tests_helper.SetLogLevel(args.verbose_count) | 521 run_tests_helper.SetLogLevel(args.verbose_count) |
421 | 522 |
422 gradle_output_dir = os.path.abspath( | 523 gradle_output_dir = os.path.abspath( |
423 args.project_dir.replace('$CHROMIUM_OUTPUT_DIR', output_dir)) | 524 args.project_dir.replace('$CHROMIUM_OUTPUT_DIR', output_dir)) |
424 logging.warning('Creating project at: %s', gradle_output_dir) | 525 logging.warning('Creating project at: %s', gradle_output_dir) |
425 | 526 |
426 if args.all: | 527 if args.all: |
427 # Run GN gen if necessary (faster than running "gn gen" in the no-op case). | 528 # Run GN gen if necessary (faster than running "gn gen" in the no-op case). |
428 _RunNinja(output_dir, ['build.ninja']) | 529 _RunNinja(constants.GetOutDirectory(), ['build.ninja']) |
429 # Query ninja for all __build_config targets. | 530 # Query ninja for all __build_config targets. |
430 targets = _QueryForAllGnTargets(output_dir) | 531 targets = _QueryForAllGnTargets(output_dir) |
431 else: | 532 else: |
432 targets = args.targets or _DEFAULT_TARGETS | 533 targets = args.targets or _DEFAULT_TARGETS |
433 # TODO(agrieve): See if it makes sense to utilize Gradle's test constructs | 534 # TODO(agrieve): See if it makes sense to utilize Gradle's test constructs |
434 # for our instrumentation tests. | 535 # for our instrumentation tests. |
435 targets = [re.sub(r'_test_apk$', '_test_apk__apk', t) for t in targets] | 536 targets = [re.sub(r'_test_apk$', '_test_apk__apk', t) for t in targets] |
436 targets = [re.sub(r'_junit_tests$', '_junit_tests__java_binary', t) | 537 targets = [re.sub(r'_junit_tests$', '_junit_tests__java_binary', t) |
437 for t in targets] | 538 for t in targets] |
438 | 539 |
439 main_entries = [_ProjectEntry(t) for t in targets] | 540 main_entries = [_ProjectEntry(t) for t in targets] |
440 | 541 |
441 logging.warning('Building .build_config files...') | 542 logging.warning('Building .build_config files...') |
442 _RunNinja(output_dir, [e.NinjaBuildConfigTarget() for e in main_entries]) | 543 _RunNinja(output_dir, [e.NinjaBuildConfigTarget() for e in main_entries]) |
443 | 544 |
444 # There are many unused libraries, so restrict to those that are actually used | 545 # There are many unused libraries, so restrict to those that are actually used |
445 # when using --all. | 546 # when using --all. |
446 if args.all: | 547 if args.all: |
447 main_entries = [e for e in main_entries if e.GetType() == 'android_apk'] | 548 main_entries = [e for e in main_entries if e.GetType() == 'android_apk'] |
448 | 549 |
449 all_entries = _FindAllProjectEntries(main_entries) | 550 all_entries = _FindAllProjectEntries(main_entries) |
450 logging.info('Found %d dependent build_config targets.', len(all_entries)) | 551 logging.info('Found %d dependent build_config targets.', len(all_entries)) |
451 | 552 |
452 logging.warning('Writing .gradle files...') | 553 logging.warning('Writing .gradle files...') |
453 jinja_processor = jinja_template.JinjaProcessor(_FILE_DIR) | 554 jinja_processor = jinja_template.JinjaProcessor(_FILE_DIR) |
454 build_vars = _ReadBuildVars(output_dir) | 555 build_vars = _ReadBuildVars(output_dir) |
455 project_entries = [] | 556 project_entries = [] |
456 srcjar_tuples = [] | 557 srcjar_tuples = [] |
457 generated_inputs = [] | 558 generated_inputs = [] |
458 for entry in all_entries: | 559 entries = _CombineTestEntries(all_entries) |
agrieve
2017/01/12 21:28:35
nit: move this above the "writing gradle files" lo
Peter Wen
2017/01/18 20:54:41
Done.
| |
560 for entry in entries: | |
459 if entry.GetType() not in ('android_apk', 'java_library', 'java_binary'): | 561 if entry.GetType() not in ('android_apk', 'java_library', 'java_binary'): |
460 continue | 562 continue |
461 | 563 |
462 entry_output_dir = os.path.join(gradle_output_dir, entry.GradleSubdir()) | 564 entry_output_dir = entry.EntryOutputDir(gradle_output_dir) |
463 relativize = lambda x, d=entry_output_dir: _RebasePath(x, d) | 565 relativize = lambda x, d=entry_output_dir: _RebasePath(x, d) |
464 build_config = entry.BuildConfig() | |
465 | 566 |
466 srcjars = _RebasePath(build_config['gradle'].get('bundled_srcjars', [])) | 567 data = _GenerateGradleFile(entry, gradle_output_dir, build_vars, |
467 if not args.use_gradle_process_resources: | |
468 srcjars += _RebasePath(build_config['javac']['srcjars']) | |
469 | |
470 java_sources_file = build_config['gradle'].get('java_sources_file') | |
471 java_files = [] | |
472 if java_sources_file: | |
473 java_sources_file = _RebasePath(java_sources_file) | |
474 java_files = build_utils.ReadSourcesList(java_sources_file) | |
475 | |
476 java_dirs = _CreateJavaSourceDir(output_dir, entry_output_dir, java_files) | |
477 if srcjars: | |
478 java_dirs.append(os.path.join(entry_output_dir, _SRCJARS_SUBDIR)) | |
479 | |
480 native_section = build_config.get('native') | |
481 if native_section: | |
482 jni_libs = _CreateJniLibsDir( | |
483 output_dir, entry_output_dir, native_section.get('libraries')) | |
484 else: | |
485 jni_libs = [] | |
486 | |
487 data = _GenerateGradleFile(build_config, build_vars, java_dirs, jni_libs, | |
488 relativize, args.use_gradle_process_resources, | 568 relativize, args.use_gradle_process_resources, |
489 jinja_processor) | 569 jinja_processor) |
490 if data: | 570 if data: |
491 project_entries.append(entry) | 571 project_entries.append(entry) |
492 # Build all paths references by .gradle that exist within output_dir. | 572 # Build all paths references by .gradle that exist within output_dir. |
493 generated_inputs.extend(srcjars) | 573 generated_inputs.extend(entry.GeneratedInputs( |
494 generated_inputs.extend(p for p in java_files if not p.startswith('..')) | 574 args.use_gradle_process_resources)) |
495 generated_inputs.extend(build_config['gradle']['dependent_prebuilt_jars']) | |
496 | |
497 srcjar_tuples.extend( | 575 srcjar_tuples.extend( |
498 (s, os.path.join(entry_output_dir, _SRCJARS_SUBDIR)) for s in srcjars) | 576 (s, os.path.join(entry_output_dir, _SRCJARS_SUBDIR)) |
577 for s in entry.Srcjars(args.use_gradle_process_resources)) | |
499 _WriteFile(os.path.join(entry_output_dir, 'build.gradle'), data) | 578 _WriteFile(os.path.join(entry_output_dir, 'build.gradle'), data) |
500 | 579 |
501 _WriteFile(os.path.join(gradle_output_dir, 'build.gradle'), | 580 _WriteFile(os.path.join(gradle_output_dir, 'build.gradle'), |
502 _GenerateRootGradle(jinja_processor)) | 581 _GenerateRootGradle(jinja_processor)) |
503 | 582 |
504 _WriteFile(os.path.join(gradle_output_dir, 'settings.gradle'), | 583 _WriteFile(os.path.join(gradle_output_dir, 'settings.gradle'), |
505 _GenerateSettingsGradle(project_entries)) | 584 _GenerateSettingsGradle(project_entries)) |
506 | 585 |
507 sdk_path = _RebasePath(build_vars['android_sdk_root']) | 586 sdk_path = _RebasePath(build_vars['android_sdk_root']) |
508 _WriteFile(os.path.join(gradle_output_dir, 'local.properties'), | 587 _WriteFile(os.path.join(gradle_output_dir, 'local.properties'), |
509 _GenerateLocalProperties(sdk_path)) | 588 _GenerateLocalProperties(sdk_path)) |
510 | 589 |
511 if generated_inputs: | 590 if generated_inputs: |
512 logging.warning('Building generated source files...') | 591 logging.warning('Building generated source files...') |
513 targets = _RebasePath(generated_inputs, output_dir) | 592 targets = _RebasePath(generated_inputs, output_dir) |
514 _RunNinja(output_dir, targets) | 593 _RunNinja(output_dir, targets) |
515 | 594 |
516 if srcjar_tuples: | 595 if srcjar_tuples: |
517 _ExtractSrcjars(gradle_output_dir, srcjar_tuples) | 596 _ExtractSrcjars(gradle_output_dir, srcjar_tuples) |
518 | 597 |
519 logging.warning('Project created! (%d subprojects)', len(project_entries)) | 598 logging.warning('Project created! (%d subprojects)', len(project_entries)) |
520 logging.warning('Generated projects work best with Android Studio 2.2') | 599 logging.warning('Generated projects work best with Android Studio 2.2') |
521 logging.warning('For more tips: https://chromium.googlesource.com/chromium' | 600 logging.warning('For more tips: https://chromium.googlesource.com/chromium' |
522 '/src.git/+/master/docs/android_studio.md') | 601 '/src.git/+/master/docs/android_studio.md') |
523 | 602 |
524 | 603 |
525 if __name__ == '__main__': | 604 if __name__ == '__main__': |
526 main() | 605 main() |
OLD | NEW |