OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 # This file is meant to be included into a target to provide a rule | 5 # This file is meant to be included into a target to provide a rule |
6 # to build Android APKs in a consistent manner. | 6 # to build Android APKs in a consistent manner. |
7 # | 7 # |
8 # To use this, create a gyp target with the following form: | 8 # To use this, create a gyp target with the following form: |
9 # { | 9 # { |
10 # 'target_name': 'my_package_apk', | 10 # 'target_name': 'my_package_apk', |
11 # 'type': 'none', | 11 # 'type': 'none', |
12 # 'variables': { | 12 # 'variables': { |
13 # 'package_name': 'my_package', | 13 # 'package_name': 'my_package', |
14 # 'apk_name': 'MyPackage', | 14 # 'apk_name': 'MyPackage', |
15 # 'java_in_dir': 'path/to/package/root', | 15 # 'java_in_dir': 'path/to/package/root', |
16 # 'resource_dir': 'res', | 16 # 'resource_dir': 'res', |
17 # }, | 17 # }, |
18 # 'includes': ['path/to/this/gypi/file'], | 18 # 'includes': ['path/to/this/gypi/file'], |
19 # } | 19 # } |
20 # | 20 # |
21 # Note that this assumes that there's an ant buildfile <package_name>_apk.xml in | 21 # Note that this assumes that there's an ant buildfile <package_name>_apk.xml in |
22 # java_in_dir. So, if you have package_name="content_shell" and | 22 # java_in_dir. So, if you have package_name="content_shell" and |
23 # java_in_dir="content/shell/android/java" you should have a directory structure | 23 # java_in_dir="content/shell/android/java" you should have a directory structure |
24 # like: | 24 # like: |
25 # | 25 # |
26 # content/shell/android/java/content_shell_apk.xml | 26 # content/shell/android/java/content_shell_apk.xml |
27 # content/shell/android/java/src/chromium/base/Foo.java | 27 # content/shell/android/java/src/org/chromium/base/Foo.java |
28 # content/shell/android/java/src/chromium/base/Bar.java | 28 # content/shell/android/java/src/org/chromium/base/Bar.java |
29 # | 29 # |
30 # Required variables: | 30 # Required variables: |
31 # package_name - Used to name the intermediate output directory and in the | 31 # package_name - Used to name the intermediate output directory and in the |
32 # names of some output files. | 32 # names of some output files. |
33 # apk_name - The final apk will be named <apk_name>.apk | 33 # apk_name - The final apk will be named <apk_name>.apk |
34 # java_in_dir - The top-level java directory. The src should be in | 34 # java_in_dir - The top-level java directory. The src should be in |
35 # <java_in_dir>/src. | 35 # <java_in_dir>/src. |
36 # Optional/automatic variables: | 36 # Optional/automatic variables: |
37 # additional_input_paths - These paths will be included in the 'inputs' list to | 37 # additional_input_paths - These paths will be included in the 'inputs' list to |
38 # ensure that this target is rebuilt when one of these paths changes. | 38 # ensure that this target is rebuilt when one of these paths changes. |
| 39 # additional_res_dirs - Additional directories containing Android resources. |
| 40 # additional_res_packages - Package names of the R.java files corresponding to |
| 41 # each directory in additional_res_dirs. |
39 # additional_src_dirs - Additional directories with .java files to be compiled | 42 # additional_src_dirs - Additional directories with .java files to be compiled |
40 # and included in the output of this target. | 43 # and included in the output of this target. |
41 # asset_location - The directory where assets are located (default: | 44 # asset_location - The directory where assets are located (default: |
42 # <PRODUCT_DIR>/<package_name>/assets). | 45 # <PRODUCT_DIR>/<package_name>/assets). |
43 # generated_src_dirs - Same as additional_src_dirs except used for .java files | 46 # generated_src_dirs - Same as additional_src_dirs except used for .java files |
44 # that are generated at build time. This should be set automatically by a | 47 # that are generated at build time. This should be set automatically by a |
45 # target's dependencies. The .java files in these directories are not | 48 # target's dependencies. The .java files in these directories are not |
46 # included in the 'inputs' list (unlike additional_src_dirs). | 49 # included in the 'inputs' list (unlike additional_src_dirs). |
47 # input_jars_paths - The path to jars to be included in the classpath. This | 50 # input_jars_paths - The path to jars to be included in the classpath. This |
48 # should be filled automatically by depending on the appropriate targets. | 51 # should be filled automatically by depending on the appropriate targets. |
| 52 # is_test_apk - Set to 1 if building a test apk. This prevents resources from |
| 53 # dependencies from being re-included. |
49 # native_libs_paths - The path to any native library to be included in this | 54 # native_libs_paths - The path to any native library to be included in this |
50 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of | 55 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of |
51 # the library will be included in the apk and symbolic links to the | 56 # the library will be included in the apk and symbolic links to the |
52 # unstripped copy will be added to <(android_product_out) to enable native | 57 # unstripped copy will be added to <(android_product_out) to enable native |
53 # debugging. | 58 # debugging. |
54 # resource_dir - The directory for resources. | 59 # resource_dir - The directory for resources. |
55 | 60 |
56 { | 61 { |
57 'variables': { | 62 'variables': { |
58 'asset_location%': '', | 63 'asset_location%': '', |
59 'additional_input_paths': [], | 64 'additional_input_paths': [], |
60 'input_jars_paths': [], | 65 'input_jars_paths': [], |
61 'additional_src_dirs': [], | 66 'additional_src_dirs': [], |
62 'generated_src_dirs': [], | 67 'generated_src_dirs': [], |
63 'app_manifest_version_name%': '<(android_app_version_name)', | 68 'app_manifest_version_name%': '<(android_app_version_name)', |
64 'app_manifest_version_code%': '<(android_app_version_code)', | 69 'app_manifest_version_code%': '<(android_app_version_code)', |
65 'proguard_enabled%': 'false', | 70 'proguard_enabled%': 'false', |
66 'proguard_flags%': '', | 71 'proguard_flags%': '', |
67 'native_libs_paths': [], | 72 'native_libs_paths': [], |
68 'manifest_package_name%': 'unknown.package.name', | 73 'manifest_package_name%': 'unknown.package.name', |
69 'resource_dir%':'', | 74 'resource_dir%': '', |
| 75 'additional_res_dirs': [], |
| 76 'additional_res_packages': [], |
| 77 'is_test_apk%': 0, |
70 }, | 78 }, |
71 'sources': [ | 79 'sources': [ |
72 '<@(native_libs_paths)' | 80 '<@(native_libs_paths)' |
73 ], | 81 ], |
74 'rules': [ | 82 'rules': [ |
75 { | 83 { |
76 'rule_name': 'copy_and_strip_native_libraries', | 84 'rule_name': 'copy_and_strip_native_libraries', |
77 'extension': 'so', | 85 'extension': 'so', |
78 'variables': { | 86 'variables': { |
79 'stripped_library_path': '<(PRODUCT_DIR)/<(package_name)/libs/<(android_
app_abi)/<(RULE_INPUT_ROOT).so', | 87 'stripped_library_path': '<(PRODUCT_DIR)/<(package_name)/libs/<(android_
app_abi)/<(RULE_INPUT_ROOT).so', |
(...skipping 25 matching lines...) Expand all Loading... |
105 # wrong .java files when additional_src_dirs is empty. | 113 # wrong .java files when additional_src_dirs is empty. |
106 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 114 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
107 '>@(input_jars_paths)', | 115 '>@(input_jars_paths)', |
108 '>@(native_libs_paths)', | 116 '>@(native_libs_paths)', |
109 '>@(additional_input_paths)', | 117 '>@(additional_input_paths)', |
110 ], | 118 ], |
111 'conditions': [ | 119 'conditions': [ |
112 ['resource_dir!=""', { | 120 ['resource_dir!=""', { |
113 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")'] | 121 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")'] |
114 }], | 122 }], |
| 123 ['is_test_apk == 1', { |
| 124 'variables': { |
| 125 'additional_res_dirs=': [], |
| 126 'additional_res_packages=': [], |
| 127 } |
| 128 }], |
115 ], | 129 ], |
116 'outputs': [ | 130 'outputs': [ |
117 '<(PRODUCT_DIR)/apks/<(apk_name).apk', | 131 '<(PRODUCT_DIR)/apks/<(apk_name).apk', |
118 ], | 132 ], |
119 'action': [ | 133 'action': [ |
120 'ant', | 134 'ant', |
121 '-DAPP_ABI=<(android_app_abi)', | 135 '-DAPP_ABI=<(android_app_abi)', |
122 '-DANDROID_GDBSERVER=<(android_gdbserver)', | 136 '-DANDROID_GDBSERVER=<(android_gdbserver)', |
123 '-DANDROID_SDK=<(android_sdk)', | 137 '-DANDROID_SDK=<(android_sdk)', |
124 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 138 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
125 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | 139 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', |
126 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 140 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
127 '-DANDROID_TOOLCHAIN=<(android_toolchain)', | 141 '-DANDROID_TOOLCHAIN=<(android_toolchain)', |
128 '-DCHROMIUM_SRC=<(ant_build_out)/../..', | 142 '-DCHROMIUM_SRC=<(ant_build_out)/../..', |
129 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | 143 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
130 '-DPRODUCT_DIR=<(ant_build_out)', | 144 '-DPRODUCT_DIR=<(ant_build_out)', |
131 | 145 |
132 '-DAPK_NAME=<(apk_name)', | 146 '-DAPK_NAME=<(apk_name)', |
133 '-DASSET_DIR=<(asset_location)', | 147 '-DASSET_DIR=<(asset_location)', |
134 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | 148 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
135 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 149 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
136 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 150 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
137 '-DPACKAGE_NAME=<(package_name)', | 151 '-DPACKAGE_NAME=<(package_name)', |
138 '-DRESOURCE_DIR=<(resource_dir)', | 152 '-DRESOURCE_DIR=<(resource_dir)', |
| 153 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', |
| 154 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', |
139 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', | 155 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', |
140 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', | 156 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', |
141 '-DPROGUARD_FLAGS=>(proguard_flags)', | 157 '-DPROGUARD_FLAGS=>(proguard_flags)', |
142 '-DPROGUARD_ENABLED=>(proguard_enabled)', | 158 '-DPROGUARD_ENABLED=>(proguard_enabled)', |
143 | 159 |
144 '-Dbasedir=<(java_in_dir)', | 160 '-Dbasedir=<(java_in_dir)', |
145 '-buildfile', | 161 '-buildfile', |
146 '<(DEPTH)/build/android/ant/chromium-apk.xml', | 162 '<(DEPTH)/build/android/ant/chromium-apk.xml', |
147 | 163 |
148 # Specify CONFIGURATION_NAME as the target for ant to build. The | 164 # Specify CONFIGURATION_NAME as the target for ant to build. The |
149 # buildfile will then build the appropriate SDK tools target. | 165 # buildfile will then build the appropriate SDK tools target. |
150 '<(CONFIGURATION_NAME)', | 166 '<(CONFIGURATION_NAME)', |
151 ] | 167 ] |
152 }, | 168 }, |
153 ], | 169 ], |
154 } | 170 } |
OLD | NEW |