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. |
Andreas Gampe | 24a2017 | 2018-06-13 11:28:45 -0700 | [diff] [blame] | 58 | "-Xep:ConstantOverflow:WARN", // Known constant overflow in SplittableRandom |
Andreas Gampe | 66b3173 | 2018-02-20 09:22:16 -0800 | [diff] [blame] | 59 | ], |
| 60 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | // |
| 64 | // Build for the target (device). |
| 65 | // |
| 66 | |
| 67 | java_library { |
| 68 | name: "core-all", |
| 69 | defaults: ["libcore_java_defaults"], |
| 70 | |
| 71 | srcs: [ |
| 72 | ":openjdk_java_files", |
| 73 | ":non_openjdk_java_files", |
| 74 | ":android_icu4j_src_files", |
| 75 | ":openjdk_lambda_stub_files", |
| 76 | ], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 77 | openjdk9: { |
| 78 | srcs: ["luni/src/module/java/module-info.java"], |
| 79 | javacflags: ["--patch-module=java.base=."], |
| 80 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 81 | java_resource_dirs: core_resource_dirs, |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 82 | java_resources: [":android_icu4j_resources"], |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 83 | |
| 84 | required: [ |
| 85 | "tzdata", |
| 86 | "tzlookup.xml", |
| 87 | ], |
| 88 | |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 89 | system_modules: "none", |
| 90 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 91 | installable: false, |
| 92 | } |
| 93 | |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 94 | java_system_modules { |
| 95 | name: "core-all-system-modules", |
| 96 | libs: ["core-all"], |
| 97 | } |
| 98 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 99 | java_library { |
| 100 | name: "core-oj", |
| 101 | defaults: ["libcore_java_defaults"], |
Colin Cross | 5b75cdd | 2018-06-27 11:00:13 -0700 | [diff] [blame] | 102 | installable: true, |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 103 | hostdex: true, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 104 | |
| 105 | srcs: [":openjdk_java_files"], |
| 106 | java_resource_dirs: core_resource_dirs, |
| 107 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 108 | system_modules: "core-all-system-modules", |
| 109 | openjdk9: { |
| 110 | javacflags: ["--patch-module=java.base=."], |
| 111 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 112 | |
| 113 | notice: "ojluni/NOTICE", |
| 114 | |
| 115 | required: [ |
| 116 | "tzdata", |
| 117 | "tzlookup.xml", |
| 118 | ], |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 119 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | // Definitions to make the core library. |
| 123 | java_library { |
| 124 | name: "core-libart", |
| 125 | defaults: ["libcore_java_defaults"], |
Colin Cross | 5b75cdd | 2018-06-27 11:00:13 -0700 | [diff] [blame] | 126 | installable: true, |
Colin Cross | bb180be | 2017-10-09 14:54:53 -0700 | [diff] [blame] | 127 | hostdex: true, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 128 | |
| 129 | srcs: [ |
| 130 | ":non_openjdk_java_files", |
| 131 | ":android_icu4j_src_files", |
| 132 | ], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 133 | java_resources: [":android_icu4j_resources"], |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 134 | |
| 135 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 136 | system_modules: "core-all-system-modules", |
| 137 | openjdk9: { |
| 138 | javacflags: ["--patch-module=java.base=."], |
| 139 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 140 | |
| 141 | required: [ |
| 142 | "tzdata", |
| 143 | "tzlookup.xml", |
| 144 | ], |
| 145 | } |
| 146 | |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 147 | // A guaranteed unstripped version of core-oj and core-libart. |
| 148 | // The build system may or may not strip the core-oj and core-libart jars, |
| 149 | // but these will not be stripped. See b/24535627. |
| 150 | java_library { |
| 151 | name: "core-oj-testdex", |
Colin Cross | 5b75cdd | 2018-06-27 11:00:13 -0700 | [diff] [blame] | 152 | installable: true, |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 153 | static_libs: ["core-oj"], |
| 154 | no_standard_libs: true, |
| 155 | libs: ["core-all"], |
| 156 | system_modules: "core-all-system-modules", |
| 157 | dxflags: ["--core-library"], |
Colin Cross | 485ed36 | 2017-12-05 17:24:22 -0800 | [diff] [blame] | 158 | dex_preopt: { |
| 159 | enabled: false, |
| 160 | }, |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 161 | notice: "ojluni/NOTICE", |
| 162 | required: [ |
| 163 | "tzdata", |
| 164 | "tzlookup.xml", |
| 165 | ], |
| 166 | } |
| 167 | |
| 168 | java_library { |
| 169 | name: "core-libart-testdex", |
Colin Cross | 5b75cdd | 2018-06-27 11:00:13 -0700 | [diff] [blame] | 170 | installable: true, |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 171 | static_libs: ["core-libart"], |
| 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 | |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 186 | // A library that exists to satisfy javac when |
| 187 | // compiling source code that contains lambdas. |
| 188 | java_library { |
| 189 | name: "core-lambda-stubs", |
| 190 | defaults: ["libcore_java_defaults"], |
| 191 | |
| 192 | srcs: [ |
| 193 | ":openjdk_lambda_stub_files", |
| 194 | ":openjdk_lambda_duplicate_stub_files", |
| 195 | ], |
| 196 | |
| 197 | libs: ["core-all"], |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 198 | system_modules: "core-all-system-modules", |
| 199 | openjdk9: { |
| 200 | javacflags: ["--patch-module=java.base=."], |
| 201 | }, |
Colin Cross | af0b54c | 2017-09-27 17:22:32 -0700 | [diff] [blame] | 202 | |
| 203 | notice: "ojluni/NOTICE", |
| 204 | |
| 205 | installable: false, |
| 206 | include_srcs: true, |
| 207 | } |
Colin Cross | a4d9fc4 | 2017-09-29 18:04:37 -0700 | [diff] [blame] | 208 | |
| 209 | java_system_modules { |
| 210 | name: "core-system-modules", |
| 211 | libs: [ |
| 212 | "core-oj", |
| 213 | "core-libart", |
| 214 | "core-lambda-stubs", |
| 215 | ], |
| 216 | } |
Colin Cross | 3c6c2e2 | 2017-10-18 13:24:52 -0700 | [diff] [blame] | 217 | |
| 218 | // Build libcore test rules |
| 219 | java_library_static { |
| 220 | name: "core-test-rules", |
| 221 | hostdex: true, |
| 222 | no_framework_libs: true, |
| 223 | srcs: [ |
| 224 | "dalvik/test-rules/src/main/**/*.java", |
| 225 | "test-rules/src/main/**/*.java", |
| 226 | ], |
| 227 | static_libs: ["junit"], |
| 228 | } |
| 229 | |
| 230 | // Make the core-tests-support library. |
| 231 | java_library_static { |
| 232 | name: "core-tests-support", |
| 233 | hostdex: true, |
| 234 | no_framework_libs: true, |
| 235 | srcs: ["support/src/test/java/**/*.java"], |
| 236 | libs: [ |
| 237 | "junit", |
| 238 | "bouncycastle", |
| 239 | ], |
| 240 | static_libs: [ |
| 241 | "bouncycastle-bcpkix", |
| 242 | "bouncycastle-ocsp", |
| 243 | ], |
| 244 | } |
| 245 | |
| 246 | // Make the jsr166-tests library. |
| 247 | java_library_static { |
| 248 | name: "jsr166-tests", |
| 249 | srcs: ["jsr166-tests/src/test/java/**/*.java"], |
| 250 | no_framework_libs: true, |
| 251 | libs: [ |
| 252 | "junit", |
| 253 | ], |
| 254 | } |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 255 | |
| 256 | genrule { |
| 257 | name: "gen-ojluni-jaif-annotated-srcs", |
| 258 | tools: [ |
| 259 | "gen-annotated-java-files-bp", |
| 260 | "soong_zip", |
| 261 | ], |
| 262 | tool_files: [ |
| 263 | ":insert-annotations-to-source", |
| 264 | "annotations/ojluni.jaif", |
| 265 | ], |
| 266 | srcs: [ |
| 267 | ":annotated_ojluni_files", |
| 268 | ], |
| 269 | 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] | 270 | "(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] | 271 | "(echo -e \"********************\" >&2; " + |
| 272 | " echo -e \"annotated_java_files.bp needs regenerating. Please run:\" >&2; " + |
| 273 | " 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] | 274 | " echo -e \"********************\" >&2; exit 1) ) && " + |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 275 | "(rm $(genDir)/annotated_java_files.bp.tmp) && " + |
Nan Zhang | 8c56144 | 2018-02-27 17:21:49 -0800 | [diff] [blame] | 276 | "(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] | 277 | "($(location soong_zip) -o $(out) -C $(genDir) -D $(genDir))", |
| 278 | out: [ |
| 279 | "ojluni_jaif_annotated_srcs.srcjar", |
| 280 | ], |
| 281 | } |
| 282 | |
Nan Zhang | 3824a82 | 2018-03-21 21:41:02 +0000 | [diff] [blame] | 283 | // |
| 284 | // Local droiddoc for faster libcore testing |
| 285 | // |
| 286 | // Run with: |
| 287 | // mm -j32 core-docs |
| 288 | // |
| 289 | // Main output: |
| 290 | // ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/reference/packages.html |
| 291 | // |
| 292 | // All text for proofreading (or running tools over): |
| 293 | // ../out/soong/.intermediates/libcore/core-docs/android_common/core-docs-proofread.txt |
| 294 | // |
| 295 | // TODO list of missing javadoc, etc: |
| 296 | // ../out/soong/.intermediates/libcore/core-docs/android_common/docs/out/core-docs-todo.html |
| 297 | // |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 298 | droiddoc { |
| 299 | name: "core-docs", |
| 300 | srcs: [ |
| 301 | ":openjdk_javadoc_files", |
| 302 | ":non_openjdk_javadoc_files", |
| 303 | ":android_icu4j_src_files_for_docs", |
| 304 | ":gen-ojluni-jaif-annotated-srcs", |
| 305 | ], |
| 306 | exclude_srcs: [ |
| 307 | ":annotated_ojluni_files", |
| 308 | ], |
Dan Willemsen | f2b0458 | 2018-02-26 14:36:32 -0800 | [diff] [blame] | 309 | custom_template: "droiddoc-templates-sdk", |
Nan Zhang | 65f27a3 | 2018-01-05 10:41:46 -0800 | [diff] [blame] | 310 | hdf: [ |
| 311 | "android.whichdoc offline", |
| 312 | ], |
| 313 | knowntags: [ |
| 314 | "known_oj_tags.txt", |
| 315 | ], |
| 316 | proofread_file: "core-docs-proofread.txt", |
| 317 | todo_file: "core-docs-todo.html", |
| 318 | args: "-offlinemode -title \"libcore\"", |
| 319 | } |
Nan Zhang | d55722b | 2018-02-27 15:08:20 -0800 | [diff] [blame] | 320 | |
| 321 | filegroup { |
| 322 | name: "known-oj-tags", |
| 323 | srcs: [ |
| 324 | "known_oj_tags.txt", |
| 325 | ], |
| 326 | } |
Nan Zhang | 602fc0e | 2018-03-22 16:14:22 -0700 | [diff] [blame] | 327 | |
| 328 | droiddoc { |
| 329 | name: "core-current-stubs-gen-docs", |
| 330 | srcs: [ |
| 331 | ":openjdk_javadoc_files", |
| 332 | ":non_openjdk_javadoc_files", |
| 333 | ":android_icu4j_src_files_for_docs", |
| 334 | ":gen-ojluni-jaif-annotated-srcs", |
| 335 | ], |
| 336 | exclude_srcs: [ |
| 337 | ":annotated_ojluni_files", |
| 338 | ], |
| 339 | custom_template: "droiddoc-templates-sdk", |
| 340 | installable: false, |
| 341 | no_framework_libs: true, |
| 342 | args: "-nodocs", |
| 343 | } |
| 344 | |
| 345 | java_library_static { |
| 346 | name: "core.current.stubs", |
| 347 | srcs: [ |
| 348 | ":core-current-stubs-gen-docs", |
| 349 | ], |
| 350 | errorprone: { |
| 351 | javacflags: [ |
| 352 | "-Xep:MissingOverride:OFF", |
| 353 | ], |
| 354 | }, |
Tobias Thierer | 496a938 | 2018-06-12 14:09:11 +0100 | [diff] [blame] | 355 | openjdk9: { |
| 356 | javacflags: ["--patch-module=java.base=."], |
| 357 | }, |
Nan Zhang | 602fc0e | 2018-03-22 16:14:22 -0700 | [diff] [blame] | 358 | no_standard_libs: true, |
| 359 | system_modules: "none", |
| 360 | } |