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

Side by Side Diff: build/config/android/internal_rules.gni

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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
« no previous file with comments | « build/config/android/config.gni ('k') | build/config/android/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/config/android/config.gni")
6
7 assert(is_android)
8
9 rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
10 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir)
11 rebased_android_sdk_build_tools =
12 rebase_path(android_sdk_build_tools, root_build_dir)
13
14 android_sdk_jar = "$android_sdk/android.jar"
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
16 android_aapt_path = "$rebased_android_sdk_build_tools/aapt"
17
18 template("android_lint") {
19 set_sources_assignment_filter([])
20 if (defined(invoker.testonly)) {
21 testonly = invoker.testonly
22 }
23
24 jar_path = invoker.jar_path
25 android_manifest = invoker.android_manifest
26 java_files = invoker.java_files
27 base_path = "$target_gen_dir/$target_name"
28
29 action(target_name) {
30 script = "//build/android/gyp/lint.py"
31 result_path = base_path + "/result.xml"
32 config_path = base_path + "/config.xml"
33 suppressions_file = "//build/android/lint/suppressions.xml"
34 inputs = [
35 suppressions_file,
36 android_manifest,
37 jar_path,
38 ] + java_files
39
40 outputs = [
41 config_path,
42 result_path,
43 ]
44
45 rebased_java_files = rebase_path(java_files, root_build_dir)
46
47 args = [
48 "--lint-path=$rebased_android_sdk_root/tools/lint",
49 "--config-path",
50 rebase_path(suppressions_file, root_build_dir),
51 "--manifest-path",
52 rebase_path(android_manifest, root_build_dir),
53 "--product-dir=.",
54 "--jar-path",
55 rebase_path(jar_path, root_build_dir),
56 "--processed-config-path",
57 rebase_path(config_path, root_build_dir),
58 "--result-path",
59 rebase_path(result_path, root_build_dir),
60 "--java-files=$rebased_java_files",
61 "--enable",
62 ]
63
64 if (defined(invoker.deps)) {
65 deps = invoker.deps
66 }
67 if (defined(invoker.public_deps)) {
68 public_deps = invoker.public_deps
69 }
70 if (defined(invoker.data_deps)) {
71 data_deps = invoker.data_deps
72 }
73 }
74 }
75
76 template("findbugs") {
77 jar_path = invoker.jar_path
78
79 build_config = invoker.build_config
80
81 action(target_name) {
82 script = "//build/android/findbugs_diff.py"
83 depfile = "$target_gen_dir/$target_name.d"
84 result_path = "$target_gen_dir/$target_name/result.xml"
85 exclusions_file = "//build/android/findbugs_filter/findbugs_exclude.xml"
86
87 rebased_build_config = rebase_path(build_config, root_build_dir)
88
89 if (defined(invoker.deps)) {
90 deps = invoker.deps
91 }
92
93 if (defined(invoker.testonly)) {
94 testonly = invoker.testonly
95 }
96
97 inputs = [
98 "//build/android/pylib/utils/findbugs.py",
99 exclusions_file,
100 jar_path,
101 ]
102
103 outputs = [
104 depfile,
105 result_path,
106 ]
107
108 args = [
109 "--depfile",
110 rebase_path(depfile, root_build_dir),
111 "--exclude",
112 rebase_path(exclusions_file, root_build_dir),
113 "--auxclasspath-gyp",
114 "@FileArg($rebased_build_config:javac:classpath)",
115 "--output-file",
116 rebase_path(result_path, root_build_dir),
117 rebase_path(jar_path, root_build_dir),
118 ]
119 }
120 }
121
122 template("dex") {
123 set_sources_assignment_filter([])
124 if (defined(invoker.testonly)) {
125 testonly = invoker.testonly
126 }
127
128 assert(defined(invoker.output))
129 action(target_name) {
130 script = "//build/android/gyp/dex.py"
131 depfile = "$target_gen_dir/$target_name.d"
132 if (defined(invoker.sources)) {
133 sources = invoker.sources
134 }
135 outputs = [
136 depfile,
137 invoker.output,
138 ]
139 if (defined(invoker.inputs)) {
140 inputs = invoker.inputs
141 }
142
143 if (defined(invoker.deps)) {
144 deps = invoker.deps
145 }
146
147 rebased_output = rebase_path(invoker.output, root_build_dir)
148
149 args = [
150 "--depfile",
151 rebase_path(depfile, root_build_dir),
152 "--android-sdk-tools",
153 rebased_android_sdk_build_tools,
154 "--dex-path",
155 rebased_output,
156 ]
157
158 if (defined(invoker.no_locals) && invoker.no_locals) {
159 args += [ "--no-locals=1" ]
160 }
161
162 if (defined(invoker.args)) {
163 args += invoker.args
164 }
165
166 if (defined(invoker.sources)) {
167 args += rebase_path(invoker.sources, root_build_dir)
168 }
169 }
170 }
171
172 # Creates a zip archive of the inputs.
173 # If base_dir is provided, the archive paths will be relative to it.
174 template("zip") {
175 set_sources_assignment_filter([])
176 if (defined(invoker.testonly)) {
177 testonly = invoker.testonly
178 }
179
180 assert(defined(invoker.inputs))
181 assert(defined(invoker.output))
182
183 rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
184 rebase_output = rebase_path(invoker.output, root_build_dir)
185 action(target_name) {
186 script = "//build/android/gn/zip.py"
187 depfile = "$target_gen_dir/$target_name.d"
188 inputs = invoker.inputs
189 outputs = [
190 depfile,
191 invoker.output,
192 ]
193 args = [
194 "--depfile",
195 rebase_path(depfile, root_build_dir),
196 "--inputs=$rebase_inputs",
197 "--output=$rebase_output",
198 ]
199 if (defined(invoker.base_dir)) {
200 args += [
201 "--base-dir",
202 rebase_path(invoker.base_dir, root_build_dir),
203 ]
204 }
205
206 if (defined(invoker.deps)) {
207 deps = invoker.deps
208 }
209 if (defined(invoker.public_deps)) {
210 public_deps = invoker.public_deps
211 }
212 if (defined(invoker.data_deps)) {
213 data_deps = invoker.data_deps
214 }
215
216 if (defined(invoker.visibility)) {
217 visibility = invoker.visibility
218 }
219 }
220 }
221
222 # Write the target's .build_config file. This is a json file that contains a
223 # dictionary of information about how to build this target (things that
224 # require knowledge about this target's dependencies and cannot be calculated
225 # at gn-time). There is a special syntax to add a value in that dictionary to
226 # an action/action_foreachs args:
227 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
228 # At runtime, such an arg will be replaced by the value in the build_config.
229 # See build/android/gyp/write_build_config.py and
230 # build/android/gyp/util/build_utils.py:ExpandFileArgs
231 template("write_build_config") {
232 set_sources_assignment_filter([])
233 if (defined(invoker.testonly)) {
234 testonly = invoker.testonly
235 }
236
237 assert(defined(invoker.type))
238 assert(defined(invoker.build_config))
239
240 type = invoker.type
241 build_config = invoker.build_config
242
243 assert(type == "android_apk" || type == "java_library" ||
244 type == "android_resources" || type == "deps_dex")
245
246 action(target_name) {
247 if (defined(invoker.visibility)) {
248 visibility = invoker.visibility
249 }
250
251 script = "//build/android/gyp/write_build_config.py"
252 depfile = "$target_gen_dir/$target_name.d"
253 inputs = []
254
255 deps = []
256 if (defined(invoker.deps)) {
257 deps += invoker.deps
258 }
259
260 possible_deps_configs = []
261 foreach(d, deps) {
262 dep_gen_dir = get_label_info(d, "target_gen_dir")
263 dep_name = get_label_info(d, "name")
264 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ]
265 }
266 rebase_possible_deps_configs =
267 rebase_path(possible_deps_configs, root_build_dir)
268
269 outputs = [
270 depfile,
271 build_config,
272 ]
273
274 args = [
275 "--type",
276 type,
277 "--depfile",
278 rebase_path(depfile, root_build_dir),
279 "--possible-deps-configs=$rebase_possible_deps_configs",
280 "--build-config",
281 rebase_path(build_config, root_build_dir),
282 ]
283
284 is_java_library = type == "java_library"
285 is_apk = type == "android_apk"
286 is_android_resources = type == "android_resources"
287 is_deps_dex = type == "deps_dex"
288
289 supports_android = is_apk || is_android_resources || is_deps_dex ||
290 (is_java_library && defined(invoker.supports_android) &&
291 invoker.supports_android)
292 requires_android = is_apk || is_android_resources || is_deps_dex ||
293 (is_java_library && defined(invoker.requires_android) &&
294 invoker.requires_android)
295
296 assert(!requires_android || supports_android,
297 "requires_android requires" + " supports_android")
298
299 # Mark these variables as used.
300 assert(is_java_library || true)
301 assert(is_apk || true)
302 assert(is_android_resources || true)
303 assert(is_deps_dex || true)
304
305 if (is_java_library || is_apk) {
306 args += [
307 "--jar-path",
308 rebase_path(invoker.jar_path, root_build_dir),
309 ]
310 }
311
312 if (is_apk || is_deps_dex || (is_java_library && supports_android)) {
313 args += [
314 "--dex-path",
315 rebase_path(invoker.dex_path, root_build_dir),
316 ]
317 }
318 if (supports_android) {
319 args += [ "--supports-android" ]
320 }
321 if (requires_android) {
322 args += [ "--requires-android" ]
323 }
324 if (defined(invoker.bypass_platform_checks) &&
325 invoker.bypass_platform_checks) {
326 args += [ "--bypass-platform-checks" ]
327 }
328
329 if (defined(invoker.apk_under_test)) {
330 deps += [ invoker.apk_under_test ]
331 apk_under_test_gen_dir =
332 get_label_info(invoker.apk_under_test, "target_gen_dir")
333 apk_under_test_name = get_label_info(invoker.apk_under_test, "name")
334 apk_under_test_config =
335 "$apk_under_test_gen_dir/$apk_under_test_name.build_config"
336 args += [
337 "--tested-apk-config",
338 rebase_path(apk_under_test_config, root_build_dir),
339 ]
340 }
341
342 if (is_android_resources || is_apk) {
343 assert(defined(invoker.resources_zip))
344 args += [
345 "--resources-zip",
346 rebase_path(invoker.resources_zip, root_build_dir),
347 ]
348 if (defined(invoker.android_manifest)) {
349 inputs += [ invoker.android_manifest ]
350 args += [
351 "--android-manifest",
352 rebase_path(invoker.android_manifest, root_build_dir),
353 ]
354 } else {
355 assert(!is_apk, "apk build configs require an android_manifest")
356 }
357 if (defined(invoker.custom_package)) {
358 args += [
359 "--package-name",
360 invoker.custom_package,
361 ]
362 }
363 if (defined(invoker.r_text)) {
364 args += [
365 "--r-text",
366 rebase_path(invoker.r_text, root_build_dir),
367 ]
368 }
369 }
370
371 if (is_apk) {
372 if (defined(invoker.native_libs)) {
373 inputs += invoker.native_libs
374 rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir)
375 rebased_android_readelf = rebase_path(android_readelf, root_build_dir)
376 args += [
377 "--native-libs=$rebased_native_libs",
378 "--readelf-path=$rebased_android_readelf",
379 ]
380 }
381 }
382
383 if (defined(invoker.srcjar)) {
384 args += [
385 "--srcjar",
386 rebase_path(invoker.srcjar, root_build_dir),
387 ]
388 }
389 }
390 }
391
392 template("process_java_prebuilt") {
393 set_sources_assignment_filter([])
394 if (defined(invoker.testonly)) {
395 testonly = invoker.testonly
396 }
397
398 _input_jar_path = invoker.input_jar_path
399 _output_jar_path = invoker.output_jar_path
400 _jar_toc_path = _output_jar_path + ".TOC"
401
402 assert(invoker.build_config != "")
403
404 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
405 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar"
406 _proguard_config_path = invoker.proguard_config
407 _build_config = invoker.build_config
408 _rebased_build_config = rebase_path(_build_config, root_build_dir)
409 _output_jar_target = "${target_name}__proguard_process"
410 action(_output_jar_target) {
411 script = "//build/android/gyp/proguard.py"
412 inputs = [
413 android_sdk_jar,
414 _proguard_jar_path,
415 _build_config,
416 _input_jar_path,
417 _proguard_config_path,
418 ]
419 depfile = "${target_gen_dir}/${target_name}.d"
420 outputs = [
421 depfile,
422 _output_jar_path,
423 ]
424 args = [
425 "--depfile",
426 rebase_path(depfile, root_build_dir),
427 "--proguard-path",
428 rebase_path(_proguard_jar_path, root_build_dir),
429 "--input-path",
430 rebase_path(_input_jar_path, root_build_dir),
431 "--output-path",
432 rebase_path(_output_jar_path, root_build_dir),
433 "--proguard-config",
434 rebase_path(_proguard_config_path, root_build_dir),
435 "--classpath",
436 rebased_android_sdk_jar,
437 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
438 ]
439
440 if (defined(invoker.deps)) {
441 deps = invoker.deps
442 }
443 if (defined(invoker.public_deps)) {
444 public_deps = invoker.public_deps
445 }
446 if (defined(invoker.data_deps)) {
447 data_deps = invoker.data_deps
448 }
449 }
450 } else {
451 _output_jar_target = "${target_name}__copy_jar"
452 copy(_output_jar_target) {
453 sources = [
454 _input_jar_path,
455 ]
456 outputs = [
457 _output_jar_path,
458 ]
459
460 if (defined(invoker.deps)) {
461 deps = invoker.deps
462 }
463 if (defined(invoker.public_deps)) {
464 public_deps = invoker.public_deps
465 }
466 if (defined(invoker.data_deps)) {
467 data_deps = invoker.data_deps
468 }
469 }
470 }
471
472 action("${target_name}__jar_toc") {
473 script = "//build/android/gyp/jar_toc.py"
474 depfile = "$target_gen_dir/$target_name.d"
475 outputs = [
476 depfile,
477 _jar_toc_path,
478 _jar_toc_path + ".md5.stamp",
479 ]
480 inputs = [
481 _output_jar_path,
482 ]
483 args = [
484 "--depfile",
485 rebase_path(depfile, root_build_dir),
486 "--jar-path",
487 rebase_path(_output_jar_path, root_build_dir),
488 "--toc-path",
489 rebase_path(_jar_toc_path, root_build_dir),
490 ]
491 public_deps = [
492 ":$_output_jar_target",
493 ]
494 }
495
496 group(target_name) {
497 if (defined(invoker.visibility)) {
498 visibility = invoker.visibility
499 }
500 public_deps = [
501 ":${target_name}__jar_toc",
502 ":$_output_jar_target",
503 ]
504 }
505 }
506
507 template("finalize_apk") {
508 action(target_name) {
509 script = "//build/android/gyp/finalize_apk.py"
510 depfile = "$target_gen_dir/$target_name.d"
511
512 if (defined(invoker.testonly)) {
513 testonly = invoker.testonly
514 }
515
516 sources = [
517 invoker.input_apk_path,
518 ]
519 inputs = [
520 invoker.keystore_path,
521 ]
522 outputs = [
523 depfile,
524 invoker.output_apk_path,
525 ]
526
527 args = [
528 "--depfile",
529 rebase_path(depfile, root_build_dir),
530 "--zipalign-path",
531 rebase_path(zipalign_path, root_build_dir),
532 "--unsigned-apk-path",
533 rebase_path(invoker.input_apk_path, root_build_dir),
534 "--final-apk-path",
535 rebase_path(invoker.output_apk_path, root_build_dir),
536 "--key-path",
537 rebase_path(invoker.keystore_path, root_build_dir),
538 "--key-name",
539 invoker.keystore_name,
540 "--key-passwd",
541 invoker.keystore_password,
542 ]
543 if (defined(invoker.rezip_apk) && invoker.rezip_apk) {
544 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
545 inputs += [ _rezip_jar_path ]
546 args += [
547 "--load-library-from-zip=1",
548 "--rezip-apk-jar-path",
549 rebase_path(_rezip_jar_path, root_build_dir),
550 ]
551 }
552
553 if (defined(invoker.deps)) {
554 deps = invoker.deps
555 }
556 if (defined(invoker.public_deps)) {
557 public_deps = invoker.public_deps
558 }
559 if (defined(invoker.data_deps)) {
560 data_deps = invoker.data_deps
561 }
562 }
563 }
564
565 # Packages resources, assets, dex, and native libraries into an apk. Signs and
566 # zipaligns the apk.
567 template("create_apk") {
568 set_sources_assignment_filter([])
569 if (defined(invoker.testonly)) {
570 testonly = invoker.testonly
571 }
572
573 _android_manifest = invoker.android_manifest
574 _base_path = invoker.base_path
575 _final_apk_path = invoker.apk_path
576
577 if (defined(invoker.resources_zip)) {
578 _resources_zip = invoker.resources_zip
579 }
580 if (defined(invoker.dex_path)) {
581 _dex_path = invoker.dex_path
582 }
583 _load_library_from_apk = invoker.load_library_from_apk
584
585 _package_deps = []
586 if (defined(invoker.deps)) {
587 _package_deps = invoker.deps
588 }
589
590 _native_libs_dir = "//build/android/empty/res"
591 if (defined(invoker.native_libs_dir)) {
592 _native_libs_dir = invoker.native_libs_dir
593 }
594
595 if (defined(invoker.asset_location)) {
596 _asset_location = invoker.asset_location
597 }
598
599 _version_code = invoker.version_code
600 _version_name = invoker.version_name
601
602 _base_apk_path = _base_path + ".apk_intermediates"
603
604 _resource_packaged_apk_path = _base_apk_path + ".ap_"
605 _packaged_apk_path = _base_apk_path + ".unfinished.apk"
606 _shared_resources =
607 defined(invoker.shared_resources) && invoker.shared_resources
608
609 _configuration_name = "Release"
610 if (is_debug) {
611 _configuration_name = "Debug"
612 }
613
614 _keystore_path = invoker.keystore_path
615 _keystore_name = invoker.keystore_name
616 _keystore_password = invoker.keystore_password
617
618 _split_densities = []
619 if (defined(invoker.create_density_splits) && invoker.create_density_splits) {
620 _split_densities = [
621 "hdpi",
622 "xhdpi",
623 "xxhdpi",
624 "xxxhdpi",
625 "tvdpi",
626 ]
627 }
628
629 _split_languages = []
630 if (defined(invoker.language_splits)) {
631 _split_languages = invoker.language_splits
632 }
633
634 _package_resources_target_name = "${target_name}__package_resources"
635 action(_package_resources_target_name) {
636 deps = _package_deps
637
638 script = "//build/android/gyp/package_resources.py"
639 depfile = "${target_gen_dir}/${target_name}.d"
640 inputs = [
641 _android_manifest,
642 ]
643 if (defined(_resources_zip)) {
644 inputs += [ _resources_zip ]
645 }
646 outputs = [
647 depfile,
648 _resource_packaged_apk_path,
649 ]
650
651 args = [
652 "--depfile",
653 rebase_path(depfile, root_build_dir),
654 "--android-sdk",
655 rebased_android_sdk,
656 "--aapt-path",
657 android_aapt_path,
658 "--configuration-name=$_configuration_name",
659 "--android-manifest",
660 rebase_path(_android_manifest, root_build_dir),
661 "--version-code",
662 _version_code,
663 "--version-name",
664 _version_name,
665 "--apk-path",
666 rebase_path(_resource_packaged_apk_path, root_build_dir),
667 ]
668
669 if (defined(_asset_location)) {
670 args += [
671 "--asset-dir",
672 rebase_path(_asset_location, root_build_dir),
673 ]
674 }
675 if (defined(_resources_zip)) {
676 args += [
677 "--resource-zips",
678 rebase_path(_resources_zip, root_build_dir),
679 ]
680 }
681 if (_shared_resources) {
682 args += [ "--shared-resources" ]
683 }
684 if (_split_densities != []) {
685 args += [ "--create-density-splits" ]
686 foreach(_density, _split_densities) {
687 outputs += [ "${_resource_packaged_apk_path}_${_density}" ]
688 }
689 }
690 if (_split_languages != []) {
691 args += [ "--language-splits=$_split_languages" ]
692 foreach(_language, _split_languages) {
693 outputs += [ "${_resource_packaged_apk_path}_${_language}" ]
694 }
695 }
696 if (defined(invoker.extensions_to_not_compress)) {
697 args += [
698 "--no-compress",
699 invoker.extensions_to_not_compress,
700 ]
701 }
702 }
703
704 package_target = "${target_name}__package"
705 action(package_target) {
706 script = "//build/android/gyp/ant.py"
707 _ant_script = "//build/android/ant/apk-package.xml"
708
709 deps = [
710 ":${_package_resources_target_name}",
711 ]
712 if (defined(invoker.deps)) {
713 deps += invoker.deps
714 }
715 depfile = "$target_gen_dir/$target_name.d"
716
717 inputs = [
718 _resource_packaged_apk_path,
719 _ant_script,
720 ]
721 if (defined(_dex_path)) {
722 inputs += [ _dex_path ]
723 }
724
725 outputs = [
726 depfile,
727 _packaged_apk_path,
728 ]
729
730 _rebased_emma_jar = ""
731 _rebased_resource_packaged_apk_path =
732 rebase_path(_resource_packaged_apk_path, root_build_dir)
733 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
734 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
735 args = [
736 "--depfile",
737 rebase_path(depfile, root_build_dir),
738 "--",
739 "-quiet",
740 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
741 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
742 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
743 "-DCONFIGURATION_NAME=$_configuration_name",
744 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
745 "-DOUT_DIR=",
746 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
747 "-DEMMA_INSTRUMENT=0",
748 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
749 "-Dbasedir=.",
750 "-buildfile",
751 rebase_path(_ant_script, root_build_dir),
752 ]
753 if (defined(_dex_path)) {
754 _rebased_dex_path = rebase_path(_dex_path, root_build_dir)
755 args += [
756 "-DDEX_FILE_PATH=$_rebased_dex_path",
757 "-DHAS_CODE=true",
758 ]
759 } else {
760 args += [ "-DHAS_CODE=false" ]
761 }
762 }
763
764 _finalize_apk_rule_name = "${target_name}__finalize"
765 finalize_apk(_finalize_apk_rule_name) {
766 input_apk_path = _packaged_apk_path
767 output_apk_path = _final_apk_path
768 keystore_path = _keystore_path
769 keystore_name = _keystore_name
770 keystore_password = _keystore_password
771 rezip_apk = _load_library_from_apk
772
773 public_deps = [
774 # Generator of the _packaged_apk_path this target takes as input.
775 ":$package_target",
776 ]
777 }
778
779 _final_deps = [ ":${_finalize_apk_rule_name}" ]
780
781 template("finalize_split") {
782 finalize_apk(target_name) {
783 _config = invoker.split_config
784 _type = invoker.split_type
785 input_apk_path = "${_resource_packaged_apk_path}_${_config}"
786 _output_paths = process_file_template(
787 [ _final_apk_path ],
788 "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk")
789 output_apk_path = _output_paths[0]
790 keystore_path = _keystore_path
791 keystore_name = _keystore_name
792 keystore_password = _keystore_password
793 deps = [
794 ":${_package_resources_target_name}",
795 ]
796 }
797 }
798
799 foreach(_split, _split_densities) {
800 _split_rule = "${target_name}__finalize_${_split}_split"
801 finalize_split(_split_rule) {
802 split_type = "density"
803 split_config = _split
804 }
805 _final_deps += [ ":$_split_rule" ]
806 }
807 foreach(_split, _split_languages) {
808 _split_rule = "${target_name}__finalize_${_split}_split"
809 finalize_split(_split_rule) {
810 split_type = "lang"
811 split_config = _split
812 }
813 _final_deps += [ ":$_split_rule" ]
814 }
815
816 group(target_name) {
817 public_deps = _final_deps
818 }
819 }
820
821 template("java_prebuilt_impl") {
822 set_sources_assignment_filter([])
823 if (defined(invoker.testonly)) {
824 testonly = invoker.testonly
825 }
826 _supports_android =
827 defined(invoker.supports_android) && invoker.supports_android
828
829 assert(defined(invoker.jar_path))
830 _base_path = "${target_gen_dir}/$target_name"
831 _jar_path = _base_path + ".jar"
832 _build_config = _base_path + ".build_config"
833
834 if (_supports_android) {
835 _dex_path = _base_path + ".dex.jar"
836 }
837 _deps = []
838 if (defined(invoker.deps)) {
839 _deps = invoker.deps
840 }
841 _jar_deps = []
842 if (defined(invoker.jar_dep)) {
843 _jar_deps = [ invoker.jar_dep ]
844 }
845
846 _template_name = target_name
847
848 build_config_target_name = "${_template_name}__build_config"
849 process_jar_target_name = "${_template_name}__process_jar"
850 if (_supports_android) {
851 dex_target_name = "${_template_name}__dex"
852 }
853
854 write_build_config(build_config_target_name) {
855 type = "java_library"
856 supports_android = _supports_android
857 requires_android =
858 defined(invoker.requires_android) && invoker.requires_android
859
860 deps = _deps
861 build_config = _build_config
862 jar_path = _jar_path
863 if (_supports_android) {
864 dex_path = _dex_path
865 }
866 }
867
868 process_java_prebuilt(process_jar_target_name) {
869 visibility = [ ":$_template_name" ]
870 if (_supports_android) {
871 visibility += [ ":$dex_target_name" ]
872 }
873
874 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
875 proguard_preprocess = true
876 proguard_config = invoker.proguard_config
877 }
878
879 build_config = _build_config
880 input_jar_path = invoker.jar_path
881 output_jar_path = _jar_path
882
883 deps = [ ":$build_config_target_name" ] + _deps + _jar_deps
884 }
885
886 if (_supports_android) {
887 dex(dex_target_name) {
888 sources = [
889 _jar_path,
890 ]
891 output = _dex_path
892 deps = [ ":$process_jar_target_name" ] + _deps + _jar_deps
893 }
894 }
895
896 group(target_name) {
897 deps = [
898 ":$process_jar_target_name",
899 ]
900 if (defined(invoker.data_deps)) {
901 data_deps = invoker.data_deps
902 }
903 if (_supports_android) {
904 deps += [ ":$dex_target_name" ]
905 }
906 }
907 }
908
909 # Compiles and jars a set of java files.
910 #
911 # Outputs:
912 # $jar_path.jar
913 # $jar_path.jar.TOC
914 #
915 # Variables
916 # java_files: List of .java files to compile.
917 # java_deps: List of java dependencies. These should all have a .jar output
918 # at "${target_gen_dir}/${target_name}.jar.
919 # chromium_code: If true, enable extra warnings.
920 # srcjar_deps: List of srcjar dependencies. The .java files contained in the
921 # dependencies srcjar outputs will be compiled and added to the output jar.
922 # jar_path: Use this to explicitly set the output jar path. Defaults to
923 # "${target_gen_dir}/${target_name}.jar.
924 template("compile_java") {
925 set_sources_assignment_filter([])
926 if (defined(invoker.testonly)) {
927 testonly = invoker.testonly
928 }
929
930 assert(defined(invoker.java_files))
931 assert(defined(invoker.build_config))
932 assert(defined(invoker.jar_path))
933
934 _java_files = invoker.java_files
935 _final_jar_path = invoker.jar_path
936 _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar"
937
938 _build_config = invoker.build_config
939
940 _jar_excluded_patterns = []
941 if (defined(invoker.jar_excluded_patterns)) {
942 _jar_excluded_patterns += invoker.jar_excluded_patterns
943 }
944
945 _chromium_code = false
946 if (defined(invoker.chromium_code)) {
947 _chromium_code = invoker.chromium_code
948 }
949
950 _supports_android = true
951 if (defined(invoker.supports_android)) {
952 _supports_android = invoker.supports_android
953 }
954
955 _enable_errorprone = use_errorprone_java_compiler
956 if (defined(invoker.enable_errorprone)) {
957 _enable_errorprone = invoker.enable_errorprone
958 }
959
960 _manifest_entries = []
961 if (defined(invoker.manifest_entries)) {
962 _manifest_entries = invoker.manifest_entries
963 }
964
965 _srcjar_deps = []
966 if (defined(invoker.srcjar_deps)) {
967 _srcjar_deps += invoker.srcjar_deps
968 }
969
970 _java_srcjars = []
971 if (defined(invoker.srcjars)) {
972 _java_srcjars = invoker.srcjars
973 }
974 foreach(dep, _srcjar_deps) {
975 _dep_gen_dir = get_label_info(dep, "target_gen_dir")
976 _dep_name = get_label_info(dep, "name")
977 _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
978 }
979
980 # Mark srcjar_deps as used.
981 assert(_srcjar_deps == [] || true)
982
983 _system_jars = []
984 if (defined(invoker.android) && invoker.android) {
985 _system_jars += [ android_sdk_jar ]
986 }
987
988 _rebased_build_config = rebase_path(_build_config, root_build_dir)
989 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
990
991 javac_target_name = "${target_name}__javac"
992 finish_target_name = "${target_name}__finish"
993 final_target_name = target_name
994
995 action(javac_target_name) {
996 script = "//build/android/gyp/javac.py"
997 depfile = "$target_gen_dir/$target_name.d"
998 deps = _srcjar_deps
999 if (defined(invoker.deps)) {
1000 deps += invoker.deps
1001 }
1002
1003 outputs = [
1004 depfile,
1005 _intermediate_jar_path,
1006 _intermediate_jar_path + ".md5.stamp",
1007 ]
1008 sources = _java_files + _java_srcjars
1009 inputs = _system_jars + [ _build_config ]
1010
1011 _rebased_system_jars = rebase_path(_system_jars, root_build_dir)
1012 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
1013 _rebased_depfile = rebase_path(depfile, root_build_dir)
1014 args = [
1015 "--depfile=$_rebased_depfile",
1016 "--classpath=$_rebased_system_jars",
1017 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
1018 "--jar-path=$_rebased_jar_path",
1019 "--java-srcjars=$_rebased_java_srcjars",
1020 "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
1021 "--jar-excluded-classes=$_jar_excluded_patterns",
1022 ]
1023 if (_supports_android) {
1024 _rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
1025 args += [ "--bootclasspath=$_rebased_android_sdk_jar" ]
1026 }
1027 foreach(e, _manifest_entries) {
1028 args += [ "--manifest-entry=" + e ]
1029 }
1030 if (_chromium_code) {
1031 args += [ "--chromium-code=1" ]
1032 }
1033 if (_enable_errorprone) {
1034 deps += [ "//third_party/errorprone:chromium_errorprone" ]
1035 args += [
1036 "--use-errorprone-path",
1037 "bin/chromium_errorprone",
1038 ]
1039 }
1040 args += rebase_path(_java_files, root_build_dir)
1041 }
1042
1043 process_java_prebuilt(finish_target_name) {
1044 visibility = [ ":$final_target_name" ]
1045
1046 build_config = _build_config
1047 input_jar_path = _intermediate_jar_path
1048 output_jar_path = _final_jar_path
1049 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
1050 proguard_preprocess = invoker.proguard_preprocess
1051 proguard_config = invoker.proguard_config
1052 }
1053 deps = [
1054 ":$javac_target_name",
1055 ]
1056 }
1057
1058 group(final_target_name) {
1059 if (defined(invoker.visibility)) {
1060 visibility = invoker.visibility
1061 }
1062 public_deps = [
1063 ":$finish_target_name",
1064 ]
1065 }
1066 }
1067
1068 template("java_library_impl") {
1069 set_sources_assignment_filter([])
1070 if (defined(invoker.testonly)) {
1071 testonly = invoker.testonly
1072 }
1073
1074 assert(
1075 defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir) ||
1076 defined(invoker.srcjars) || defined(invoker.srcjar_deps))
1077 _base_path = "$target_gen_dir/$target_name"
1078 _jar_path = _base_path + ".jar"
1079 if (defined(invoker.jar_path)) {
1080 _jar_path = invoker.jar_path
1081 }
1082 _template_name = target_name
1083
1084 _final_deps = []
1085 _final_datadeps = []
1086 if (defined(invoker.datadeps)) {
1087 _final_datadeps = invoker.datadeps
1088 }
1089
1090 _supports_android =
1091 defined(invoker.supports_android) && invoker.supports_android
1092 _requires_android =
1093 defined(invoker.requires_android) && invoker.requires_android
1094
1095 if (_supports_android) {
1096 _dex_path = _base_path + ".dex.jar"
1097 if (defined(invoker.dex_path)) {
1098 _dex_path = invoker.dex_path
1099 }
1100 }
1101
1102 # Define build_config_deps which will be a list of targets required to
1103 # build the _build_config.
1104 if (defined(invoker.override_build_config)) {
1105 _build_config = invoker.override_build_config
1106
1107 # When a custom build config file is specified, we need to use the deps
1108 # supplied by the invoker any time we reference the build config file.
1109 assert(defined(invoker.deps),
1110 "If you specify a build config file for " +
1111 "java_library_impl($target_name), you should " +
1112 "also specify the target that made it in the deps")
1113 build_config_deps = invoker.deps
1114 } else {
1115 _build_config = _base_path + ".build_config"
1116 build_config_target_name = "${_template_name}__build_config"
1117 build_config_deps = [ ":$build_config_target_name" ]
1118
1119 write_build_config(build_config_target_name) {
1120 type = "java_library"
1121 supports_android = _supports_android
1122 requires_android = _requires_android
1123 bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
1124 invoker.bypass_platform_checks
1125
1126 deps = []
1127 if (defined(invoker.deps)) {
1128 deps += invoker.deps
1129 }
1130
1131 build_config = _build_config
1132 jar_path = _jar_path
1133 if (_supports_android) {
1134 dex_path = _dex_path
1135 }
1136 }
1137 }
1138
1139 _chromium_code = true
1140 if (defined(invoker.chromium_code)) {
1141 _chromium_code = invoker.chromium_code
1142 }
1143
1144 _srcjar_deps = []
1145 if (defined(invoker.srcjar_deps)) {
1146 _srcjar_deps = invoker.srcjar_deps
1147 }
1148
1149 _srcjars = []
1150 if (defined(invoker.srcjars)) {
1151 _srcjars = invoker.srcjars
1152 }
1153
1154 _java_files = []
1155 if (defined(invoker.java_files)) {
1156 _java_files = invoker.java_files
1157 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
1158 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
1159 _src_dir_exists = exec_script("//build/dir_exists.py",
1160 [ rebase_path(_src_dir, root_build_dir) ],
1161 "string")
1162 assert(_src_dir_exists == "False",
1163 "In GN, java_in_dir should be the fully specified java directory " +
1164 "(i.e. including the trailing \"/src\")")
1165
1166 _java_files_build_rel = exec_script(
1167 "//build/android/gyp/find.py",
1168 [
1169 "--pattern",
1170 "*.java",
1171 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir),
1172 ],
1173 "list lines")
1174 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
1175 }
1176 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
1177
1178 _compile_java_target = "${_template_name}__compile_java"
1179 _final_deps += [ ":$_compile_java_target" ]
1180 compile_java(_compile_java_target) {
1181 jar_path = _jar_path
1182 build_config = _build_config
1183 java_files = _java_files
1184 srcjar_deps = _srcjar_deps
1185 srcjars = _srcjars
1186 chromium_code = _chromium_code
1187 android = _requires_android
1188
1189 if (defined(invoker.enable_errorprone)) {
1190 enable_errorprone = invoker.enable_errorprone
1191 }
1192 if (defined(invoker.jar_excluded_patterns)) {
1193 jar_excluded_patterns = invoker.jar_excluded_patterns
1194 }
1195 if (defined(invoker.proguard_preprocess)) {
1196 proguard_preprocess = invoker.proguard_preprocess
1197 }
1198 if (defined(invoker.proguard_config)) {
1199 proguard_config = invoker.proguard_config
1200 }
1201 if (defined(invoker.dist_jar_path)) {
1202 dist_jar_path = invoker.dist_jar_path
1203 }
1204 if (defined(invoker.manifest_entries)) {
1205 manifest_entries = invoker.manifest_entries
1206 }
1207
1208 supports_android = _supports_android
1209 deps = build_config_deps
1210 }
1211
1212 if (defined(invoker.main_class)) {
1213 _final_deps += [ ":${_template_name}__binary_script" ]
1214 action("${_template_name}__binary_script") {
1215 script = "//build/android/gyp/create_java_binary_script.py"
1216 depfile = "$target_gen_dir/$target_name.d"
1217 java_script = "$root_build_dir/bin/$_template_name"
1218 inputs = [
1219 _build_config,
1220 ]
1221 outputs = [
1222 depfile,
1223 java_script,
1224 ]
1225 _rebased_build_config = rebase_path(_build_config, root_build_dir)
1226 args = [
1227 "--depfile",
1228 rebase_path(depfile, root_build_dir),
1229 "--output",
1230 rebase_path(java_script, root_build_dir),
1231 "--classpath=@FileArg($_rebased_build_config:java:full_classpath)",
1232 "--jar-path",
1233 rebase_path(_jar_path, root_build_dir),
1234 "--main-class",
1235 invoker.main_class,
1236 ]
1237
1238 deps = build_config_deps
1239 }
1240 }
1241
1242 if (_supports_android) {
1243 if (defined(invoker.chromium_code) && invoker.chromium_code) {
1244 _android_manifest = "//build/android/AndroidManifest.xml"
1245 if (defined(invoker.android_manifest)) {
1246 _android_manifest = invoker.android_manifest
1247 }
1248
1249 _final_datadeps += [ ":${_template_name}__lint" ]
1250 android_lint("${_template_name}__lint") {
1251 android_manifest = _android_manifest
1252 jar_path = _jar_path
1253 java_files = _java_files
1254 deps = [
1255 ":$_compile_java_target",
1256 ]
1257 if (defined(invoker.deps)) {
1258 deps += invoker.deps
1259 }
1260 }
1261
1262 if (run_findbugs) {
1263 _final_datadeps += [ ":${_template_name}__findbugs" ]
1264 findbugs("${_template_name}__findbugs") {
1265 build_config = _build_config
1266 jar_path = _jar_path
1267 deps = build_config_deps
1268 }
1269 }
1270 }
1271
1272 _final_deps += [ ":${_template_name}__dex" ]
1273 dex("${_template_name}__dex") {
1274 sources = [
1275 _jar_path,
1276 ]
1277 output = _dex_path
1278 deps = [
1279 ":$_compile_java_target",
1280 ]
1281 }
1282 }
1283
1284 group(target_name) {
1285 if (defined(invoker.visibility)) {
1286 visibility = invoker.visibility
1287 }
1288 public_deps = _final_deps
1289 data_deps = _final_datadeps
1290 }
1291 }
1292
1293 # Runs process_resources.py
1294 template("process_resources") {
1295 set_sources_assignment_filter([])
1296 if (defined(invoker.testonly)) {
1297 testonly = invoker.testonly
1298 }
1299
1300 zip_path = invoker.zip_path
1301 srcjar_path = invoker.srcjar_path
1302 r_text_path = invoker.r_text_path
1303 build_config = invoker.build_config
1304 resource_dirs = invoker.resource_dirs
1305 android_manifest = invoker.android_manifest
1306
1307 non_constant_id = true
1308 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) {
1309 non_constant_id = false
1310 }
1311
1312 action(target_name) {
1313 if (defined(invoker.visibility)) {
1314 visibility = invoker.visibility
1315 }
1316
1317 script = "//build/android/gyp/process_resources.py"
1318
1319 depfile = "$target_gen_dir/$target_name.d"
1320 outputs = [
1321 depfile,
1322 zip_path,
1323 srcjar_path,
1324 r_text_path,
1325 ]
1326
1327 sources_build_rel = exec_script("//build/android/gyp/find.py",
1328 rebase_path(resource_dirs, root_build_dir),
1329 "list lines")
1330 sources = rebase_path(sources_build_rel, ".", root_build_dir)
1331
1332 inputs = [
1333 build_config,
1334 android_manifest,
1335 ]
1336
1337 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir)
1338 rebase_build_config = rebase_path(build_config, root_build_dir)
1339 args = [
1340 "--depfile",
1341 rebase_path(depfile, root_build_dir),
1342 "--android-sdk",
1343 rebase_path(android_sdk, root_build_dir),
1344 "--aapt-path",
1345 android_aapt_path,
1346 "--android-manifest",
1347 rebase_path(android_manifest, root_build_dir),
1348 "--resource-dirs=$rebase_resource_dirs",
1349 "--srcjar-out",
1350 rebase_path(srcjar_path, root_build_dir),
1351 "--resource-zip-out",
1352 rebase_path(zip_path, root_build_dir),
1353 "--r-text-out",
1354 rebase_path(r_text_path, root_build_dir),
1355 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc y_zips)",
1356 "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_packag e_names)",
1357 "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text _files)",
1358 ]
1359
1360 if (non_constant_id) {
1361 args += [ "--non-constant-id" ]
1362 }
1363
1364 if (defined(invoker.custom_package)) {
1365 args += [
1366 "--custom-package",
1367 invoker.custom_package,
1368 ]
1369 }
1370
1371 if (defined(invoker.v14_skip) && invoker.v14_skip) {
1372 args += [ "--v14-skip" ]
1373 }
1374
1375 if (defined(invoker.shared_resources) && invoker.shared_resources) {
1376 args += [ "--shared-resources" ]
1377 }
1378
1379 if (defined(invoker.include_all_resources) &&
1380 invoker.include_all_resources) {
1381 args += [ "--include-all-resources" ]
1382 }
1383
1384 if (defined(invoker.all_resources_zip_path)) {
1385 all_resources_zip = invoker.all_resources_zip_path
1386 outputs += [ all_resources_zip ]
1387 args += [
1388 "--all-resources-zip-out",
1389 rebase_path(all_resources_zip, root_build_dir),
1390 ]
1391 }
1392
1393 if (defined(invoker.args)) {
1394 args += invoker.args
1395 }
1396 if (defined(invoker.deps)) {
1397 deps = invoker.deps
1398 }
1399 }
1400 }
1401
1402 template("copy_ex") {
1403 set_sources_assignment_filter([])
1404 if (defined(invoker.testonly)) {
1405 testonly = invoker.testonly
1406 }
1407
1408 action(target_name) {
1409 if (defined(invoker.visibility)) {
1410 visibility = invoker.visibility
1411 }
1412
1413 script = "//build/android/gyp/copy_ex.py"
1414
1415 if (defined(invoker.deps)) {
1416 deps = invoker.deps
1417 }
1418
1419 sources = []
1420 if (defined(invoker.sources)) {
1421 sources += invoker.sources
1422 }
1423
1424 inputs = []
1425 if (defined(invoker.inputs)) {
1426 inputs += invoker.inputs
1427 }
1428
1429 depfile = "$target_gen_dir/$target_name.d"
1430 outputs = [
1431 depfile,
1432 ]
1433
1434 args = [
1435 "--depfile",
1436 rebase_path(depfile, root_build_dir),
1437 "--dest",
1438 rebase_path(invoker.dest, root_build_dir),
1439 ]
1440 rebased_sources = rebase_path(sources, root_build_dir)
1441 args += [ "--files=$rebased_sources" ]
1442
1443 if (defined(invoker.clear_dir) && invoker.clear_dir) {
1444 args += [ "--clear" ]
1445 }
1446
1447 if (defined(invoker.args)) {
1448 args += invoker.args
1449 }
1450 }
1451 }
1452
1453 # Produces a single .dex.jar out of a set of Java dependencies.
1454 template("deps_dex") {
1455 set_sources_assignment_filter([])
1456 build_config = "$target_gen_dir/${target_name}.build_config"
1457 build_config_target_name = "${target_name}__build_config"
1458
1459 write_build_config(build_config_target_name) {
1460 type = "deps_dex"
1461 deps = invoker.deps
1462
1463 build_config = build_config
1464 dex_path = invoker.dex_path
1465 }
1466
1467 rebased_build_config = rebase_path(build_config, root_build_dir)
1468 dex(target_name) {
1469 inputs = [
1470 build_config,
1471 ]
1472 output = invoker.dex_path
1473 dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files"
1474 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1475 if (defined(invoker.excluded_jars)) {
1476 excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir)
1477 args += [ "--excluded-paths=${excluded_jars}" ]
1478 }
1479 deps = [
1480 ":$build_config_target_name",
1481 ]
1482 }
1483 }
1484
1485 # Creates an AndroidManifest.xml for an APK split.
1486 template("generate_split_manifest") {
1487 assert(defined(invoker.main_manifest))
1488 assert(defined(invoker.out_manifest))
1489 assert(defined(invoker.split_name))
1490
1491 action(target_name) {
1492 depfile = "$target_gen_dir/$target_name.d"
1493 if (defined(invoker.deps)) {
1494 deps = invoker.deps
1495 }
1496 args = [
1497 "--main-manifest",
1498 rebase_path(invoker.main_manifest, root_build_dir),
1499 "--out-manifest",
1500 rebase_path(invoker.out_manifest, root_build_dir),
1501 "--split",
1502 invoker.split_name,
1503 ]
1504 if (defined(invoker.version_code)) {
1505 args += [
1506 "--version-code",
1507 invoker.version_code,
1508 ]
1509 }
1510 if (defined(invoker.version_name)) {
1511 args += [
1512 "--version-name",
1513 invoker.version_name,
1514 ]
1515 }
1516 if (defined(invoker.has_code)) {
1517 args += [
1518 "--has-code",
1519 invoker.has_code,
1520 ]
1521 }
1522 args += [
1523 "--depfile",
1524 rebase_path(depfile, root_build_dir),
1525 ]
1526
1527 script = "//build/android/gyp/generate_split_manifest.py"
1528 outputs = [
1529 depfile,
1530 invoker.out_manifest,
1531 ]
1532 inputs = [
1533 invoker.main_manifest,
1534 ]
1535 }
1536 }
1537
1538 # Generates a script in the output bin directory which runs the test
1539 # target using the test runner script in build/android/test_runner.py.
1540 template("test_runner_script") {
1541 testonly = true
1542 _test_name = invoker.test_name
1543 _test_type = invoker.test_type
1544
1545 action(target_name) {
1546 script = "//build/android/gyp/create_test_runner_script.py"
1547 depfile = "$target_gen_dir/$target_name.d"
1548
1549 test_runner_args = [
1550 _test_type,
1551 "--output-directory",
1552 rebase_path(root_build_dir, root_build_dir),
1553 ]
1554 if (_test_type == "gtest") {
1555 assert(defined(invoker.test_suite))
1556 test_runner_args += [
1557 "--suite",
1558 invoker.test_suite,
1559 ]
1560 } else if (_test_type == "instrumentation") {
1561 assert(defined(invoker.test_apk))
1562 test_runner_args += [
1563 "--test-apk",
1564 invoker.test_apk,
1565 ]
1566 if (defined(invoker.support_apk_path)) {
1567 test_runner_args += [
1568 "--support-apk",
1569 rebase_path(invoker.support_apk_path, root_build_dir),
1570 ]
1571 }
1572 } else {
1573 assert(false, "Invalid test type: $_test_type.")
1574 }
1575
1576 if (defined(invoker.isolate_file)) {
1577 test_runner_args += [
1578 "--isolate-file-path",
1579 rebase_path(invoker.isolate_file, root_build_dir),
1580 ]
1581 }
1582
1583 generated_script = "$root_build_dir/bin/run_${_test_name}"
1584 outputs = [
1585 depfile,
1586 generated_script,
1587 ]
1588 args = [
1589 "--depfile",
1590 rebase_path(depfile, root_build_dir),
1591 "--script-output-path",
1592 rebase_path(generated_script, root_build_dir),
1593 ]
1594 args += test_runner_args
1595 }
1596 }
OLDNEW
« no previous file with comments | « build/config/android/config.gni ('k') | build/config/android/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698