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.
5 import("//build/config/android/config.gni")
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)
14 android_sdk_jar = "$android_sdk/android.jar"
15 rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
17 template("android_lint") {
18 set_sources_assignment_filter([])
19 if (defined(invoker.testonly)) {
20 testonly = invoker.testonly
23 jar_path = invoker.jar_path
24 android_manifest = invoker.android_manifest
25 java_files = invoker.java_files
26 base_path = "$target_gen_dir/$target_name"
29 script = "//build/android/gyp/lint.py"
30 result_path = base_path + "/result.xml"
31 config_path = base_path + "/config.xml"
32 suppressions_file = "//build/android/lint/suppressions.xml"
44 rebased_java_files = rebase_path(java_files, root_build_dir)
47 "--lint-path=$rebased_android_sdk_root/tools/lint",
49 rebase_path(suppressions_file, root_build_dir),
51 rebase_path(android_manifest, root_build_dir),
54 rebase_path(jar_path, root_build_dir),
55 "--processed-config-path",
56 rebase_path(config_path, root_build_dir),
58 rebase_path(result_path, root_build_dir),
59 "--java-files=$rebased_java_files",
65 template("findbugs") {
66 jar_path = invoker.jar_path
68 build_config = invoker.build_config
71 script = "//build/android/findbugs_diff.py"
72 depfile = "$target_gen_dir/$target_name.d"
73 result_path = "$target_gen_dir/$target_name/result.xml"
74 exclusions_file = "//build/android/findbugs_filter/findbugs_exclude.xml"
76 rebased_build_config = rebase_path(build_config, root_build_dir)
79 "//build/android/pylib/utils/findbugs.py",
91 rebase_path(depfile, root_build_dir),
93 rebase_path(exclusions_file, root_build_dir),
95 "@FileArg($rebased_build_config:javac:classpath)",
97 rebase_path(result_path, root_build_dir),
98 rebase_path(jar_path, root_build_dir),
104 set_sources_assignment_filter([])
105 if (defined(invoker.testonly)) {
106 testonly = invoker.testonly
109 assert(defined(invoker.output))
110 action(target_name) {
111 script = "//build/android/gyp/dex.py"
112 depfile = "$target_gen_dir/$target_name.d"
113 if (defined(invoker.sources)) {
114 sources = invoker.sources
120 if (defined(invoker.inputs)) {
121 inputs = invoker.inputs
124 if (defined(invoker.deps)) {
128 rebased_output = rebase_path(invoker.output, root_build_dir)
132 rebase_path(depfile, root_build_dir),
133 "--android-sdk-tools",
134 rebased_android_sdk_build_tools,
139 if (defined(invoker.no_locals) && invoker.no_locals) {
140 args += [ "--no-locals=1" ]
143 if (defined(invoker.args)) {
147 if (defined(invoker.sources)) {
148 args += rebase_path(invoker.sources, root_build_dir)
153 # Creates a zip archive of the inputs.
154 # If base_dir is provided, the archive paths will be relative to it.
156 set_sources_assignment_filter([])
157 if (defined(invoker.testonly)) {
158 testonly = invoker.testonly
161 assert(defined(invoker.inputs))
162 assert(defined(invoker.output))
164 rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
165 rebase_output = rebase_path(invoker.output, root_build_dir)
166 action(target_name) {
167 script = "//build/android/gn/zip.py"
168 depfile = "$target_gen_dir/$target_name.d"
169 inputs = invoker.inputs
176 rebase_path(depfile, root_build_dir),
177 "--inputs=$rebase_inputs",
178 "--output=$rebase_output",
180 if (defined(invoker.base_dir)) {
183 rebase_path(invoker.base_dir, root_build_dir),
189 # Write the target's .build_config file. This is a json file that contains a
190 # dictionary of information about how to build this target (things that
191 # require knowledge about this target's dependencies and cannot be calculated
192 # at gn-time). There is a special syntax to add a value in that dictionary to
193 # an action/action_foreachs args:
194 # --python-arg=@FileArg($rebased_build_config_path:key0:key1)
195 # At runtime, such an arg will be replaced by the value in the build_config.
196 # See build/android/gyp/write_build_config.py and
197 # build/android/gyp/util/build_utils.py:ExpandFileArgs
198 template("write_build_config") {
199 set_sources_assignment_filter([])
200 if (defined(invoker.testonly)) {
201 testonly = invoker.testonly
204 assert(defined(invoker.type))
205 assert(defined(invoker.build_config))
208 build_config = invoker.build_config
210 assert(type == "android_apk" || type == "java_library" ||
211 type == "android_resources" || type == "deps_dex")
213 action(target_name) {
214 script = "//build/android/gyp/write_build_config.py"
215 depfile = "$target_gen_dir/$target_name.d"
219 if (defined(invoker.deps)) {
223 possible_deps_configs = []
225 dep_gen_dir = get_label_info(d, "target_gen_dir")
226 dep_name = get_label_info(d, "name")
227 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ]
229 rebase_possible_deps_configs = rebase_path(possible_deps_configs)
240 rebase_path(depfile, root_build_dir),
241 "--possible-deps-configs=$rebase_possible_deps_configs",
243 rebase_path(build_config, root_build_dir),
246 is_java_library = type == "java_library"
247 is_apk = type == "android_apk"
248 is_android_resources = type == "android_resources"
249 is_deps_dex = type == "deps_dex"
251 supports_android = is_apk || is_android_resources || is_deps_dex ||
252 (is_java_library && defined(invoker.supports_android) &&
253 invoker.supports_android)
254 requires_android = is_apk || is_android_resources || is_deps_dex ||
255 (is_java_library && defined(invoker.requires_android) &&
256 invoker.requires_android)
258 assert(!requires_android || supports_android,
259 "requires_android requires" + " supports_android")
261 # Mark these variables as used.
262 assert(is_java_library || true)
263 assert(is_apk || true)
264 assert(is_android_resources || true)
265 assert(is_deps_dex || true)
267 if (is_java_library || is_apk) {
270 rebase_path(invoker.jar_path, root_build_dir),
274 if (is_apk || is_deps_dex || (is_java_library && supports_android)) {
277 rebase_path(invoker.dex_path, root_build_dir),
280 if (supports_android) {
281 args += [ "--supports-android" ]
283 if (requires_android) {
284 args += [ "--requires-android" ]
286 if (defined(invoker.bypass_platform_checks) &&
287 invoker.bypass_platform_checks) {
288 args += [ "--bypass-platform-checks" ]
291 if (is_android_resources || is_apk) {
292 assert(defined(invoker.resources_zip))
295 rebase_path(invoker.resources_zip, root_build_dir),
297 if (defined(invoker.android_manifest)) {
298 inputs += [ invoker.android_manifest ]
300 "--android-manifest",
301 rebase_path(invoker.android_manifest, root_build_dir),
304 if (defined(invoker.custom_package)) {
307 invoker.custom_package,
313 if (defined(invoker.native_libs)) {
314 inputs += invoker.native_libs
315 rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir)
316 rebased_android_readelf = rebase_path(android_readelf, root_build_dir)
318 "--native-libs=$rebased_native_libs",
319 "--readelf-path=$rebased_android_readelf",
324 if (defined(invoker.srcjar)) {
327 rebase_path(invoker.srcjar, root_build_dir),
333 template("process_java_prebuilt") {
334 set_sources_assignment_filter([])
335 if (defined(invoker.testonly)) {
336 testonly = invoker.testonly
339 _input_jar_path = invoker.input_jar_path
340 _output_jar_path = invoker.output_jar_path
341 _jar_toc_path = _output_jar_path + ".TOC"
343 assert(invoker.build_config != "")
345 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
346 _proguard_jar_path = "$android_sdk_root/tools/proguard/lib/proguard.jar"
347 _proguard_config_path = invoker.proguard_config
348 _build_config = invoker.build_config
349 _rebased_build_config = rebase_path(_build_config, root_build_dir)
350 action("${target_name}__proguard_process") {
351 script = "//build/android/gyp/proguard.py"
357 _proguard_config_path,
359 depfile = "${target_gen_dir}/${target_name}.d"
366 rebase_path(depfile, root_build_dir),
368 rebase_path(_proguard_jar_path, root_build_dir),
370 rebase_path(_input_jar_path, root_build_dir),
372 rebase_path(_output_jar_path, root_build_dir),
374 rebase_path(_proguard_config_path, root_build_dir),
376 rebased_android_sdk_jar,
377 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
381 copy("${target_name}__copy_jar") {
391 action("${target_name}__jar_toc") {
392 script = "//build/android/gyp/jar_toc.py"
393 depfile = "$target_gen_dir/$target_name.d"
397 _jar_toc_path + ".md5.stamp",
404 rebase_path(depfile, root_build_dir),
406 rebase_path(_output_jar_path, root_build_dir),
408 rebase_path(_jar_toc_path, root_build_dir),
414 ":${target_name}__jar_toc",
419 # Packages resources, assets, dex, and native libraries into an apk. Signs and
421 template("create_apk") {
422 set_sources_assignment_filter([])
423 if (defined(invoker.testonly)) {
424 testonly = invoker.testonly
427 _android_manifest = invoker.android_manifest
428 _base_path = invoker.base_path
429 _final_apk_path = invoker.apk_path
430 _resources_zip = invoker.resources_zip
431 _dex_path = invoker.dex_path
432 _keystore_path = invoker.keystore_path
433 _keystore_name = invoker.keystore_name
434 _keystore_password = invoker.keystore_password
435 _load_library_from_apk = invoker.load_library_from_apk
438 if (defined(invoker.deps)) {
442 _native_libs_dir = "//build/android/empty/res"
443 if (defined(invoker.native_libs_dir)) {
444 _native_libs_dir = invoker.native_libs_dir
447 _asset_location = "//build/android/empty/res"
448 if (defined(invoker.asset_location)) {
449 _asset_location = invoker.asset_location
452 _version_code = invoker.version_code
453 _version_name = invoker.version_name
455 _base_apk_path = _base_path + ".apk_intermediates"
457 _resource_packaged_apk_path = _base_apk_path + ".ap_"
458 _packaged_apk_path = _base_apk_path + ".unfinished.apk"
460 defined(invoker.shared_resources) && invoker.shared_resources
462 _configuration_name = "Release"
464 _configuration_name = "Debug"
467 action("${target_name}__package_resources") {
470 script = "//build/android/gyp/package_resources.py"
471 depfile = "${target_gen_dir}/${target_name}.d"
478 _resource_packaged_apk_path,
481 _rebased_resources_zips = [ rebase_path(_resources_zip, root_build_dir) ]
484 rebase_path(depfile, root_build_dir),
487 "--android-sdk-tools",
488 rebased_android_sdk_build_tools,
489 "--configuration-name=$_configuration_name",
490 "--android-manifest",
491 rebase_path(_android_manifest, root_build_dir),
497 rebase_path(_asset_location, root_build_dir),
498 "--resource-zips=$_rebased_resources_zips",
500 rebase_path(_resource_packaged_apk_path, root_build_dir),
503 if (_shared_resources) {
504 args += [ "--shared-resources" ]
508 action("${target_name}__package") {
509 script = "//build/android/gyp/ant.py"
510 _ant_script = "//build/android/ant/apk-package.xml"
512 depfile = "$target_gen_dir/$target_name.d"
516 _resource_packaged_apk_path,
525 _rebased_emma_jar = ""
526 _rebased_resource_packaged_apk_path =
527 rebase_path(_resource_packaged_apk_path, root_build_dir)
528 _rebased_packaged_apk_path = rebase_path(_packaged_apk_path, root_build_dir)
529 _rebased_native_libs_dir = rebase_path(_native_libs_dir, root_build_dir)
530 _rebased_dex_path = rebase_path(_dex_path, root_build_dir)
533 rebase_path(depfile, root_build_dir),
536 "-DANDROID_SDK_ROOT=$rebased_android_sdk_root",
537 "-DANDROID_SDK_TOOLS=$rebased_android_sdk_build_tools",
538 "-DRESOURCE_PACKAGED_APK_NAME=$_rebased_resource_packaged_apk_path",
539 "-DCONFIGURATION_NAME=$_configuration_name",
540 "-DNATIVE_LIBS_DIR=$_rebased_native_libs_dir",
542 "-DUNSIGNED_APK_PATH=$_rebased_packaged_apk_path",
543 "-DEMMA_INSTRUMENT=0",
544 "-DEMMA_DEVICE_JAR=$_rebased_emma_jar",
545 "-DDEX_FILE_PATH=$_rebased_dex_path",
548 rebase_path(_ant_script, root_build_dir),
552 action("${target_name}__finalize") {
553 script = "//build/android/gyp/finalize_apk.py"
554 depfile = "$target_gen_dir/$target_name.d"
569 rebase_path(depfile, root_build_dir),
571 rebase_path(zipalign_path, root_build_dir),
572 "--unsigned-apk-path",
573 rebase_path(_packaged_apk_path, root_build_dir),
575 rebase_path(_final_apk_path, root_build_dir),
577 rebase_path(_keystore_path, root_build_dir),
583 if (_load_library_from_apk) {
584 _rezip_jar_path = "$root_build_dir/lib.java/rezip_apk.jar"
585 inputs += [ _rezip_jar_path ]
587 "--load-library-from-zip-file=1",
588 "--rezip-apk-jar-path",
589 rebase_path(_rezip_jar_path, root_build_dir),
596 ":${target_name}__finalize",
601 template("java_prebuilt_impl") {
602 set_sources_assignment_filter([])
603 if (defined(invoker.testonly)) {
604 testonly = invoker.testonly
607 defined(invoker.supports_android) && invoker.supports_android
609 assert(defined(invoker.jar_path))
610 _base_path = "${target_gen_dir}/$target_name"
611 _jar_path = _base_path + ".jar"
612 _build_config = _base_path + ".build_config"
614 if (_supports_android) {
615 _dex_path = _base_path + ".dex.jar"
619 _template_name = target_name
621 _final_deps += [ ":${_template_name}__build_config" ]
622 write_build_config("${_template_name}__build_config") {
623 type = "java_library"
624 supports_android = _supports_android
626 defined(invoker.requires_android) && invoker.requires_android
629 if (defined(invoker.deps)) {
632 build_config = _build_config
634 if (_supports_android) {
639 _final_deps += [ ":${_template_name}__process_jar" ]
640 process_java_prebuilt("${_template_name}__process_jar") {
641 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
642 proguard_preprocess = true
643 proguard_config = invoker.proguard_config
646 build_config = _build_config
647 input_jar_path = invoker.jar_path
648 output_jar_path = _jar_path
651 if (_supports_android) {
652 _final_deps += [ ":${_template_name}__dex" ]
653 dex("${_template_name}__dex") {
666 # Compiles and jars a set of java files.
673 # java_files: List of .java files to compile.
674 # java_deps: List of java dependencies. These should all have a .jar output
675 # at "${target_gen_dir}/${target_name}.jar.
676 # chromium_code: If true, enable extra warnings.
677 # srcjar_deps: List of srcjar dependencies. The .java files contained in the
678 # dependencies srcjar outputs will be compiled and added to the output jar.
679 # jar_path: Use this to explicitly set the output jar path. Defaults to
680 # "${target_gen_dir}/${target_name}.jar.
681 template("compile_java") {
682 set_sources_assignment_filter([])
683 if (defined(invoker.testonly)) {
684 testonly = invoker.testonly
687 assert(defined(invoker.java_files))
688 assert(defined(invoker.build_config))
689 assert(defined(invoker.jar_path))
691 _java_files = invoker.java_files
692 _final_jar_path = invoker.jar_path
693 _intermediate_jar_path = "$target_gen_dir/$target_name.initial.jar"
695 _build_config = invoker.build_config
697 _jar_excluded_patterns = []
698 if (defined(invoker.jar_excluded_patterns)) {
699 _jar_excluded_patterns += invoker.jar_excluded_patterns
702 _chromium_code = false
703 if (defined(invoker.chromium_code)) {
704 _chromium_code = invoker.chromium_code
706 _manifest_entries = []
707 if (defined(invoker.manifest_entries)) {
708 _manifest_entries = invoker.manifest_entries
712 if (defined(invoker.srcjar_deps)) {
713 _srcjar_deps += invoker.srcjar_deps
717 if (defined(invoker.srcjars)) {
718 _java_srcjars = invoker.srcjars
720 foreach(dep, _srcjar_deps) {
721 _dep_gen_dir = get_label_info(dep, "target_gen_dir")
722 _dep_name = get_label_info(dep, "name")
723 _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
726 # Mark srcjar_deps as used.
727 assert(_srcjar_deps == [] || true)
730 if (defined(invoker.android) && invoker.android) {
731 _system_jars += [ android_sdk_jar ]
734 _rebased_build_config = rebase_path(_build_config, root_build_dir)
735 _rebased_jar_path = rebase_path(_intermediate_jar_path, root_build_dir)
737 _template_name = target_name
738 _final_deps = [ ":${_template_name}__javac" ]
739 action("${_template_name}__javac") {
740 script = "//build/android/gyp/javac.py"
741 depfile = "$target_gen_dir/$target_name.d"
745 _intermediate_jar_path,
746 _intermediate_jar_path + ".md5.stamp",
748 sources = _java_files + _java_srcjars
749 inputs = _system_jars + [ _build_config ]
751 _rebased_system_jars = rebase_path(_system_jars, root_build_dir)
752 _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
753 _rebased_depfile = rebase_path(depfile, root_build_dir)
755 "--depfile=$_rebased_depfile",
756 "--classpath=$_rebased_system_jars",
757 "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
758 "--jar-path=$_rebased_jar_path",
759 "--java-srcjars=$_rebased_java_srcjars",
760 "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
761 "--jar-excluded-classes=$_jar_excluded_patterns",
763 foreach(e, _manifest_entries) {
764 args += [ "--manifest-entry=" + e ]
766 if (_chromium_code) {
767 args += [ "--chromium-code=1" ]
770 args += rebase_path(_java_files, root_build_dir)
773 _final_deps += [ ":${_template_name}__finish" ]
774 process_java_prebuilt("${_template_name}__finish") {
775 build_config = _build_config
776 input_jar_path = _intermediate_jar_path
777 output_jar_path = _final_jar_path
778 if (defined(invoker.proguard_preprocess) && invoker.proguard_preprocess) {
779 proguard_preprocess = invoker.proguard_preprocess
780 proguard_config = invoker.proguard_config
789 template("java_library_impl") {
790 set_sources_assignment_filter([])
791 if (defined(invoker.testonly)) {
792 testonly = invoker.testonly
796 defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir) ||
797 defined(invoker.srcjars) || defined(invoker.srcjar_deps))
798 _base_path = "$target_gen_dir/$target_name"
799 _jar_path = _base_path + ".jar"
800 if (defined(invoker.jar_path)) {
801 _jar_path = invoker.jar_path
803 _template_name = target_name
807 if (defined(invoker.datadeps)) {
808 _final_datadeps = invoker.datadeps
812 defined(invoker.supports_android) && invoker.supports_android
814 defined(invoker.requires_android) && invoker.requires_android
816 if (_supports_android) {
817 _dex_path = _base_path + ".dex.jar"
818 if (defined(invoker.dex_path)) {
819 _dex_path = invoker.dex_path
823 if (defined(invoker.override_build_config)) {
824 _build_config = invoker.override_build_config
826 _build_config = _base_path + ".build_config"
827 _final_deps += [ ":${_template_name}__build_config" ]
828 write_build_config("${_template_name}__build_config") {
829 type = "java_library"
830 supports_android = _supports_android
831 requires_android = _requires_android
832 bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
833 invoker.bypass_platform_checks
836 if (defined(invoker.deps)) {
840 build_config = _build_config
842 if (_supports_android) {
848 _chromium_code = true
849 if (defined(invoker.chromium_code)) {
850 _chromium_code = invoker.chromium_code
854 if (defined(invoker.srcjar_deps)) {
855 _srcjar_deps = invoker.srcjar_deps
859 if (defined(invoker.srcjars)) {
860 _srcjars = invoker.srcjars
864 if (defined(invoker.java_files)) {
865 _java_files = invoker.java_files
866 } else if (defined(invoker.DEPRECATED_java_in_dir)) {
867 _src_dir = invoker.DEPRECATED_java_in_dir + "/src"
868 _src_dir_exists = exec_script("//build/dir_exists.py",
869 [ rebase_path(_src_dir, root_build_dir) ],
871 assert(_src_dir_exists == "False",
872 "In GN, java_in_dir should be the fully specified java directory " +
873 "(i.e. including the trailing \"/src\")")
875 _java_files_build_rel = exec_script(
876 "//build/android/gyp/find.py",
880 rebase_path(invoker.DEPRECATED_java_in_dir, root_build_dir),
883 _java_files = rebase_path(_java_files_build_rel, ".", root_build_dir)
885 assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
887 _final_deps += [ ":${_template_name}__compile_java" ]
888 compile_java("${_template_name}__compile_java") {
890 build_config = _build_config
891 java_files = _java_files
892 srcjar_deps = _srcjar_deps
894 chromium_code = _chromium_code
895 android = _requires_android
897 if (defined(invoker.jar_excluded_patterns)) {
898 jar_excluded_patterns = invoker.jar_excluded_patterns
900 if (defined(invoker.proguard_preprocess)) {
901 proguard_preprocess = invoker.proguard_preprocess
903 if (defined(invoker.proguard_config)) {
904 proguard_config = invoker.proguard_config
906 if (defined(invoker.dist_jar_path)) {
907 dist_jar_path = invoker.dist_jar_path
909 if (defined(invoker.manifest_entries)) {
910 manifest_entries = invoker.manifest_entries
914 if (defined(invoker.main_class)) {
915 _final_deps += [ ":${_template_name}__binary_script" ]
916 action("${_template_name}__binary_script") {
917 script = "//build/android/gyp/create_java_binary_script.py"
918 depfile = "$target_gen_dir/$target_name.d"
919 java_script = "$root_build_dir/bin/$_template_name"
927 _rebased_build_config = rebase_path(_build_config, root_build_dir)
930 rebase_path(depfile, root_build_dir),
932 rebase_path(java_script, root_build_dir),
933 "--classpath=@FileArg($_rebased_build_config:java:full_classpath)",
935 rebase_path(_jar_path, root_build_dir),
942 if (_supports_android) {
943 if (defined(invoker.chromium_code) && invoker.chromium_code) {
944 _android_manifest = "//build/android/AndroidManifest.xml"
945 if (defined(invoker.android_manifest)) {
946 _android_manifest = invoker.android_manifest
949 _final_datadeps += [ ":${_template_name}__lint" ]
950 android_lint("${_template_name}__lint") {
951 android_manifest = _android_manifest
953 java_files = _java_files
957 _final_datadeps += [ ":${_template_name}__findbugs" ]
958 findbugs("${_template_name}__findbugs") {
959 build_config = _build_config
965 _final_deps += [ ":${_template_name}__dex" ]
966 dex("${_template_name}__dex") {
975 if (defined(invoker.visibility)) {
976 visibility = invoker.visibility
979 datadeps = _final_datadeps
983 # Runs process_resources.py
984 template("process_resources") {
985 set_sources_assignment_filter([])
986 if (defined(invoker.testonly)) {
987 testonly = invoker.testonly
990 zip_path = invoker.zip_path
991 srcjar_path = invoker.srcjar_path
992 build_config = invoker.build_config
993 resource_dirs = invoker.resource_dirs
994 android_manifest = invoker.android_manifest
996 non_constant_id = true
997 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) {
998 non_constant_id = false
1001 action(target_name) {
1002 script = "//build/android/gyp/process_resources.py"
1004 depfile = "$target_gen_dir/$target_name.d"
1011 sources_build_rel = exec_script("//build/android/gyp/find.py",
1012 rebase_path(resource_dirs, root_build_dir),
1014 sources = rebase_path(sources_build_rel, ".", root_build_dir)
1021 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir)
1022 rebase_build_config = rebase_path(build_config, root_build_dir)
1025 rebase_path(depfile, root_build_dir),
1027 rebase_path(android_sdk, root_build_dir),
1028 "--android-sdk-tools",
1029 rebase_path(android_sdk_build_tools, root_build_dir),
1030 "--android-manifest",
1031 rebase_path(android_manifest, root_build_dir),
1032 "--resource-dirs=$rebase_resource_dirs",
1034 rebase_path(srcjar_path, root_build_dir),
1035 "--resource-zip-out",
1036 rebase_path(zip_path, root_build_dir),
1037 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)",
1038 "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)",
1041 if (non_constant_id) {
1042 args += [ "--non-constant-id" ]
1045 if (defined(invoker.custom_package)) {
1048 invoker.custom_package,
1052 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) {
1053 args += [ "--v14-verify-only" ]
1056 if (defined(invoker.shared_resources) && invoker.shared_resources) {
1057 args += [ "--shared-resources" ]
1060 if (defined(invoker.all_resources_zip_path)) {
1061 all_resources_zip = invoker.all_resources_zip_path
1062 outputs += [ all_resources_zip ]
1064 "--all-resources-zip-out",
1065 rebase_path(all_resources_zip, root_build_dir),
1069 if (defined(invoker.args)) {
1070 args += invoker.args
1075 template("copy_ex") {
1076 set_sources_assignment_filter([])
1077 if (defined(invoker.testonly)) {
1078 testonly = invoker.testonly
1081 action(target_name) {
1082 script = "//build/android/gyp/copy_ex.py"
1084 if (defined(invoker.deps)) {
1089 if (defined(invoker.sources)) {
1090 sources += invoker.sources
1094 if (defined(invoker.inputs)) {
1095 inputs += invoker.inputs
1098 depfile = "$target_gen_dir/$target_name.d"
1105 rebase_path(depfile, root_build_dir),
1107 rebase_path(invoker.dest, root_build_dir),
1109 rebased_sources = rebase_path(sources, root_build_dir)
1110 args += [ "--files=$rebased_sources" ]
1112 if (defined(invoker.clear_dir) && invoker.clear_dir) {
1113 args += [ "--clear" ]
1116 if (defined(invoker.args)) {
1117 args += invoker.args
1122 # Produces a single .dex.jar out of a set of Java dependencies.
1123 template("deps_dex") {
1124 set_sources_assignment_filter([])
1125 build_config = "$target_gen_dir/${target_name}.build_config"
1126 write_build_config("${target_name}__build_config") {
1130 build_config = build_config
1131 dex_path = invoker.dex_path
1134 rebased_build_config = rebase_path(build_config, root_build_dir)
1139 output = invoker.dex_path
1140 dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files"
1141 args = [ "--inputs=@FileArg($dex_arg_key)" ]
1142 if (defined(invoker.excluded_jars)) {
1143 excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir)
1144 args += [ "--excluded-paths=${excluded_jars}" ]