| 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%':'', |
| 70 'jar_name%': 'chromium_apk_<(package_name).jar', | 75 'jar_name%': 'chromium_apk_<(package_name).jar', |
| 76 'additional_res_dirs': [], |
| 77 'additional_res_packages': [], |
| 78 'is_test_apk%': 0, |
| 71 }, | 79 }, |
| 72 'sources': [ | 80 'sources': [ |
| 73 '<@(native_libs_paths)' | 81 '<@(native_libs_paths)' |
| 74 ], | 82 ], |
| 75 # Pass the jar path to the apk's "fake" jar target. This would be better as | 83 # Pass the jar path to the apk's "fake" jar target. This would be better as |
| 76 # direct_dependent_settings, but a variable set by a direct_dependent_settings | 84 # direct_dependent_settings, but a variable set by a direct_dependent_settings |
| 77 # cannot be lifted in a dependent to all_dependent_settings. | 85 # cannot be lifted in a dependent to all_dependent_settings. |
| 78 'all_dependent_settings': { | 86 'all_dependent_settings': { |
| 79 'variables': { | 87 'variables': { |
| 80 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', | 88 'apk_output_jar_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 # wrong .java files when additional_src_dirs is empty. | 122 # wrong .java files when additional_src_dirs is empty. |
| 115 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', | 123 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
| 116 '>@(input_jars_paths)', | 124 '>@(input_jars_paths)', |
| 117 '>@(native_libs_paths)', | 125 '>@(native_libs_paths)', |
| 118 '>@(additional_input_paths)', | 126 '>@(additional_input_paths)', |
| 119 ], | 127 ], |
| 120 'conditions': [ | 128 'conditions': [ |
| 121 ['resource_dir!=""', { | 129 ['resource_dir!=""', { |
| 122 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")'] | 130 'inputs': ['<!@(find <(java_in_dir)/<(resource_dir) -name "*")'] |
| 123 }], | 131 }], |
| 132 ['is_test_apk == 1', { |
| 133 'variables': { |
| 134 'additional_res_dirs=': [], |
| 135 'additional_res_packages=': [], |
| 136 } |
| 137 }], |
| 124 ], | 138 ], |
| 125 'outputs': [ | 139 'outputs': [ |
| 126 '<(PRODUCT_DIR)/apks/<(apk_name).apk', | 140 '<(PRODUCT_DIR)/apks/<(apk_name).apk', |
| 127 ], | 141 ], |
| 128 'action': [ | 142 'action': [ |
| 129 'ant', | 143 'ant', |
| 130 '-DAPP_ABI=<(android_app_abi)', | 144 '-DAPP_ABI=<(android_app_abi)', |
| 131 '-DANDROID_GDBSERVER=<(android_gdbserver)', | 145 '-DANDROID_GDBSERVER=<(android_gdbserver)', |
| 132 '-DANDROID_SDK=<(android_sdk)', | 146 '-DANDROID_SDK=<(android_sdk)', |
| 133 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 147 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
| 134 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | 148 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', |
| 135 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 149 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
| 136 '-DANDROID_TOOLCHAIN=<(android_toolchain)', | 150 '-DANDROID_TOOLCHAIN=<(android_toolchain)', |
| 137 '-DCHROMIUM_SRC=<(ant_build_out)/../..', | 151 '-DCHROMIUM_SRC=<(ant_build_out)/../..', |
| 138 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | 152 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
| 139 '-DPRODUCT_DIR=<(ant_build_out)', | 153 '-DPRODUCT_DIR=<(ant_build_out)', |
| 140 | 154 |
| 141 '-DAPK_NAME=<(apk_name)', | 155 '-DAPK_NAME=<(apk_name)', |
| 142 '-DASSET_DIR=<(asset_location)', | 156 '-DASSET_DIR=<(asset_location)', |
| 143 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | 157 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
| 144 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', | 158 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
| 145 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | 159 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
| 146 '-DJAR_NAME=<(jar_name)', | 160 '-DJAR_NAME=<(jar_name)', |
| 147 '-DPACKAGE_NAME=<(package_name)', | 161 '-DPACKAGE_NAME=<(package_name)', |
| 148 '-DRESOURCE_DIR=<(resource_dir)', | 162 '-DRESOURCE_DIR=<(resource_dir)', |
| 163 '-DADDITIONAL_RES_DIRS=>(additional_res_dirs)', |
| 164 '-DADDITIONAL_RES_PACKAGES=>(additional_res_packages)', |
| 149 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', | 165 '-DAPP_MANIFEST_VERSION_NAME=<(app_manifest_version_name)', |
| 150 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', | 166 '-DAPP_MANIFEST_VERSION_CODE=<(app_manifest_version_code)', |
| 151 '-DPROGUARD_FLAGS=>(proguard_flags)', | 167 '-DPROGUARD_FLAGS=>(proguard_flags)', |
| 152 '-DPROGUARD_ENABLED=>(proguard_enabled)', | 168 '-DPROGUARD_ENABLED=>(proguard_enabled)', |
| 153 | 169 |
| 154 '-Dbasedir=<(java_in_dir)', | 170 '-Dbasedir=<(java_in_dir)', |
| 155 '-buildfile', | 171 '-buildfile', |
| 156 '<(DEPTH)/build/android/ant/chromium-apk.xml', | 172 '<(DEPTH)/build/android/ant/chromium-apk.xml', |
| 157 | 173 |
| 158 # Specify CONFIGURATION_NAME as the target for ant to build. The | 174 # Specify CONFIGURATION_NAME as the target for ant to build. The |
| 159 # buildfile will then build the appropriate SDK tools target. | 175 # buildfile will then build the appropriate SDK tools target. |
| 160 '<(CONFIGURATION_NAME)', | 176 '<(CONFIGURATION_NAME)', |
| 161 ] | 177 ] |
| 162 }, | 178 }, |
| 163 ], | 179 ], |
| 164 } | 180 } |
| OLD | NEW |