[Android] Allow Java libraries to access resources from dependencies.

Libraries could previously access dependencies' resources in Java code
but not in XML layout files. This enables accessing these resources in
layout files as well, with the compromise that resources can now be
accessed using the wrong package name in Java code. Since resource
names are global anyway (an APK can't contain two resources with the
same name), this is deemed OK.

BUG=176069


Review URL: https://chromiumcodereview.appspot.com/13107002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190896 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/build/java.gypi b/build/java.gypi
index 6b0b9a5..c1d5911 100644
--- a/build/java.gypi
+++ b/build/java.gypi
@@ -88,13 +88,17 @@
         'R_stamp': '<(intermediate_dir)/resources.stamp',
         'generated_src_dirs': ['<(R_dir)'],
         'additional_input_paths': ['<(R_stamp)'],
+        'additional_res_dirs': [],
+        'dependencies_res_files': [],
       },
       'all_dependent_settings': {
         'variables': {
           # Dependent jars include this target's R.java file via
-          # generated_R_dirs and additional_R_files.
+          # generated_R_dirs and include its resources via
+          # dependencies_res_files.
           'generated_R_dirs': ['<(R_dir)'],
           'additional_input_paths': ['<(R_stamp)'],
+          'dependencies_res_files': ['<@(resource_input_paths)'],
 
           # Dependent APKs include this target's resources via
           # additional_res_dirs, additional_res_packages, and
@@ -133,11 +137,15 @@
           'message': 'processing resources for <(_target_name)',
           'variables': {
             'android_manifest': '<(DEPTH)/build/android/AndroidManifest.xml',
+            # Include the dependencies' res dirs so that references to
+            # resources in dependencies can be resolved.
+            'all_res_dirs': ['<@(res_input_dirs)', '>@(additional_res_dirs)'],
           },
           'inputs': [
             '<(DEPTH)/build/android/pylib/build_utils.py',
             '<(DEPTH)/build/android/process_resources.py',
             '>@(resource_input_paths)',
+            '>@(dependencies_res_files)',
           ],
           'outputs': [
             '<(R_stamp)',
@@ -147,7 +155,7 @@
             '--android-sdk', '<(android_sdk)',
             '--android-sdk-tools', '<(android_sdk_tools)',
             '--R-dir', '<(R_dir)',
-            '--res-dirs', '<(res_input_dirs)',
+            '--res-dirs', '>(all_res_dirs)',
             '--crunch-input-dir', '>(res_dir)',
             '--crunch-output-dir', '<(res_crunched_dir)',
             '--android-manifest', '<(android_manifest)',