Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 1 | // Copyright (C) 2007 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // |
| 16 | // Definitions for building the Java library and associated tests. |
| 17 | // |
| 18 | |
| 19 | // libcore is divided into modules. |
| 20 | // |
| 21 | // The structure of each module is: |
| 22 | // |
| 23 | // src/ |
| 24 | // main/ # To be shipped on every device. |
| 25 | // java/ # Java source for library code. |
| 26 | // native/ # C++ source for library code. |
| 27 | // resources/ # Support files. |
| 28 | // test/ # Built only on demand, for testing. |
| 29 | // java/ # Java source for tests. |
| 30 | // native/ # C++ source for tests (rare). |
| 31 | // resources/ # Support files. |
| 32 | // |
| 33 | // All subdirectories are optional |
| 34 | |
| 35 | build = [ |
| 36 | "openjdk_java_files.bp", |
| 37 | "non_openjdk_java_files.bp", |
Colin Cross | fb7218e | 2017-10-27 17:50:42 +0000 | [diff] [blame] | 38 | "annotated_java_files.bp", |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 39 | ] |
| 40 | |
| 41 | // The Java files and their associated resources. |
| 42 | core_resource_dirs = [ |
| 43 | "luni/src/main/java", |
| 44 | "ojluni/src/main/resources/", |
| 45 | ] |
| 46 | |
| 47 | java_defaults { |
| 48 | name: "libcore_java_defaults", |
| 49 | javacflags: [ |
| 50 | //"-Xlint:all", |
| 51 | //"-Xlint:-serial,-deprecation,-unchecked", |
| 52 | ], |
| 53 | dxflags: ["--core-library"], |
| 54 | no_standard_libs: true, |
Andreas Gampe | 66b3173 | 2018-02-20 09:22:16 -0800 | [diff] [blame] | 55 | errorprone: { |
| 56 | javacflags: [ |
| 57 | "-Xep:MissingOverride:OFF", // Ignore missing @Override. |
| 58 | ], |
| 59 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | // |
| 63 | // Build for the target (device). |
| 64 | // |
| 65 | |
| 66 | java_library { |
| 67 | name: "core-all", |
| 68 | defaults: ["libcore_java_defaults"], |
| 69 | |
| 70 | srcs: [ |
| 71 | ":openjdk_java_files", |
| 72 | ":non_openjdk_java_files", |
| 73 | ":android_icu4j_src_files", |
| 74 | ":openjdk_lambda_stub_files", |
| 75 | ], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 76 | openjdk9: { |
| 77 | srcs: ["luni/src/module/java/module-info.java"], |
| 78 | javacflags: ["--patch-module=java.base=."], |
| 79 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 80 | java_resource_dirs: core_resource_dirs, |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 81 | java_resources: [":android_icu4j_resources"], |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 82 | |
| 83 | required: [ |
| 84 | "tzdata", |
| 85 | "tzlookup.xml", |
| 86 | ], |
| 87 | |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 88 | system_modules: "none", |
| 89 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 90 | installable: false, |
| 91 | } |
| 92 | |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 93 | java_system_modules { |
| 94 | name: "core-all-system-modules", |
| 95 | libs: ["core-all"], |
| 96 | } |
| 97 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 98 | java_library { |
| 99 | name: "core-oj", |
| 100 | defaults: ["libcore_java_defaults"], |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 101 | hostdex: true, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 102 | |
| 103 | srcs: [":openjdk_java_files"], |
| 104 | java_resource_dirs: core_resource_dirs, |
| 105 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 106 | system_modules: "core-all-system-modules", |
| 107 | openjdk9: { |
| 108 | javacflags: ["--patch-module=java.base=."], |
| 109 | }, |
Pete Gillin | 7a7a6d2 | 2017-12-19 14:56:03 +0000 | [diff] [blame] | 110 | jacoco: { |
Pete Gillin | 27ca058 | 2018-01-10 17:04:17 +0000 | [diff] [blame] | 111 | exclude_filter: [ |
Pete Gillin | 3f59bad | 2018-01-30 11:20:29 +0000 | [diff] [blame] | 112 | "java.lang.Class", |
| 113 | "java.lang.Long", |
| 114 | "java.lang.Number", |
| 115 | "java.lang.Object", |
| 116 | "java.lang.String", |
| 117 | "java.lang.invoke.MethodHandle", |
| 118 | "java.lang.ref.Reference", |
| 119 | "java.lang.reflect.Proxy", |
Pete Gillin | b1868ada | 2018-01-17 11:03:10 +0000 | [diff] [blame] | 120 | "java.util.AbstractMap", |
Pete Gillin | 3f59bad | 2018-01-30 11:20:29 +0000 | [diff] [blame] | 121 | "java.util.HashMap", |
| 122 | "java.util.HashMap$Node", |
Pete Gillin | b1868ada | 2018-01-17 11:03:10 +0000 | [diff] [blame] | 123 | "java.util.Map", |
Pete Gillin | 7a7a6d2 | 2017-12-19 14:56:03 +0000 | [diff] [blame] | 124 | ], |
| 125 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 126 | |
| 127 | notice: "ojluni/NOTICE", |
| 128 | |
| 129 | required: [ |
| 130 | "tzdata", |
| 131 | "tzlookup.xml", |
| 132 | ], |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 133 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | // Definitions to make the core library. |
| 137 | java_library { |
| 138 | name: "core-libart", |
| 139 | defaults: ["libcore_java_defaults"], |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 140 | hostdex: true, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 141 | |
| 142 | srcs: [ |
| 143 | ":non_openjdk_java_files", |
| 144 | ":android_icu4j_src_files", |
| 145 | ], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 146 | java_resources: [":android_icu4j_resources"], |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 147 | |
| 148 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 149 | system_modules: "core-all-system-modules", |
| 150 | openjdk9: { |
| 151 | javacflags: ["--patch-module=java.base=."], |
| 152 | }, |
Pete Gillin | 80ebe87 | 2018-02-13 15:21:20 +0000 | [diff] [blame] | 153 | jacoco: { |
| 154 | exclude_filter: [ |
| 155 | "java.lang.DexCache", |
| 156 | "dalvik.system.ClassExt", |
| 157 | ], |
| 158 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 159 | |
| 160 | required: [ |
| 161 | "tzdata", |
| 162 | "tzlookup.xml", |
| 163 | ], |
| 164 | } |
| 165 | |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 166 | // A guaranteed unstripped version of core-oj and core-libart. |
| 167 | // The build system may or may not strip the core-oj and core-libart jars, |
| 168 | // but these will not be stripped. See b/24535627. |
| 169 | java_library { |
| 170 | name: "core-oj-testdex", |
| 171 | static_libs: ["core-oj"], |
| 172 | no_standard_libs: true, |
| 173 | libs: ["core-all"], |
| 174 | system_modules: "core-all-system-modules", |
| 175 | dxflags: ["--core-library"], |
Colin Cross | 485ed36 | 2017-12-05 17:24:22 -0800 | [diff] [blame] | 176 | dex_preopt: { |
| 177 | enabled: false, |
| 178 | }, |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 179 | notice: "ojluni/NOTICE", |
| 180 | required: [ |
| 181 | "tzdata", |
| 182 | "tzlookup.xml", |
| 183 | ], |
| 184 | } |
| 185 | |
| 186 | java_library { |
| 187 | name: "core-libart-testdex", |
| 188 | static_libs: ["core-libart"], |
| 189 | no_standard_libs: true, |
| 190 | libs: ["core-all"], |
| 191 | system_modules: "core-all-system-modules", |
| 192 | dxflags: ["--core-library"], |
Colin Cross | 485ed36 | 2017-12-05 17:24:22 -0800 | [diff] [blame] | 193 | dex_preopt: { |
| 194 | enabled: false, |
| 195 | }, |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 196 | notice: "ojluni/NOTICE", |
| 197 | required: [ |
| 198 | "tzdata", |
| 199 | "tzlookup.xml", |
| 200 | ], |
| 201 | } |
| 202 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 203 | // A library that exists to satisfy javac when |
| 204 | // compiling source code that contains lambdas. |
| 205 | java_library { |
| 206 | name: "core-lambda-stubs", |
| 207 | defaults: ["libcore_java_defaults"], |
| 208 | |
| 209 | srcs: [ |
| 210 | ":openjdk_lambda_stub_files", |
| 211 | ":openjdk_lambda_duplicate_stub_files", |
| 212 | ], |
| 213 | |
| 214 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 215 | system_modules: "core-all-system-modules", |
| 216 | openjdk9: { |
| 217 | javacflags: ["--patch-module=java.base=."], |
| 218 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 219 | |
| 220 | notice: "ojluni/NOTICE", |
| 221 | |
| 222 | installable: false, |
| 223 | include_srcs: true, |
| 224 | } |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 225 | |
| 226 | java_system_modules { |
| 227 | name: "core-system-modules", |
| 228 | libs: [ |
| 229 | "core-oj", |
| 230 | "core-libart", |
| 231 | "core-lambda-stubs", |
| 232 | ], |
| 233 | } |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 234 | |
| 235 | // Build libcore test rules |
| 236 | java_library_static { |
| 237 | name: "core-test-rules", |
| 238 | hostdex: true, |
| 239 | no_framework_libs: true, |
| 240 | srcs: [ |
| 241 | "dalvik/test-rules/src/main/**/*.java", |
| 242 | "test-rules/src/main/**/*.java", |
| 243 | ], |
| 244 | static_libs: ["junit"], |
| 245 | } |
| 246 | |
| 247 | // Make the core-tests-support library. |
| 248 | java_library_static { |
| 249 | name: "core-tests-support", |
| 250 | hostdex: true, |
| 251 | no_framework_libs: true, |
| 252 | srcs: ["support/src/test/java/**/*.java"], |
| 253 | libs: [ |
| 254 | "junit", |
| 255 | "bouncycastle", |
| 256 | ], |
| 257 | static_libs: [ |
| 258 | "bouncycastle-bcpkix", |
| 259 | "bouncycastle-ocsp", |
| 260 | ], |
| 261 | } |
| 262 | |
| 263 | // Make the jsr166-tests library. |
| 264 | java_library_static { |
| 265 | name: "jsr166-tests", |
| 266 | srcs: ["jsr166-tests/src/test/java/**/*.java"], |
| 267 | no_framework_libs: true, |
| 268 | libs: [ |
| 269 | "junit", |
| 270 | ], |
| 271 | } |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 272 | |
| 273 | genrule { |
| 274 | name: "gen-ojluni-jaif-annotated-srcs", |
| 275 | tools: [ |
| 276 | "gen-annotated-java-files-bp", |
| 277 | "soong_zip", |
| 278 | ], |
| 279 | tool_files: [ |
| 280 | ":insert-annotations-to-source", |
| 281 | "annotations/ojluni.jaif", |
| 282 | ], |
| 283 | srcs: [ |
| 284 | ":annotated_ojluni_files", |
| 285 | ], |
| 286 | cmd: "($(location gen-annotated-java-files-bp) $(location annotations/ojluni.jaif) > $(genDir)/annotated_java_files.bp.tmp) && " + |
Nan Zhang | 8c56144 | 2018-02-27 17:21:49 -0800 | [diff] [blame] | 287 | "(diff -u `pwd`/libcore/annotated_java_files.bp $(genDir)/annotated_java_files.bp.tmp || " + |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 288 | "(echo -e \"********************\" >&2; " + |
| 289 | " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " + |
| 290 | " echo -e \"libcore/annotations/generate_annotated_java_files.py libcore/annotations/ojluni.jaif > libcore/annotated_java_files.bp\" >&2; " + |
Nan Zhang | 8c56144 | 2018-02-27 17:21:49 -0800 | [diff] [blame] | 291 | " echo -e \"********************\" >&2; exit 1) ) && " + |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 292 | "(rm $(genDir)/annotated_java_files.bp.tmp) && " + |
Nan Zhang | 8c56144 | 2018-02-27 17:21:49 -0800 | [diff] [blame] | 293 | "(external/annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -d $(genDir) $(location annotations/ojluni.jaif) $(in)) && " + |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 294 | "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))", |
| 295 | out: [ |
| 296 | "ojluni_jaif_annotated_srcs.srcjar", |
| 297 | ], |
| 298 | } |
| 299 | |
| 300 | droiddoc { |
| 301 | name: "core-docs", |
| 302 | srcs: [ |
| 303 | ":openjdk_javadoc_files", |
| 304 | ":non_openjdk_javadoc_files", |
| 305 | ":android_icu4j_src_files_for_docs", |
| 306 | ":gen-ojluni-jaif-annotated-srcs", |
| 307 | ], |
| 308 | exclude_srcs: [ |
| 309 | ":annotated_ojluni_files", |
| 310 | ], |
Dan Willemsen | f2b0458 | 2018-02-26 14:36:32 -0800 | [diff] [blame] | 311 | custom_template: "droiddoc-templates-sdk", |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 312 | hdf: [ |
| 313 | "android.whichdoc offline", |
| 314 | ], |
| 315 | knowntags: [ |
| 316 | "known_oj_tags.txt", |
| 317 | ], |
| 318 | proofread_file: "core-docs-proofread.txt", |
| 319 | todo_file: "core-docs-todo.html", |
| 320 | args: "-offlinemode -title \"libcore\"", |
| 321 | } |