blob: ff102f9c03f42bec3f1ac14c6cd5463562d2f13a [file] [log] [blame]
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/android/rules.gni")
# Generate ResourceRewriter.java from Android Libraries according the dep
# graph.
# Argument:
# deps
# The same deps of target that uses the generated ResourceRewriter.
# package_name
# The package name of ResourceRewriter.java.
#
# This target generates a single srcjar containing generated
# ResourceRewrite.java which will list the R classes generated by all the
# Android libraries reachabled from the target specified in deps. Add this
# target to srcjar_deps of android_library will call ResourceRewriter.
#
template("generate_resource_rewriter") {
set_sources_assignment_filter([])
assert(defined(invoker.package_name))
_final_target_name = target_name
_build_config = "$target_gen_dir/${target_name}.build_config"
_build_config_target_name = "${target_name}__build_config"
_srcjar = "$target_gen_dir/${target_name}.srcjar"
write_build_config(_build_config_target_name) {
deps = invoker.deps
type = "resource_rewriter"
build_config = _build_config
}
action(_final_target_name) {
forward_variables_from(invoker, [ "visibility" ])
inputs = [
_build_config,
]
deps = [
":${_build_config_target_name}",
]
script = "//build/android/gyp/generate_resource_rewriter.py"
_rebased_build_config = rebase_path(_build_config)
args = [
"--package-name",
invoker.package_name,
"--dep-packages",
"@FileArg($_rebased_build_config:resources:extra_package_names)",
"--srcjar",
rebase_path(_srcjar),
]
outputs = [
_srcjar,
]
}
}