From e430bfd8102c265186b009fd377b0e516a9d09a6 Mon Sep 17 00:00:00 2001 From: wnwen Date: Wed, 7 Dec 2016 13:11:58 -0800 Subject: [PATCH] Android: Add java files from android_apk targets This allows editing android_webview_apk and android_webview_test_apk files in android studio. BUG=670044 Review-Url: https://codereview.chromium.org/2545793002 Cr-Original-Commit-Position: refs/heads/master@{#437056} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: c3bace8213461c2a3884b36a3b80aea0e651b15a --- config/android/internal_rules.gni | 11 ++++++++++- config/android/rules.gni | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/android/internal_rules.gni b/config/android/internal_rules.gni index 27b736f36..48fcbc4e7 100644 --- a/config/android/internal_rules.gni +++ b/config/android/internal_rules.gni @@ -2245,6 +2245,11 @@ if (enable_java_templates) { _accumulated_deps = invoker.deps } + # Caller overriding build config must have valid java sources file if it has + # java files. + assert(!defined(invoker.override_build_config) || + !defined(invoker.java_files) || defined(invoker.java_sources_file)) + assert(defined(invoker.java_files) || defined(invoker.srcjars) || defined(invoker.srcjar_deps)) _base_path = "$target_gen_dir/$target_name" @@ -2326,7 +2331,11 @@ if (enable_java_templates) { _java_files += invoker.java_files } if (_java_files != []) { - _java_sources_file = "$_base_path.sources" + if (defined(invoker.java_sources_file)) { + _java_sources_file = invoker.java_sources_file + } else { + _java_sources_file = "$_base_path.sources" + } write_file(_java_sources_file, rebase_path(_java_files, root_build_dir)) } diff --git a/config/android/rules.gni b/config/android/rules.gni index 0f1891433..91d84cc48 100644 --- a/config/android/rules.gni +++ b/config/android/rules.gni @@ -1433,6 +1433,9 @@ if (enable_java_templates) { _lib_dex_path = "$base_path.dex.jar" _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir) _template_name = target_name + if (defined(invoker.java_files)) { + _java_sources_file = "$base_path.sources" + } enable_multidex = defined(invoker.enable_multidex) && invoker.enable_multidex @@ -1616,6 +1619,10 @@ if (enable_java_templates) { build_config = _build_config android_manifest = _android_manifest + if (defined(_java_sources_file)) { + java_sources_file = _java_sources_file + } + deps = _android_manifest_deps if (defined(invoker.deps)) { @@ -1782,6 +1789,9 @@ if (enable_java_templates) { jar_path = _jar_path dex_path = _lib_dex_path emma_never_instrument = _emma_never_instrument + if (defined(_java_sources_file)) { + java_sources_file = _java_sources_file + } if (defined(invoker.deps)) { deps += invoker.deps