Commit e5babf59 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[modules] Auto-determine if resouces go into base or feature module

Bug: 944115
Change-Id: I42573db7c4e99f21c9ef208aeb31e0a10b9f10f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1548319
Auto-Submit: Tibor Goldschwendt <tiborg@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646591}
parent 07b05271
...@@ -939,6 +939,11 @@ def main(argv): ...@@ -939,6 +939,11 @@ def main(argv):
help='Dump the Markdown .build_config format documentation ' help='Dump the Markdown .build_config format documentation '
'then exit immediately.') 'then exit immediately.')
parser.add_option(
'--base-module-build-config',
help='Path to the base module\'s build config '
'if this is a feature module.')
options, args = parser.parse_args(argv) options, args = parser.parse_args(argv)
if args: if args:
...@@ -1049,6 +1054,11 @@ def main(argv): ...@@ -1049,6 +1054,11 @@ def main(argv):
all_resources_deps = deps.All('android_resources') all_resources_deps = deps.All('android_resources')
all_classpath_library_deps = classpath_deps.All('java_library') all_classpath_library_deps = classpath_deps.All('java_library')
base_module_build_config = None
if options.base_module_build_config:
with open(options.base_module_build_config, 'r') as f:
base_module_build_config = json.load(f)
# Initialize some common config. # Initialize some common config.
# Any value that needs to be queryable by dependents must go within deps_info. # Any value that needs to be queryable by dependents must go within deps_info.
config = { config = {
...@@ -1233,16 +1243,36 @@ def main(argv): ...@@ -1233,16 +1243,36 @@ def main(argv):
'android_resources', 'android_apk', 'junit_binary', 'resource_rewriter', 'android_resources', 'android_apk', 'junit_binary', 'resource_rewriter',
'dist_aar', 'android_app_bundle_module'): 'dist_aar', 'android_app_bundle_module'):
config['resources'] = {} config['resources'] = {}
config['resources']['dependency_zips'] = [
c['resources_zip'] for c in all_resources_deps] dependency_zips = [
c['resources_zip'] for c in all_resources_deps if c['resources_zip']
]
extra_package_names = [] extra_package_names = []
extra_r_text_files = [] extra_r_text_files = []
if options.type != 'android_resources': if options.type != 'android_resources':
extra_package_names = [ extra_package_names = [
c['package_name'] for c in all_resources_deps if 'package_name' in c] c['package_name'] for c in all_resources_deps if 'package_name' in c]
extra_r_text_files = [ extra_r_text_files = [
c['r_text'] for c in all_resources_deps if 'r_text' in c] c['r_text'] for c in all_resources_deps if 'r_text' in c]
# For feature modules, remove any resources that already exist in the base
# module.
if base_module_build_config:
dependency_zips = [
c for c in dependency_zips
if c not in base_module_build_config['resources']['dependency_zips']
]
extra_package_names = [
c for c in extra_package_names if c not in
base_module_build_config['resources']['extra_package_names']
]
extra_r_text_files = [
c for c in extra_r_text_files if c not in
base_module_build_config['resources']['extra_r_text_files']
]
config['resources']['dependency_zips'] = dependency_zips
config['resources']['extra_package_names'] = extra_package_names config['resources']['extra_package_names'] = extra_package_names
config['resources']['extra_r_text_files'] = extra_r_text_files config['resources']['extra_r_text_files'] = extra_r_text_files
......
...@@ -143,6 +143,9 @@ template("write_build_config") { ...@@ -143,6 +143,9 @@ template("write_build_config") {
if (defined(invoker.android_manifest_dep)) { if (defined(invoker.android_manifest_dep)) {
deps += [ invoker.android_manifest_dep ] deps += [ invoker.android_manifest_dep ]
} }
if (defined(invoker.base_module_build_config_target)) {
deps += [ invoker.base_module_build_config_target ]
}
script = "//build/android/gyp/write_build_config.py" script = "//build/android/gyp/write_build_config.py"
depfile = "$target_gen_dir/$target_name.d" depfile = "$target_gen_dir/$target_name.d"
...@@ -477,6 +480,12 @@ template("write_build_config") { ...@@ -477,6 +480,12 @@ template("write_build_config") {
invoker.main_class, invoker.main_class,
] ]
} }
if (defined(invoker.base_module_build_config)) {
_rebased_base_module_build_config =
rebase_path(invoker.base_module_build_config, root_build_dir)
args +=
[ "--base-module-build-config=$_rebased_base_module_build_config" ]
}
if (current_toolchain != default_toolchain) { if (current_toolchain != default_toolchain) {
# This has to be a built-time error rather than a GN assert because many # This has to be a built-time error rather than a GN assert because many
# packages have a mix of java and non-java targets. For example, the # packages have a mix of java and non-java targets. For example, the
...@@ -3346,8 +3355,10 @@ if (enable_java_templates) { ...@@ -3346,8 +3355,10 @@ if (enable_java_templates) {
if (type == "android_app_bundle_module") { if (type == "android_app_bundle_module") {
forward_variables_from(invoker, forward_variables_from(invoker,
[ [
"proto_resources_path", "base_module_build_config",
"base_module_build_config_target",
"module_rtxt_path", "module_rtxt_path",
"proto_resources_path",
]) ])
} }
build_config = _build_config build_config = _build_config
......
...@@ -2587,6 +2587,8 @@ if (enable_java_templates) { ...@@ -2587,6 +2587,8 @@ if (enable_java_templates) {
"android_manifest", "android_manifest",
"android_manifest_dep", "android_manifest_dep",
"apk_under_test", "apk_under_test",
"base_module_build_config",
"base_module_build_config_target",
"chromium_code", "chromium_code",
"classpath_deps", "classpath_deps",
"emma_never_instrument", "emma_never_instrument",
...@@ -3294,10 +3296,15 @@ if (enable_java_templates) { ...@@ -3294,10 +3296,15 @@ if (enable_java_templates) {
_base_module_target_gen_dir = _base_module_target_gen_dir =
get_label_info(_base_module_target, "target_gen_dir") get_label_info(_base_module_target, "target_gen_dir")
_base_module_target_name = get_label_info(_base_module_target, "name") _base_module_target_name = get_label_info(_base_module_target, "name")
base_module_arsc_resource = base_module_arsc_resource =
"$_base_module_target_gen_dir/$_base_module_target_name.arsc.ap_" "$_base_module_target_gen_dir/$_base_module_target_name.arsc.ap_"
base_module_arsc_resource_target = base_module_arsc_resource_target =
"${_base_module_target}__compile_arsc_resources" "${_base_module_target}__compile_arsc_resources"
base_module_build_config = "$_base_module_target_gen_dir/" +
"$_base_module_target_name.build_config"
base_module_build_config_target =
"${_base_module_target}$build_config_target_suffix"
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment