| 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', | |
| 14 # 'apk_name': 'MyPackage', | 13 # 'apk_name': 'MyPackage', |
| 15 # 'java_in_dir': 'path/to/package/root', | 14 # 'java_in_dir': 'path/to/package/root', |
| 16 # 'resource_dir': 'res', | 15 # 'resource_dir': 'res', |
| 17 # }, | 16 # }, |
| 18 # 'includes': ['path/to/this/gypi/file'], | 17 # 'includes': ['path/to/this/gypi/file'], |
| 19 # } | 18 # } |
| 20 # | 19 # |
| 21 # If you have package_name="content_shell" and | |
| 22 # java_in_dir="content/shell/android/java" you should have a directory structure | |
| 23 # like: | |
| 24 # | |
| 25 # content/shell/android/java/src/org/chromium/base/Foo.java | |
| 26 # content/shell/android/java/src/org/chromium/base/Bar.java | |
| 27 # | |
| 28 # Required variables: | 20 # Required variables: |
| 29 # package_name - Used to name the intermediate output directory and in the | |
| 30 # names of some output files. | |
| 31 # apk_name - The final apk will be named <apk_name>.apk | 21 # apk_name - The final apk will be named <apk_name>.apk |
| 32 # java_in_dir - The top-level java directory. The src should be in | 22 # java_in_dir - The top-level java directory. The src should be in |
| 33 # <java_in_dir>/src. | 23 # <(java_in_dir)/src. |
| 34 # Optional/automatic variables: | 24 # Optional/automatic variables: |
| 35 # additional_input_paths - These paths will be included in the 'inputs' list to | 25 # additional_input_paths - These paths will be included in the 'inputs' list to |
| 36 # ensure that this target is rebuilt when one of these paths changes. | 26 # ensure that this target is rebuilt when one of these paths changes. |
| 37 # additional_res_dirs - Additional directories containing Android resources. | 27 # additional_res_dirs - Additional directories containing Android resources. |
| 38 # additional_res_packages - Package names of the R.java files corresponding to | 28 # additional_res_packages - Package names of the R.java files corresponding to |
| 39 # each directory in additional_res_dirs. | 29 # each directory in additional_res_dirs. |
| 40 # additional_src_dirs - Additional directories with .java files to be compiled | 30 # additional_src_dirs - Additional directories with .java files to be compiled |
| 41 # and included in the output of this target. | 31 # and included in the output of this target. |
| 42 # asset_location - The absolute path to the directory where assets are located | 32 # asset_location - The directory where assets are located (default: |
| 43 # (default: <(ant_build_out)/<(package_name)/assets). | 33 # <(ant_build_out)/<(_target_name)/assets). |
| 44 # generated_src_dirs - Same as additional_src_dirs except used for .java files | 34 # generated_src_dirs - Same as additional_src_dirs except used for .java files |
| 45 # that are generated at build time. This should be set automatically by a | 35 # that are generated at build time. This should be set automatically by a |
| 46 # target's dependencies. The .java files in these directories are not | 36 # target's dependencies. The .java files in these directories are not |
| 47 # included in the 'inputs' list (unlike additional_src_dirs). | 37 # included in the 'inputs' list (unlike additional_src_dirs). |
| 48 # input_jars_paths - The path to jars to be included in the classpath. This | 38 # input_jars_paths - The path to jars to be included in the classpath. This |
| 49 # should be filled automatically by depending on the appropriate targets. | 39 # should be filled automatically by depending on the appropriate targets. |
| 50 # is_test_apk - Set to 1 if building a test apk. This prevents resources from | 40 # is_test_apk - Set to 1 if building a test apk. This prevents resources from |
| 51 # dependencies from being re-included. | 41 # dependencies from being re-included. |
| 52 # native_libs_paths - The path to any native library to be included in this | 42 # native_libs_paths - The path to any native library to be included in this |
| 53 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of | 43 # target. This should be a path in <(SHARED_LIB_DIR). A stripped copy of |
| 54 # the library will be included in the apk. | 44 # the library will be included in the apk. |
| 55 # resource_dir - The directory for resources. | 45 # resource_dir - The directory for resources. |
| 56 # R_package - A custom Java package to generate the resource file R.java in. | 46 # R_package - A custom Java package to generate the resource file R.java in. |
| 57 # By default, the package given in AndroidManifest.xml will be used. | 47 # By default, the package given in AndroidManifest.xml will be used. |
| 58 # java_strings_grd - The name of the grd file from which to generate localized | 48 # java_strings_grd - The name of the grd file from which to generate localized |
| 59 # strings.xml files, if any. | 49 # strings.xml files, if any. |
| 60 | 50 |
| 61 { | 51 { |
| 62 'variables': { | 52 'variables': { |
| 63 'asset_location%': '', | 53 'asset_location%': '', |
| 64 'additional_input_paths': [], | 54 'additional_input_paths': [], |
| 65 'input_jars_paths': [], | 55 'input_jars_paths': [], |
| 66 'additional_src_dirs': [], | 56 'additional_src_dirs': [], |
| 67 'generated_src_dirs': [], | 57 'generated_src_dirs': [], |
| 68 'app_manifest_version_name%': '<(android_app_version_name)', | 58 'app_manifest_version_name%': '<(android_app_version_name)', |
| 69 'app_manifest_version_code%': '<(android_app_version_code)', | 59 'app_manifest_version_code%': '<(android_app_version_code)', |
| 70 'proguard_enabled%': 'false', | 60 'proguard_enabled%': 'false', |
| 71 'proguard_flags%': '', | 61 'proguard_flags%': '', |
| 72 'native_libs_paths': [], | 62 'native_libs_paths': [], |
| 73 'jar_name%': 'chromium_apk_<(package_name).jar', | 63 'jar_name%': 'chromium_apk_<(_target_name).jar', |
| 74 'resource_dir%':'', | 64 'resource_dir%':'', |
| 75 'R_package%':'', | 65 'R_package%':'', |
| 76 'additional_res_dirs': [], | 66 'additional_res_dirs': [], |
| 77 'additional_res_packages': [], | 67 'additional_res_packages': [], |
| 78 'is_test_apk%': 0, | 68 'is_test_apk%': 0, |
| 79 'java_strings_grd%': '', | 69 'java_strings_grd%': '', |
| 80 'grit_grd_file%': '', | 70 'grit_grd_file%': '', |
| 81 }, | 71 }, |
| 82 'sources': [ | 72 'sources': [ |
| 83 '<@(native_libs_paths)' | 73 '<@(native_libs_paths)' |
| 84 ], | 74 ], |
| 85 # Pass the jar path to the apk's "fake" jar target. This would be better as | 75 # Pass the jar path to the apk's "fake" jar target. This would be better as |
| 86 # direct_dependent_settings, but a variable set by a direct_dependent_settings | 76 # direct_dependent_settings, but a variable set by a direct_dependent_settings |
| 87 # cannot be lifted in a dependent to all_dependent_settings. | 77 # cannot be lifted in a dependent to all_dependent_settings. |
| 88 'all_dependent_settings': { | 78 'all_dependent_settings': { |
| 89 'variables': { | 79 'variables': { |
| 90 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 80 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
| 91 }, | 81 }, |
| 92 }, | 82 }, |
| 93 'rules': [ | 83 'rules': [ |
| 94 { | 84 { |
| 95 'rule_name': 'copy_and_strip_native_libraries', | 85 'rule_name': 'copy_and_strip_native_libraries', |
| 96 'extension': 'so', | 86 'extension': 'so', |
| 97 'variables': { | 87 'variables': { |
| 98 'stripped_library_path': '<(PRODUCT_DIR)/<(package_name)/libs/<(android_
app_abi)/<(RULE_INPUT_ROOT).so', | 88 'stripped_library_path': '<(PRODUCT_DIR)/<(_target_name)/libs/<(android_
app_abi)/<(RULE_INPUT_ROOT).so', |
| 99 }, | 89 }, |
| 100 'outputs': [ | 90 'outputs': [ |
| 101 '<(stripped_library_path)', | 91 '<(stripped_library_path)', |
| 102 ], | 92 ], |
| 103 # There is no way to do 2 actions for each source library in gyp. So to | 93 # There is no way to do 2 actions for each source library in gyp. So to |
| 104 # both strip the library and create the link in <(link_dir) a separate | 94 # both strip the library and create the link in <(link_dir) a separate |
| 105 # script is required. | 95 # script is required. |
| 106 'action': [ | 96 'action': [ |
| 107 '<(DEPTH)/build/android/prepare_library_for_apk', | 97 '<(DEPTH)/build/android/prepare_library_for_apk', |
| 108 '<(android_strip)', | 98 '<(android_strip)', |
| (...skipping 27 matching lines...) Expand all Loading... |
| 136 # resource_ids is unneeded since we don't generate .h headers. | 126 # resource_ids is unneeded since we don't generate .h headers. |
| 137 'grit_resource_ids': '', | 127 'grit_resource_ids': '', |
| 138 }, | 128 }, |
| 139 'includes': ['../build/grit_action.gypi'], | 129 'includes': ['../build/grit_action.gypi'], |
| 140 }, | 130 }, |
| 141 ], | 131 ], |
| 142 }], | 132 }], |
| 143 ], | 133 ], |
| 144 'actions': [ | 134 'actions': [ |
| 145 { | 135 { |
| 146 'action_name': 'ant_<(package_name)_apk', | 136 'action_name': 'ant_<(_target_name)', |
| 147 'message': 'Building <(package_name) apk.', | 137 'message': 'Building <(_target_name).', |
| 148 'inputs': [ | 138 'inputs': [ |
| 149 '<(java_in_dir)/AndroidManifest.xml', | 139 '<(java_in_dir)/AndroidManifest.xml', |
| 150 '<(DEPTH)/build/android/ant/chromium-apk.xml', | 140 '<(DEPTH)/build/android/ant/chromium-apk.xml', |
| 151 '<(DEPTH)/build/android/ant/common.xml', | 141 '<(DEPTH)/build/android/ant/common.xml', |
| 152 '<(DEPTH)/build/android/ant/sdk-targets.xml', | 142 '<(DEPTH)/build/android/ant/sdk-targets.xml', |
| 153 # If there is a separate find for additional_src_dirs, it will find the | 143 # If there is a separate find for additional_src_dirs, it will find the |
| 154 # wrong .java files when additional_src_dirs is empty. | 144 # wrong .java files when additional_src_dirs is empty. |
| 155 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 145 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
| 156 '>@(input_jars_paths)', | 146 '>@(input_jars_paths)', |
| 157 '>@(native_libs_paths)', | 147 '>@(native_libs_paths)', |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 '-DCHROMIUM_SRC=<(ant_build_out)/../..', | 184 '-DCHROMIUM_SRC=<(ant_build_out)/../..', |
| 195 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | 185 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
| 196 '-DPRODUCT_DIR=<(ant_build_out)', | 186 '-DPRODUCT_DIR=<(ant_build_out)', |
| 197 | 187 |
| 198 '-DAPK_NAME=<(apk_name)', | 188 '-DAPK_NAME=<(apk_name)', |
| 199 '-DASSET_DIR=<(asset_location)', | 189 '-DASSET_DIR=<(asset_location)', |
| 200 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | 190 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
| 201 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 191 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
| 202 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 192 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
| 203 '-DJAR_NAME=<(jar_name)', | 193 '-DJAR_NAME=<(jar_name)', |
| 204 '-DPACKAGE_NAME=<(package_name)', | 194 '-DOUT_DIR=<(ant_build_out)/<(_target_name)', |
| 205 '-DRESOURCE_DIR=<(resource_dir)', | 195 '-DRESOURCE_DIR=<(resource_dir)', |
| 206 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', | 196 '-DADDITIONAL_R_TEXT_FILES=>(additional_R_text_files)', |
| 207 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', | 197 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', |
| 208 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', | 198 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', |
| 209 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', | 199 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', |
| 210 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', | 200 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', |
| 211 '-DPROGUARD_FLAGS=>(proguard_flags)', | 201 '-DPROGUARD_FLAGS=>(proguard_flags)', |
| 212 '-DPROGUARD_ENABLED=>(proguard_enabled)', | 202 '-DPROGUARD_ENABLED=>(proguard_enabled)', |
| 213 | 203 |
| 214 '-Dbasedir=<(java_in_dir)', | 204 '-Dbasedir=<(java_in_dir)', |
| 215 '-buildfile', | 205 '-buildfile', |
| 216 '<(DEPTH)/build/android/ant/chromium-apk.xml', | 206 '<(DEPTH)/build/android/ant/chromium-apk.xml', |
| 217 | 207 |
| 218 # Specify CONFIGURATION_NAME as the target for ant to build. The | 208 # Specify CONFIGURATION_NAME as the target for ant to build. The |
| 219 # buildfile will then build the appropriate SDK tools target. | 209 # buildfile will then build the appropriate SDK tools target. |
| 220 '<(CONFIGURATION_NAME)', | 210 '<(CONFIGURATION_NAME)', |
| 221 ] | 211 ] |
| 222 }, | 212 }, |
| 223 ], | 213 ], |
| 224 } | 214 } |
| OLD | NEW |