| 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 | 14 |
| 15 # Write the target's .build_config file. This is a json file that contains a | 15 # Write the target's .build_config file. This is a json file that contains a |
| 16 # dictionary of information about how to build this target (things that | 16 # dictionary of information about how to build this target (things that |
| 17 # require knowledge about this target's dependencies and cannot be calculated | 17 # require knowledge about this target's dependencies and cannot be calculated |
| 18 # at gn-time). There is a special syntax to add a value in that dictionary to | 18 # at gn-time). There is a special syntax to add a value in that dictionary to |
| 19 # an action/action_foreachs args: | 19 # an action/action_foreachs args: |
| 20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) | 20 # --python-arg=@FileArg($rebased_build_config_path:key0:key1) |
| 21 # At runtime, such an arg will be replaced by the value in the build_config. | 21 # At runtime, such an arg will be replaced by the value in the build_config. |
| 22 # See build/android/gyp/write_build_config.py and | 22 # See build/android/gyp/write_build_config.py and |
| 23 # build/android/gyp/util/build_utils.py:ExpandFileArgs | 23 # build/android/gyp/util/build_utils.py:ExpandFileArgs |
| 24 template("write_build_config") { | 24 template("write_build_config") { |
| 25 assert(defined(invoker.type)) | 25 assert(defined(invoker.type)) |
| 26 assert(defined(invoker.base_path)) | 26 assert(defined(invoker.build_config)) |
| 27 | 27 |
| 28 base_path = invoker.base_path | |
| 29 type = invoker.type | 28 type = invoker.type |
| 30 build_config = base_path + ".build_config" | 29 build_config = invoker.build_config |
| 31 | 30 |
| 32 assert(type == "android_binary" || type == "android_library" || type == "andro
id_resources") | 31 assert(type == "android_apk" || type == "android_library" || type == "android_
resources") |
| 33 | 32 |
| 34 action(target_name) { | 33 action(target_name) { |
| 35 script = "//build/android/gyp/write_build_config.py" | 34 script = "//build/android/gyp/write_build_config.py" |
| 36 depfile = "$target_gen_dir/$target_name.d" | 35 depfile = "$target_gen_dir/$target_name.d" |
| 37 | 36 |
| 38 deps = [] | 37 deps = [] |
| 39 if (defined(invoker.deps)) { | 38 if (defined(invoker.deps)) { |
| 40 deps += invoker.deps | 39 deps += invoker.deps |
| 41 } | 40 } |
| 42 | 41 |
| 43 outputs = [ | 42 outputs = [ |
| 44 depfile, | 43 depfile, |
| 45 build_config | 44 build_config |
| 46 ] | 45 ] |
| 47 | 46 |
| 48 possible_deps_configs = [] | 47 possible_deps_configs = [] |
| 49 foreach(d, deps) { | 48 foreach(d, deps) { |
| 50 dep_gen_dir = get_label_info(d, "target_gen_dir") | 49 dep_gen_dir = get_label_info(d, "target_gen_dir") |
| 51 dep_name = get_label_info(d, "name") | 50 dep_name = get_label_info(d, "name") |
| 52 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] | 51 possible_deps_configs += [ "$dep_gen_dir/$dep_name.build_config" ] |
| 53 } | 52 } |
| 54 rebase_possible_deps_configs = rebase_path(possible_deps_configs) | 53 rebase_possible_deps_configs = rebase_path(possible_deps_configs) |
| 54 |
| 55 args = [ | 55 args = [ |
| 56 "--type", type, | 56 "--type", type, |
| 57 "--depfile", rebase_path(depfile, root_build_dir), | 57 "--depfile", rebase_path(depfile, root_build_dir), |
| 58 "--possible-deps-configs=$rebase_possible_deps_configs", | 58 "--possible-deps-configs=$rebase_possible_deps_configs", |
| 59 "--build-config", rebase_path(build_config, root_build_dir), | 59 "--build-config", rebase_path(build_config, root_build_dir), |
| 60 ] | 60 ] |
| 61 | 61 |
| 62 if (type == "android_library") { | 62 if (type == "android_library" || type == "android_apk") { |
| 63 jar_path = base_path + ".jar" | |
| 64 args += [ | 63 args += [ |
| 65 "--jar-path", rebase_path(jar_path, root_build_dir), | 64 "--jar-path", rebase_path(invoker.jar_path, root_build_dir), |
| 66 ] | 65 ] |
| 67 } | 66 } |
| 68 | 67 |
| 69 if (type == "android_resources") { | 68 if (type == "android_resources" || type == "android_apk") { |
| 70 assert(defined(invoker.resources_zip)) | 69 assert(defined(invoker.resources_zip)) |
| 71 args += [ | 70 args += [ |
| 72 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), | 71 "--resources-zip", rebase_path(invoker.resources_zip, root_build_dir), |
| 73 ] | 72 ] |
| 74 if (defined(invoker.srcjar)) { | 73 } |
| 75 args += [ | 74 |
| 76 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) | 75 if (defined(invoker.srcjar)) { |
| 77 ] | 76 args += [ |
| 78 } | 77 "--srcjar", rebase_path(invoker.srcjar, root_build_dir) |
| 78 ] |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 # Creates a zip archive of the inputs. | 84 # Creates a zip archive of the inputs. |
| 85 # If base_dir is provided, the archive paths will be relative to it. | 85 # If base_dir is provided, the archive paths will be relative to it. |
| 86 template("zip") { | 86 template("zip") { |
| 87 assert(defined(invoker.inputs)) | 87 assert(defined(invoker.inputs)) |
| 88 assert(defined(invoker.output)) | 88 assert(defined(invoker.output)) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 103 "--output=$rebase_output", | 103 "--output=$rebase_output", |
| 104 ] | 104 ] |
| 105 if (defined(invoker.base_dir)) { | 105 if (defined(invoker.base_dir)) { |
| 106 args += [ | 106 args += [ |
| 107 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) | 107 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) |
| 108 ] | 108 ] |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 | |
| 114 # Compiles and jars a set of java files. | 113 # Compiles and jars a set of java files. |
| 115 # | 114 # |
| 116 # Outputs: | 115 # Outputs: |
| 117 # $jar_path.jar | 116 # $jar_path.jar |
| 118 # $jar_path.jar.TOC | 117 # $jar_path.jar.TOC |
| 119 # | 118 # |
| 120 # Variables | 119 # Variables |
| 121 # java_files: List of .java files to compile. | 120 # java_files: List of .java files to compile. |
| 122 # java_deps: List of java dependencies. These should all have a .jar output | 121 # java_deps: List of java dependencies. These should all have a .jar output |
| 123 # at "${target_gen_dir}/${target_name}.jar. | 122 # at "${target_gen_dir}/${target_name}.jar. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 221 } |
| 223 } | 222 } |
| 224 | 223 |
| 225 | 224 |
| 226 # This adds Android-specific parts to the java_library template. | 225 # This adds Android-specific parts to the java_library template. |
| 227 # | 226 # |
| 228 # Runs Android lint against the compiled java files. | 227 # Runs Android lint against the compiled java files. |
| 229 # Dexes the output jar for inclusion in an APK. | 228 # Dexes the output jar for inclusion in an APK. |
| 230 template("android_java_library") { | 229 template("android_java_library") { |
| 231 assert(defined(invoker.java_files)) | 230 assert(defined(invoker.java_files)) |
| 232 | |
| 233 assert(defined(invoker.build_config)) | 231 assert(defined(invoker.build_config)) |
| 234 assert(defined(invoker.jar_path)) | 232 assert(defined(invoker.jar_path)) |
| 235 | 233 |
| 234 _jar_path = invoker.jar_path |
| 235 |
| 236 java_library("${target_name}__java_library") { | 236 java_library("${target_name}__java_library") { |
| 237 jar_path = _jar_path |
| 237 if (defined(invoker.jar_excluded_patterns)) { | 238 if (defined(invoker.jar_excluded_patterns)) { |
| 238 jar_excluded_patterns = invoker.jar_excluded_patterns | 239 jar_excluded_patterns = invoker.jar_excluded_patterns |
| 239 } | 240 } |
| 240 build_config = invoker.build_config | 241 build_config = invoker.build_config |
| 241 java_files = invoker.java_files | 242 java_files = invoker.java_files |
| 242 jar_path = invoker.jar_path | |
| 243 | 243 |
| 244 if (defined(invoker.srcjar_deps)) { | 244 if (defined(invoker.srcjar_deps)) { |
| 245 srcjar_deps = invoker.srcjar_deps | 245 srcjar_deps = invoker.srcjar_deps |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 # TODO(cjhopman): lint | 249 # TODO(cjhopman): lint |
| 250 # TODO(cjhopman): dex | 250 # TODO(cjhopman): dex |
| 251 | 251 |
| 252 group(target_name) { | 252 group(target_name) { |
| 253 deps = [ | 253 deps = [ |
| 254 ":${target_name}__java_library" | 254 ":${target_name}__java_library" |
| 255 ] | 255 ] |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 | 259 |
| 260 # Runs process_resources.py | 260 # Runs process_resources.py |
| 261 template("process_resources") { | 261 template("process_resources") { |
| 262 zip_path = invoker.zip_path | 262 zip_path = invoker.zip_path |
| 263 srcjar_path = invoker.srcjar_path | 263 srcjar_path = invoker.srcjar_path |
| 264 build_config = invoker.build_config | 264 build_config = invoker.build_config |
| 265 resource_dirs = invoker.resource_dirs | 265 resource_dirs = invoker.resource_dirs |
| 266 android_manifest = invoker.android_manifest | 266 android_manifest = invoker.android_manifest |
| 267 | 267 |
| 268 non_constant_id = true |
| 269 if (defined(invoker.generate_constant_ids) && invoker.generate_constant_ids) { |
| 270 non_constant_id = false |
| 271 } |
| 272 |
| 268 action(target_name) { | 273 action(target_name) { |
| 269 script = "//build/android/gyp/process_resources.py" | 274 script = "//build/android/gyp/process_resources.py" |
| 270 | 275 |
| 271 depfile = "$target_gen_dir/$target_name.d" | 276 depfile = "$target_gen_dir/$target_name.d" |
| 272 outputs = [ | 277 outputs = [ |
| 273 depfile, | 278 depfile, |
| 274 zip_path, | 279 zip_path, |
| 275 srcjar_path, | 280 srcjar_path, |
| 276 ] | 281 ] |
| 277 | 282 |
| 278 sources_build_rel = exec_script( | 283 sources_build_rel = exec_script( |
| 279 "//build/android/gyp/find.py", | 284 "//build/android/gyp/find.py", |
| 280 rebase_path(resource_dirs, root_build_dir), | 285 rebase_path(resource_dirs, root_build_dir), |
| 281 "list lines" | 286 "list lines" |
| 282 ) | 287 ) |
| 283 sources = rebase_path(sources_build_rel, ".", root_build_dir) | 288 sources = rebase_path(sources_build_rel, ".", root_build_dir) |
| 284 | 289 |
| 285 source_prereqs = [ | 290 source_prereqs = [ |
| 286 build_config, | 291 build_config, |
| 287 android_manifest, | 292 android_manifest, |
| 288 ] | 293 ] |
| 289 | 294 |
| 290 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) | 295 rebase_resource_dirs = rebase_path(resource_dirs, root_build_dir) |
| 291 rebase_build_config = rebase_path(build_config, root_build_dir) | 296 rebase_build_config = rebase_path(build_config, root_build_dir) |
| 292 args = [ | 297 args = [ |
| 293 "--depfile", rebase_path(depfile, root_build_dir), | 298 "--depfile", rebase_path(depfile, root_build_dir), |
| 294 "--android-sdk", rebase_path(android_sdk, root_build_dir), | 299 "--android-sdk", rebase_path(android_sdk, root_build_dir), |
| 295 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir
), | 300 "--android-sdk-tools", rebase_path(android_sdk_build_tools, root_build_dir
), |
| 296 "--non-constant-id", | |
| 297 "--android-manifest", rebase_path(android_manifest, root_build_dir), | 301 "--android-manifest", rebase_path(android_manifest, root_build_dir), |
| 298 | 302 |
| 299 "--resource-dirs=$rebase_resource_dirs", | 303 "--resource-dirs=$rebase_resource_dirs", |
| 300 "--srcjar-out", rebase_path(srcjar_path, root_build_dir), | 304 "--srcjar-out", rebase_path(srcjar_path, root_build_dir), |
| 301 "--resource-zip-out", rebase_path(zip_path, root_build_dir), | 305 "--resource-zip-out", rebase_path(zip_path, root_build_dir), |
| 302 | 306 |
| 303 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc
y_zips)", | 307 "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependenc
y_zips)", |
| 304 ] | 308 ] |
| 305 | 309 |
| 310 if (non_constant_id) { |
| 311 args += [ "--non-constant-id" ] |
| 312 } |
| 313 |
| 306 if (defined(invoker.custom_package)) { | 314 if (defined(invoker.custom_package)) { |
| 307 args += [ | 315 args += [ |
| 308 "--custom-package", invoker.custom_package, | 316 "--custom-package", invoker.custom_package, |
| 309 ] | 317 ] |
| 310 } | 318 } |
| 311 | 319 |
| 312 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { | 320 if (defined(invoker.v14_verify_only) && invoker.v14_verify_only) { |
| 313 args += ["--v14-verify-only"] | 321 args += ["--v14-verify-only"] |
| 314 } | 322 } |
| 323 |
| 324 if (defined(invoker.all_resources_zip_path)) { |
| 325 all_resources_zip = invoker.all_resources_zip_path |
| 326 outputs += [ all_resources_zip ] |
| 327 args += [ |
| 328 "--all-resources-zip-out", rebase_path(all_resources_zip, root_build_dir
) |
| 329 ] |
| 330 } |
| 331 |
| 332 if (defined(invoker.args)) { |
| 333 args += invoker.args |
| 334 } |
| 315 } | 335 } |
| 316 } | 336 } |
| OLD | NEW |