OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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("//build/config/android/config.gni") | 5 import("//build/config/android/config.gni") |
6 | 6 |
7 assert(is_android) | 7 assert(is_android) |
8 | 8 |
9 | 9 |
10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) | 10 rebased_android_sdk = rebase_path(android_sdk, root_build_dir) |
11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) | 11 rebased_android_sdk_root = rebase_path(android_sdk_root, root_build_dir) |
12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil
d_dir) | 12 rebased_android_sdk_build_tools = rebase_path(android_sdk_build_tools, root_buil
d_dir) |
13 | 13 |
14 android_sdk_jar = "$android_sdk/android.jar" | 14 android_sdk_jar = "$android_sdk/android.jar" |
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) | 15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir) |
16 | 16 |
17 template("android_lint") { | 17 template("android_lint") { |
| 18 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 19 |
18 jar_path = invoker.jar_path | 20 jar_path = invoker.jar_path |
19 android_manifest = invoker.android_manifest | 21 android_manifest = invoker.android_manifest |
20 java_files = invoker.java_files | 22 java_files = invoker.java_files |
21 base_path = "$target_gen_dir/$target_name" | 23 base_path = "$target_gen_dir/$target_name" |
22 | 24 |
23 action(target_name) { | 25 action(target_name) { |
24 script = "//build/android/gyp/lint.py" | 26 script = "//build/android/gyp/lint.py" |
25 result_path = base_path + "/result.xml" | 27 result_path = base_path + "/result.xml" |
26 config_path = base_path + "/config.xml" | 28 config_path = base_path + "/config.xml" |
27 suppressions_file = "//build/android/lint/suppressions.xml" | 29 suppressions_file = "//build/android/lint/suppressions.xml" |
(...skipping 28 matching lines...) Expand all Loading... |
56 # Write the target's .build_config file. This is a json file that contains a | 58 # Write the target's .build_config file. This is a json file that contains a |
57 # dictionary of information about how to build this target (things that | 59 # dictionary of information about how to build this target (things that |
58 # require knowledge about this target's dependencies and cannot be calculated | 60 # require knowledge about this target's dependencies and cannot be calculated |
59 # at gn-time). There is a special syntax to add a value in that dictionary to | 61 # at gn-time). There is a special syntax to add a value in that dictionary to |
60 # an action/action_foreachs args: | 62 # an action/action_foreachs args: |
61 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 63 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) |
62 # At runtime, such an arg will be replaced by the value in the build_config. | 64 # At runtime, such an arg will be replaced by the value in the build_config. |
63 # See build/android/gyp/write_build_config.py and | 65 # See build/android/gyp/write_build_config.py and |
64 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 66 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
65 template("write_build_config") { | 67 template("write_build_config") { |
| 68 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 69 |
66 assert(defined(invoker.type)) | 70 assert(defined(invoker.type)) |
67 assert(defined(invoker.build_config)) | 71 assert(defined(invoker.build_config)) |
68 | 72 |
69 type = invoker.type | 73 type = invoker.type |
70 build_config = invoker.build_config | 74 build_config = invoker.build_config |
71 | 75 |
72 assert(type == "android_apk" || type == "android_library" || type == "android_
resources") | 76 assert(type == "android_apk" || type == "android_library" || type == "android_
resources") |
73 | 77 |
74 action(target_name) { | 78 action(target_name) { |
75 script = "//build/android/gyp/write_build_config.py" | 79 script = "//build/android/gyp/write_build_config.py" |
76 depfile = "$target_gen_dir/$target_name.d" | 80 depfile = "$target_gen_dir/$target_name.d" |
77 inputs = [] | 81 inputs = [] |
78 | 82 |
79 deps = [] | 83 deps = [] |
80 if (defined(invoker.deps)) { | 84 if (defined(invoker.deps)) { |
81 deps += invoker.deps | 85 deps += invoker.deps |
82 } | 86 } |
83 if (defined(invoker.testonly)) { | |
84 testonly = invoker.testonly | |
85 } | |
86 | 87 |
87 outputs = [ | 88 outputs = [ |
88 depfile, | 89 depfile, |
89 build_config | 90 build_config |
90 ] | 91 ] |
91 | 92 |
92 possible_deps_configs = [] | 93 possible_deps_configs = [] |
93 foreach(d, deps) { | 94 foreach(d, deps) { |
94 dep_gen_dir = get_label_info(d, "target_gen_dir") | 95 dep_gen_dir = get_label_info(d, "target_gen_dir") |
95 dep_name = get_label_info(d, "name") | 96 dep_name = get_label_info(d, "name") |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) | 148 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) |
148 ] | 149 ] |
149 } | 150 } |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
153 | 154 |
154 # Creates a zip archive of the inputs. | 155 # Creates a zip archive of the inputs. |
155 # If base_dir is provided, the archive paths will be relative to it. | 156 # If base_dir is provided, the archive paths will be relative to it. |
156 template("zip") { | 157 template("zip") { |
| 158 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 159 |
157 assert(defined(invoker.inputs)) | 160 assert(defined(invoker.inputs)) |
158 assert(defined(invoker.output)) | 161 assert(defined(invoker.output)) |
159 | 162 |
160 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) | 163 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) |
161 rebase_output = rebase_path(invoker.output, root_build_dir) | 164 rebase_output = rebase_path(invoker.output, root_build_dir) |
162 action(target_name) { | 165 action(target_name) { |
163 script = "//build/android/gn/zip.py" | 166 script = "//build/android/gn/zip.py" |
164 depfile = "$target_gen_dir/$target_name.d" | 167 depfile = "$target_gen_dir/$target_name.d" |
165 inputs = invoker.inputs | 168 inputs = invoker.inputs |
166 outputs = [ | 169 outputs = [ |
167 depfile, | 170 depfile, |
168 invoker.output | 171 invoker.output |
169 ] | 172 ] |
170 args = [ | 173 args = [ |
171 "--depfile", rebase_path(depfile, root_build_dir), | 174 "--depfile", rebase_path(depfile, root_build_dir), |
172 "--inputs=$rebase_inputs", | 175 "--inputs=$rebase_inputs", |
173 "--output=$rebase_output", | 176 "--output=$rebase_output", |
174 ] | 177 ] |
175 if (defined(invoker.base_dir)) { | 178 if (defined(invoker.base_dir)) { |
176 args += [ | 179 args += [ |
177 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) | 180 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) |
178 ] | 181 ] |
179 } | 182 } |
180 } | 183 } |
181 } | 184 } |
182 | 185 |
183 template("dex") { | 186 template("dex") { |
| 187 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 188 |
184 assert(defined(invoker.sources)) | 189 assert(defined(invoker.sources)) |
185 assert(defined(invoker.output)) | 190 assert(defined(invoker.output)) |
186 action(target_name) { | 191 action(target_name) { |
187 script = "//build/android/gyp/dex.py" | 192 script = "//build/android/gyp/dex.py" |
188 depfile = "$target_gen_dir/$target_name.d" | 193 depfile = "$target_gen_dir/$target_name.d" |
189 sources = invoker.sources | 194 sources = invoker.sources |
190 outputs = [depfile, invoker.output] | 195 outputs = [depfile, invoker.output] |
191 if (defined(invoker.inputs)) { | 196 if (defined(invoker.inputs)) { |
192 inputs = invoker.inputs | 197 inputs = invoker.inputs |
193 } | 198 } |
(...skipping 20 matching lines...) Expand all Loading... |
214 args += invoker.args | 219 args += invoker.args |
215 } | 220 } |
216 | 221 |
217 args += rebase_path(invoker.sources, root_build_dir) | 222 args += rebase_path(invoker.sources, root_build_dir) |
218 } | 223 } |
219 } | 224 } |
220 | 225 |
221 # Packages resources, assets, dex, and native libraries into an apk. Signs and | 226 # Packages resources, assets, dex, and native libraries into an apk. Signs and |
222 # zipaligns the apk. | 227 # zipaligns the apk. |
223 template("create_apk") { | 228 template("create_apk") { |
| 229 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 230 |
224 _android_manifest = invoker.android_manifest | 231 _android_manifest = invoker.android_manifest |
225 _base_path = invoker.base_path | 232 _base_path = invoker.base_path |
226 _final_apk_path = invoker.apk_path | 233 _final_apk_path = invoker.apk_path |
227 _resources_zip = invoker.resources_zip | 234 _resources_zip = invoker.resources_zip |
228 _dex_path = invoker.dex_path | 235 _dex_path = invoker.dex_path |
229 _keystore_path = invoker.keystore_path | 236 _keystore_path = invoker.keystore_path |
230 _keystore_name = invoker.keystore_name | 237 _keystore_name = invoker.keystore_name |
231 _keystore_password = invoker.keystore_password | 238 _keystore_password = invoker.keystore_password |
232 | 239 |
233 _deps = [] | 240 _deps = [] |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 "--key-passwd", _keystore_password, | 357 "--key-passwd", _keystore_password, |
351 ] | 358 ] |
352 } | 359 } |
353 | 360 |
354 group(target_name) { | 361 group(target_name) { |
355 deps = [":${target_name}__finalize"] | 362 deps = [":${target_name}__finalize"] |
356 } | 363 } |
357 } | 364 } |
358 | 365 |
359 template("java_prebuilt") { | 366 template("java_prebuilt") { |
| 367 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 368 |
360 _input_jar_path = invoker.input_jar_path | 369 _input_jar_path = invoker.input_jar_path |
361 _output_jar_path = invoker.output_jar_path | 370 _output_jar_path = invoker.output_jar_path |
362 _jar_toc_path = _output_jar_path + ".TOC" | 371 _jar_toc_path = _output_jar_path + ".TOC" |
363 | 372 |
364 assert(invoker.build_config != "") | 373 assert(invoker.build_config != "") |
365 | 374 |
366 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { | 375 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) { |
367 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" | 376 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar" |
368 _proguard_config_path = invoker.proguard_config | 377 _proguard_config_path = invoker.proguard_config |
369 _build_config = invoker.build_config | 378 _build_config = invoker.build_config |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 # Variables | 440 # Variables |
432 # java_files: List of .java files to compile. | 441 # java_files: List of .java files to compile. |
433 # java_deps: List of java dependencies. These should all have a .jar output | 442 # java_deps: List of java dependencies. These should all have a .jar output |
434 # at "${target_gen_dir}/${target_name}.jar. | 443 # at "${target_gen_dir}/${target_name}.jar. |
435 # chromium_code: If true, enable extra warnings. | 444 # chromium_code: If true, enable extra warnings. |
436 # srcjar_deps: List of srcjar dependencies. The .java files contained in the | 445 # srcjar_deps: List of srcjar dependencies. The .java files contained in the |
437 # dependencies srcjar outputs will be compiled and added to the output jar. | 446 # dependencies srcjar outputs will be compiled and added to the output jar. |
438 # jar_path: Use this to explicitly set the output jar path. Defaults to | 447 # jar_path: Use this to explicitly set the output jar path. Defaults to |
439 # "${target_gen_dir}/${target_name}.jar. | 448 # "${target_gen_dir}/${target_name}.jar. |
440 template("java_library") { | 449 template("java_library") { |
| 450 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 451 |
441 assert(defined(invoker.java_files)) | 452 assert(defined(invoker.java_files)) |
442 assert(defined(invoker.build_config)) | 453 assert(defined(invoker.build_config)) |
443 assert(defined(invoker.jar_path)) | 454 assert(defined(invoker.jar_path)) |
444 | 455 |
445 _java_files = invoker.java_files | 456 _java_files = invoker.java_files |
446 _final_jar_path = invoker.jar_path | 457 _final_jar_path = invoker.jar_path |
447 _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar" | 458 _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar" |
448 | 459 |
449 _build_config = invoker.build_config | 460 _build_config = invoker.build_config |
450 | 461 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 ] | 533 ] |
523 } | 534 } |
524 } | 535 } |
525 | 536 |
526 | 537 |
527 # This adds Android-specific parts to the java_library template. | 538 # This adds Android-specific parts to the java_library template. |
528 # | 539 # |
529 # Runs Android lint against the compiled java files. | 540 # Runs Android lint against the compiled java files. |
530 # Dexes the output jar for inclusion in an APK. | 541 # Dexes the output jar for inclusion in an APK. |
531 template("android_java_library") { | 542 template("android_java_library") { |
| 543 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 544 |
532 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)) | 545 assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)) |
533 assert(defined(invoker.build_config)) | 546 assert(defined(invoker.build_config)) |
534 assert(defined(invoker.jar_path)) | 547 assert(defined(invoker.jar_path)) |
535 assert(defined(invoker.dex_path)) | 548 assert(defined(invoker.dex_path)) |
536 | 549 |
537 _srcjar_deps = [] | 550 _srcjar_deps = [] |
538 if (defined(invoker.srcjar_deps)) { | 551 if (defined(invoker.srcjar_deps)) { |
539 _srcjar_deps = invoker.srcjar_deps | 552 _srcjar_deps = invoker.srcjar_deps |
540 } | 553 } |
541 | 554 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 group(target_name) { | 617 group(target_name) { |
605 deps = [ | 618 deps = [ |
606 ":${target_name}__java_library", | 619 ":${target_name}__java_library", |
607 ":${target_name}__dex", | 620 ":${target_name}__dex", |
608 ] + _final_deps + _final_datadeps | 621 ] + _final_deps + _final_datadeps |
609 } | 622 } |
610 } | 623 } |
611 | 624 |
612 # Runs process_resources.py | 625 # Runs process_resources.py |
613 template("process_resources") { | 626 template("process_resources") { |
| 627 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 628 |
614 zip_path = invoker.zip_path | 629 zip_path = invoker.zip_path |
615 srcjar_path = invoker.srcjar_path | 630 srcjar_path = invoker.srcjar_path |
616 build_config = invoker.build_config | 631 build_config = invoker.build_config |
617 resource_dirs = invoker.resource_dirs | 632 resource_dirs = invoker.resource_dirs |
618 android_manifest = invoker.android_manifest | 633 android_manifest = invoker.android_manifest |
619 | 634 |
620 non_constant_id = true | 635 non_constant_id = true |
621 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { | 636 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { |
622 non_constant_id = false | 637 non_constant_id = false |
623 } | 638 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 ] | 697 ] |
683 } | 698 } |
684 | 699 |
685 if (defined(invoker.args)) { | 700 if (defined(invoker.args)) { |
686 args += invoker.args | 701 args += invoker.args |
687 } | 702 } |
688 } | 703 } |
689 } | 704 } |
690 | 705 |
691 template("copy_ex") { | 706 template("copy_ex") { |
| 707 if (defined(invoker.testonly)) { testonly = invoker.testonly } |
| 708 |
692 action(target_name) { | 709 action(target_name) { |
693 script = "//build/android/gyp/copy_ex.py" | 710 script = "//build/android/gyp/copy_ex.py" |
694 depfile = "$target_gen_dir/$target_name.d" | 711 depfile = "$target_gen_dir/$target_name.d" |
695 outputs = [ | 712 outputs = [ |
696 depfile, | 713 depfile, |
697 ] | 714 ] |
| 715 sources = [] |
| 716 if (defined(invoker.sources)) { |
| 717 sources += invoker.sources |
| 718 } |
698 | 719 |
699 inputs = [] | 720 inputs = [] |
700 if (defined(invoker.inputs)) { | 721 if (defined(invoker.inputs)) { |
701 inputs += invoker.inputs | 722 inputs += invoker.inputs |
702 } | 723 } |
703 | 724 |
704 args = [ | 725 args = [ |
705 "--depfile", rebase_path(depfile, root_build_dir), | 726 "--depfile", rebase_path(depfile, root_build_dir), |
706 "--dest", rebase_path(invoker.dest, root_build_dir), | 727 "--dest", rebase_path(invoker.dest, root_build_dir), |
707 ] | 728 ] |
708 if (defined(invoker.args)) { | 729 if (defined(invoker.args)) { |
709 args += invoker.args | 730 args += invoker.args |
710 } | 731 } |
| 732 rebased_sources = rebase_path(sources, root_build_dir) |
| 733 args += [ "--files=$rebased_sources" ] |
| 734 |
711 if (defined(invoker.clear_dir) && invoker.clear_dir) { | 735 if (defined(invoker.clear_dir) && invoker.clear_dir) { |
712 args += ["--clear"] | 736 args += ["--clear"] |
713 } | 737 } |
714 } | 738 } |
715 } | 739 } |
OLD | NEW |