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/chromium/base/Foo.java |
28 # content/shell/android/java/src/chromium/base/Bar.java | 28 # content/shell/android/java/src/chromium/base/Bar.java |
| 29 # |
| 30 # Required variables: |
| 31 # package_name - Used to name the intermediate output directory and in the |
| 32 # names of some output files. |
| 33 # apk_name - The final apk will be named <apk_name>-debug.apk (or -release) |
| 34 # java_in_dir - The top-level java directory. The src should be in |
| 35 # <java_in_dir>/src. |
| 36 # resource_dir - The directory for resources. |
| 37 # Optional/automatic variables: |
| 38 # additional_input_paths - These paths will be included in the 'inputs' list to |
| 39 # ensure that this target is rebuilt when one of these paths changes. |
| 40 # additional_src_dirs - Additional directories with .java files to be compiled |
| 41 # and included in the output of this target. |
| 42 # generated_src_dirs - Same as additional_src_dirs except used for .java files |
| 43 # that are generated at build time. This should be set automatically by a |
| 44 # target's dependencies. The .java files in these directories are not |
| 45 # included in the 'inputs' list (unlike additional_src_dirs). |
| 46 # input_jars_paths - The path to jars to be included in the classpath. This |
| 47 # should be filled automatically by depending on the appropriate targets. |
| 48 # native_libs_paths - The path to any native library to be included in this |
| 49 # target. |
29 | 50 |
30 { | 51 { |
31 'variables': { | 52 'variables': { |
32 'input_jars_paths': [], | 53 'input_jars_paths': [], |
33 'native_libs_paths': [], | 54 'native_libs_paths': [], |
| 55 'additional_input_paths': [], |
34 'additional_src_dirs': [], | 56 'additional_src_dirs': [], |
35 'additional_input_paths': [], | 57 'generated_src_dirs': [], |
36 }, | 58 }, |
37 'actions': [ | 59 'actions': [ |
38 { | 60 { |
39 'action_name': 'ant_<(package_name)_apk', | 61 'action_name': 'ant_<(package_name)_apk', |
40 'message': 'Building <(package_name) apk.', | 62 'message': 'Building <(package_name) apk.', |
41 'inputs': [ | 63 'inputs': [ |
42 '<(java_in_dir)/<(package_name)_apk.xml', | 64 '<(java_in_dir)/<(package_name)_apk.xml', |
43 '<(java_in_dir)/AndroidManifest.xml', | 65 '<(java_in_dir)/AndroidManifest.xml', |
44 '<(DEPTH)/build/android/ant/common.xml', | 66 '<(DEPTH)/build/android/ant/common.xml', |
45 '<(DEPTH)/build/android/ant/sdk-targets.xml', | 67 '<(DEPTH)/build/android/ant/sdk-targets.xml', |
46 '<!@(find <(java_in_dir) -name "*.java")', | 68 # If there is a separate find for additonal_src_dirs, it will find the |
| 69 # wrong .java files when additional_src_dirs is empty. |
| 70 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
47 '<!@(find <(java_in_dir)/<(resource_dir) -name "*")', | 71 '<!@(find <(java_in_dir)/<(resource_dir) -name "*")', |
48 '>@(input_jars_paths)', | 72 '>@(input_jars_paths)', |
49 '>@(native_libs_paths)', | 73 '>@(native_libs_paths)', |
50 '>@(additional_input_paths)', | 74 '>@(additional_input_paths)', |
51 ], | 75 ], |
52 'outputs': [ | 76 'outputs': [ |
53 '<(PRODUCT_DIR)/apks/<(apk_name)-debug.apk', | 77 '<(PRODUCT_DIR)/apks/<(apk_name)-debug.apk', |
54 ], | 78 ], |
55 'action': [ | 79 'action': [ |
56 'ant', | 80 'ant', |
57 '-DPRODUCT_DIR=<(ant_build_out)', | |
58 '-DAPP_ABI=<(android_app_abi)', | 81 '-DAPP_ABI=<(android_app_abi)', |
59 '-DANDROID_GDBSERVER=<(android_gdbserver)', | 82 '-DANDROID_GDBSERVER=<(android_gdbserver)', |
60 '-DANDROID_SDK=<(android_sdk)', | 83 '-DANDROID_SDK=<(android_sdk)', |
61 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 84 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
62 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | 85 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', |
63 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 86 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
64 '-DANDROID_TOOLCHAIN=<(android_toolchain)', | 87 '-DANDROID_TOOLCHAIN=<(android_toolchain)', |
| 88 '-DCHROMIUM_SRC=<(ant_build_out)/../..', |
| 89 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', |
| 90 '-DPRODUCT_DIR=<(ant_build_out)', |
| 91 |
| 92 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
| 93 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
| 94 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
65 '-DPACKAGE_NAME=<(package_name)', | 95 '-DPACKAGE_NAME=<(package_name)', |
66 '-DCONFIGURATION_NAME=<(CONFIGURATION_NAME)', | |
67 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | |
68 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | |
69 '-DCHROMIUM_SRC=<(ant_build_out)/../..', | |
70 '-DRESOURCE_DIR=<(resource_dir)', | 96 '-DRESOURCE_DIR=<(resource_dir)', |
| 97 |
71 '-buildfile', | 98 '-buildfile', |
72 '<(java_in_dir)/<(package_name)_apk.xml' | 99 '<(java_in_dir)/<(package_name)_apk.xml' |
73 ] | 100 ] |
74 }, | 101 }, |
75 ], | 102 ], |
76 } | 103 } |
OLD | NEW |