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 Java in a consistent manner. | 6 # to build Java 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_java', | 10 # 'target_name': 'my-package_java', |
11 # 'type': 'none', | 11 # 'type': 'none', |
12 # 'variables': { | 12 # 'variables': { |
13 # 'package_name': 'my-package', | 13 # 'package_name': 'my-package', |
14 # 'java_in_dir': 'path/to/package/root', | 14 # 'java_in_dir': 'path/to/package/root', |
15 # }, | 15 # }, |
16 # 'includes': ['path/to/this/gypi/file'], | 16 # 'includes': ['path/to/this/gypi/file'], |
17 # } | 17 # } |
18 # | 18 # |
19 # Note that this assumes that there's ant buildfile with package_name in | 19 # The generated jar-file will be: |
20 # java_in_dir. So if if you have package_name="base" and | 20 # <(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar |
21 # java_in_dir="base/android/java" you should have a directory structure like: | |
22 # | 21 # |
23 # base/android/java/base.xml | 22 # Required variables: |
24 # base/android/java/org/chromium/base/Foo.java | 23 # package_name - Used to name the intermediate output directory and in the |
25 # base/android/java/org/chromium/base/Bar.java | 24 # names of some output files. |
26 # | 25 # java_in_dir - The top-level java directory. The src should be in |
27 # Finally, the generated jar-file will be: | 26 # <java_in_dir>/src. |
28 # <(PRODUCT_DIR)/lib.java/chromium_base.jar | 27 # Optional/automatic variables: |
| 28 # additional_input_paths - These paths will be included in the 'inputs' list to |
| 29 # ensure that this target is rebuilt when one of these paths changes. |
| 30 # additional_src_dirs - Additional directories with .java files to be compiled |
| 31 # and included in the output of this target. |
| 32 # generated_src_dirs - Same as additional_src_dirs except used for .java files |
| 33 # that are generated at build time. This should be set automatically by a |
| 34 # target's dependencies. The .java files in these directories are not |
| 35 # included in the 'inputs' list (unlike additional_src_dirs). |
| 36 # input_jars_paths - The path to jars to be included in the classpath. This |
| 37 # should be filled automatically by depending on the appropriate targets. |
29 | 38 |
30 { | 39 { |
31 'dependencies': [ | 40 'dependencies': [ |
32 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' | 41 '<(DEPTH)/build/build_output_dirs_android.gyp:build_output_dirs' |
33 ], | 42 ], |
34 'direct_dependent_settings': { | 43 'direct_dependent_settings': { |
35 'variables': { | 44 'variables': { |
36 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
'], | 45 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar
'], |
37 }, | 46 }, |
38 }, | 47 }, |
39 'variables': { | 48 'variables': { |
40 'input_jars_paths': [], | 49 'input_jars_paths': [], |
41 'additional_src_dirs': [], | 50 'additional_src_dirs': [], |
42 'additional_input_paths': [], | 51 'additional_input_paths': [], |
| 52 'generated_src_dirs': [], |
43 }, | 53 }, |
44 'actions': [ | 54 'actions': [ |
45 { | 55 { |
46 'action_name': 'ant_<(package_name)', | 56 'action_name': 'ant_<(package_name)', |
47 'message': 'Building <(package_name) java sources.', | 57 'message': 'Building <(package_name) java sources.', |
48 'inputs': [ | 58 'inputs': [ |
49 'android/ant/common.xml', | 59 'android/ant/common.xml', |
50 'android/ant/chromium-jars.xml', | 60 'android/ant/chromium-jars.xml', |
51 '<!@(find <(java_in_dir) -name "*.java")', | 61 '>!@(find >(java_in_dir) >(additional_src_dirs) -name "*.java")', |
52 '>@(input_jars_paths)', | 62 '>@(input_jars_paths)', |
53 '>@(additional_input_paths)', | 63 '>@(additional_input_paths)', |
54 ], | 64 ], |
55 'outputs': [ | 65 'outputs': [ |
56 '<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar', | 66 '<(PRODUCT_DIR)/lib.java/chromium_<(package_name).jar', |
57 ], | 67 ], |
58 'action': [ | 68 'action': [ |
59 'ant', | 69 'ant', |
60 '-DPRODUCT_DIR=<(ant_build_out)', | |
61 '-DPACKAGE_NAME=<(package_name)', | |
62 '-DINPUT_JARS_PATHS=>(input_jars_paths)', | |
63 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', | |
64 '-DANDROID_SDK=<(android_sdk)', | 70 '-DANDROID_SDK=<(android_sdk)', |
65 '-DANDROID_SDK_ROOT=<(android_sdk_root)', | 71 '-DANDROID_SDK_ROOT=<(android_sdk_root)', |
66 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', | 72 '-DANDROID_SDK_TOOLS=<(android_sdk_tools)', |
67 '-DANDROID_SDK_VERSION=<(android_sdk_version)', | 73 '-DANDROID_SDK_VERSION=<(android_sdk_version)', |
68 '-DANDROID_GDBSERVER=<(android_gdbserver)', | 74 '-DANDROID_GDBSERVER=<(android_gdbserver)', |
| 75 '-DPRODUCT_DIR=<(ant_build_out)', |
| 76 |
| 77 '-DADDITIONAL_SRC_DIRS=>(additional_src_dirs)', |
| 78 '-DGENERATED_SRC_DIRS=>(generated_src_dirs)', |
| 79 '-DINPUT_JARS_PATHS=>(input_jars_paths)', |
| 80 '-DPACKAGE_NAME=<(package_name)', |
| 81 |
69 '-Dbasedir=<(java_in_dir)', | 82 '-Dbasedir=<(java_in_dir)', |
70 '-buildfile', | 83 '-buildfile', |
71 '<(DEPTH)/build/android/ant/chromium-jars.xml' | 84 '<(DEPTH)/build/android/ant/chromium-jars.xml' |
72 ] | 85 ] |
73 }, | 86 }, |
74 ], | 87 ], |
75 } | 88 } |
OLD | NEW |