Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | # This file is meant to be included into a target to provide a rule to build |
| 6 | # a JAR file for use on a host in a consistent manner. If a main class is |
| 7 | # specified, this file will also generate an executable to run the jar in the |
| 8 | # output folder's /bin/ directory. |
| 9 | # |
| 10 | # To use this, create a gyp target with the following form: |
| 11 | # { |
| 12 | # 'target_name': 'my_jar', |
| 13 | # 'type': 'none', |
| 14 | # 'variables': { |
| 15 | # 'src_paths': [ |
| 16 | # 'path/to/directory', |
| 17 | # 'path/to/other/directory', |
| 18 | # 'path/to/individual_file.java', |
| 19 | # ... |
| 20 | # ], |
| 21 | # }, |
| 22 | # 'includes': [ 'path/to/this/gypi/file' ], |
| 23 | # } |
| 24 | # |
| 25 | # Required variables: |
| 26 | # src_paths - A list of all paths containing java files that should be |
| 27 | # included in the jar. Paths can be either directories or files. |
| 28 | # Optional/automatic variables: |
| 29 | # excluded_src_paths - A list of all paths that should be excluded from |
| 30 | # the jar. |
| 31 | # generated_src_dirs - Directories containing additional .java files |
| 32 | # generated at build time. |
| 33 | # input_jars_paths - A list of paths to the jars that should be included |
| 34 | # in the classpath. |
| 35 | # main_class - The class containing the main() function that should be called |
| 36 | # when running the jar file. |
| 37 | # jar_excluded_classes - A list of .class files that should be excluded |
| 38 | # from the jar. |
| 39 | |
| 40 | { |
| 41 | 'dependencies': [ |
| 42 | '<(DEPTH)/build/android/setup.gyp:build_output_dirs', |
| 43 | ], |
| 44 | 'variables': { |
| 45 | 'classes_dir': '<(intermediate_dir)/classes', |
| 46 | 'excluded_src_paths': [], |
| 47 | 'generated_src_dirs': [], |
| 48 | 'input_jars_paths': [], |
| 49 | 'intermediate_dir': '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)', |
| 50 | 'jar_dir': '<(PRODUCT_DIR)/lib.java', |
| 51 | 'jar_excluded_classes': [], |
| 52 | 'jar_name': '<(_target_name).jar', |
| 53 | 'jar_path': '<(jar_dir)/<(jar_name)', |
| 54 | 'main_class%': '', |
| 55 | 'stamp': '<(intermediate_dir)/jar.stamp', |
| 56 | 'conditions': [ |
| 57 | ['chromium_code == 0', { |
| 58 | 'enable_errorprone': 0, |
| 59 | }], |
| 60 | ], |
| 61 | 'enable_errorprone%': 0, |
| 62 | 'errorprone_exe_path': '<(PRODUCT_DIR)/bin.java/chromium_errorprone', |
| 63 | 'wrapper_script_name%': '<(_target_name)', |
| 64 | }, |
| 65 | 'all_dependent_settings': { |
| 66 | 'variables': { |
| 67 | 'input_jars_paths': ['<(jar_path)'] |
| 68 | }, |
| 69 | }, |
| 70 | 'actions': [ |
| 71 | { |
| 72 | 'action_name': 'javac_<(_target_name)', |
| 73 | 'message': 'Compiling <(_target_name) java sources', |
| 74 | 'variables': { |
| 75 | 'extra_args': [], |
| 76 | 'extra_inputs': [], |
| 77 | 'java_sources': [ '<!@(find <@(src_paths) -name "*.java")' ], |
| 78 | 'conditions': [ |
| 79 | ['"<(excluded_src_paths)" != ""', { |
| 80 | 'java_sources!': ['<!@(find <@(excluded_src_paths) -name "*.java")'] |
| 81 | }], |
| 82 | ['"<(jar_excluded_classes)" != ""', { |
| 83 | 'extra_args': ['--jar-excluded-classes=<(jar_excluded_classes)'] |
| 84 | }], |
| 85 | ['enable_errorprone == 1', { |
| 86 | 'extra_inputs': [ |
| 87 | '<(errorprone_exe_path)', |
| 88 | ], |
| 89 | 'extra_args': [ '--use-errorprone-path=<(errorprone_exe_path)' ], |
| 90 | }], |
| 91 | ], |
| 92 | }, |
| 93 | 'inputs': [ |
| 94 | '<(DEPTH)/build/android/gyp/util/build_utils.py', |
| 95 | '<(DEPTH)/build/android/gyp/javac.py', |
| 96 | '^@(java_sources)', |
| 97 | '>@(input_jars_paths)', |
| 98 | '<@(extra_inputs)', |
| 99 | ], |
| 100 | 'outputs': [ |
| 101 | '<(jar_path)', |
| 102 | '<(stamp)', |
| 103 | ], |
| 104 | 'action': [ |
| 105 | 'python', '<(DEPTH)/build/android/gyp/javac.py', |
| 106 | '--classpath=>(input_jars_paths)', |
| 107 | '--src-gendirs=>(generated_src_dirs)', |
| 108 | '--chromium-code=<(chromium_code)', |
| 109 | '--stamp=<(stamp)', |
| 110 | '--jar-path=<(jar_path)', |
| 111 | '<@(extra_args)', |
| 112 | '^@(java_sources)', |
| 113 | ], |
| 114 | }, |
| 115 | ], |
| 116 | 'conditions': [ |
| 117 | ['main_class != ""', { |
| 118 | 'actions': [ |
| 119 | { |
| 120 | 'action_name': 'create_java_binary_script_<(_target_name)', |
| 121 | 'message': 'Creating java binary script <(_target_name)', |
| 122 | 'variables': { |
| 123 | 'output': '<(PRODUCT_DIR)/bin/<(wrapper_script_name)', |
| 124 | }, |
| 125 | 'inputs': [ |
| 126 | '<(DEPTH)/build/android/gyp/create_java_binary_script.py', |
| 127 | '<(jar_path)', |
| 128 | ], |
| 129 | 'outputs': [ |
| 130 | '<(output)', |
| 131 | ], |
| 132 | 'action': [ |
| 133 | 'python', '<(DEPTH)/build/android/gyp/create_java_binary_script.py', |
| 134 | '--classpath=>(input_jars_paths)', |
| 135 | '--jar-path=<(jar_path)', |
| 136 | '--output=<(output)', |
| 137 | '--main-class=>(main_class)', |
| 138 | ] |
| 139 | } |
| 140 | ] |
| 141 | }], |
| 142 | ['enable_errorprone == 1', { |
| 143 | 'dependencies': [ |
| 144 | '<(DEPTH)/third_party/errorprone/errorprone.gyp:require_errorprone', |
| 145 | ], |
| 146 | }], |
| 147 | ] |
| 148 | } |
| 149 | |