Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 1 | // Copyright (C) 2019 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 | // How stubs are generated: |
| 16 | // |
| 17 | // raw source files --(metalava)--> stub source files --(javac)--> stub jar files |
| 18 | // |
| 19 | // The metalava conversion is done by droidstub modules *-api-stubs-docs. |
| 20 | // The javac compilation is done by java_library modules android_*_stubs_current. |
| 21 | // The metalava conversion is also responsible for creating API signature files |
| 22 | // and comparing them against the last API signature in api/*-current.txt files |
| 23 | // and also against the latest frozen API signature in prebuilts/sdk/*/*/api/android.txt |
| 24 | // files. |
| 25 | |
| 26 | ///////////////////////////////////////////////////////////////////// |
| 27 | // Common metalava configs |
| 28 | ///////////////////////////////////////////////////////////////////// |
| 29 | |
| 30 | packages_to_document = [ |
| 31 | "android", |
| 32 | "dalvik", |
| 33 | "java", |
| 34 | "javax", |
| 35 | "junit", |
| 36 | "org.apache.http", |
| 37 | "org.json", |
| 38 | "org.w3c.dom", |
| 39 | "org.xml.sax", |
| 40 | "org.xmlpull", |
| 41 | ] |
| 42 | |
| 43 | stubs_defaults { |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 44 | name: "metalava-base-api-stubs-default", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 45 | srcs: [ |
| 46 | ":framework-non-updatable-sources", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 47 | "core/java/**/*.logtags", |
| 48 | ":opt-telephony-srcs", |
| 49 | ":opt-net-voip-srcs", |
| 50 | ":core-current-stubs-source", |
| 51 | ":core_public_api_files", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 52 | ], |
Chen Xu | 546ce5e | 2020-01-10 08:38:31 -0800 | [diff] [blame] | 53 | // TODO(b/147699819): remove below aidl includes. |
| 54 | aidl: { |
| 55 | local_include_dirs: ["telephony/java"], |
| 56 | }, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 57 | libs: ["framework-internal-utils"], |
| 58 | installable: false, |
| 59 | annotations_enabled: true, |
| 60 | previous_api: ":last-released-public-api", |
| 61 | merge_annotations_dirs: [ |
| 62 | "metalava-manual", |
| 63 | ], |
Aurimas Liutikas | 6bb95ad | 2020-03-12 17:06:12 -0700 | [diff] [blame] | 64 | api_levels_annotations_enabled: false, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 65 | filter_packages: packages_to_document, |
| 66 | } |
| 67 | |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 68 | stubs_defaults { |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 69 | name: "metalava-full-api-stubs-default", |
| 70 | defaults: ["metalava-base-api-stubs-default"], |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 71 | srcs: [":framework-updatable-sources"], |
| 72 | sdk_version: "core_platform", |
| 73 | } |
| 74 | |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 75 | stubs_defaults { |
| 76 | name: "metalava-non-updatable-api-stubs-default", |
| 77 | defaults: ["metalava-base-api-stubs-default"], |
Anton Hansson | 92d79fd | 2020-03-20 09:12:52 +0000 | [diff] [blame] | 78 | sdk_version: "core_platform", |
Anton Hansson | 394febc | 2020-04-14 16:35:36 +0100 | [diff] [blame] | 79 | // There are a few classes from modules used as type arguments that |
| 80 | // need to be resolved by metalava. For now, we can use a previously |
| 81 | // finalized stub library to resolve them. If a new class gets added, |
| 82 | // this may be need to be revisited to use a manually maintained stub |
| 83 | // library with empty classes in order to resolve those references. |
| 84 | libs: ["sdk_system_29_android"], |
Anton Hansson | 92d79fd | 2020-03-20 09:12:52 +0000 | [diff] [blame] | 85 | aidl: { |
Anton Hansson | 394febc | 2020-04-14 16:35:36 +0100 | [diff] [blame] | 86 | local_include_dirs: ["apex/media/aidl/stable"], |
Anton Hansson | 92d79fd | 2020-03-20 09:12:52 +0000 | [diff] [blame] | 87 | }, |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 88 | } |
| 89 | |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 90 | ///////////////////////////////////////////////////////////////////// |
| 91 | // *-api-stubs-docs modules providing source files for the stub libraries |
| 92 | ///////////////////////////////////////////////////////////////////// |
| 93 | |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 94 | // api-stubs-docs, system-api-stubs-docs, and test-api-stubs-docs have APIs |
| 95 | // from the non-updatable part of the platform as well as from the updatable |
| 96 | // modules |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 97 | droidstubs { |
| 98 | name: "api-stubs-docs", |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 99 | defaults: ["metalava-full-api-stubs-default"], |
Artur Satayev | 7e7fdde | 2020-03-25 16:45:56 +0000 | [diff] [blame] | 100 | removed_dex_api_filename: "removed-dex.txt", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 101 | arg_files: [ |
| 102 | "core/res/AndroidManifest.xml", |
| 103 | ], |
| 104 | args: metalava_framework_docs_args, |
| 105 | check_api: { |
| 106 | current: { |
| 107 | api_file: "api/current.txt", |
| 108 | removed_api_file: "api/removed.txt", |
| 109 | }, |
| 110 | last_released: { |
| 111 | api_file: ":last-released-public-api", |
| 112 | removed_api_file: "api/removed.txt", |
| 113 | baseline_file: ":public-api-incompatibilities-with-last-released", |
| 114 | }, |
| 115 | api_lint: { |
| 116 | enabled: true, |
| 117 | new_since: ":last-released-public-api", |
| 118 | baseline_file: "api/lint-baseline.txt", |
| 119 | }, |
| 120 | }, |
Anton Hansson | d9a3fee | 2020-03-23 18:08:55 +0000 | [diff] [blame] | 121 | dist: { |
| 122 | targets: ["sdk", "win_sdk"], |
| 123 | dir: "apistubs/android/public/api", |
| 124 | dest: "android.txt", |
| 125 | }, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 126 | jdiff_enabled: true, |
| 127 | } |
| 128 | |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 129 | priv_apps = " " + |
| 130 | "--show-annotation android.annotation.SystemApi\\(" + |
| 131 | "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + |
| 132 | "\\) " |
| 133 | |
| 134 | module_libs = " " + |
| 135 | " --show-annotation android.annotation.SystemApi\\(" + |
| 136 | "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" + |
| 137 | "\\) " |
| 138 | |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 139 | droidstubs { |
| 140 | name: "system-api-stubs-docs", |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 141 | defaults: ["metalava-full-api-stubs-default"], |
Artur Satayev | 7e7fdde | 2020-03-25 16:45:56 +0000 | [diff] [blame] | 142 | removed_dex_api_filename: "system-removed-dex.txt", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 143 | arg_files: [ |
| 144 | "core/res/AndroidManifest.xml", |
| 145 | ], |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 146 | args: metalava_framework_docs_args + priv_apps, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 147 | check_api: { |
| 148 | current: { |
| 149 | api_file: "api/system-current.txt", |
| 150 | removed_api_file: "api/system-removed.txt", |
| 151 | }, |
| 152 | last_released: { |
| 153 | api_file: ":last-released-system-api", |
| 154 | removed_api_file: "api/system-removed.txt", |
| 155 | baseline_file: ":system-api-incompatibilities-with-last-released" |
| 156 | }, |
| 157 | api_lint: { |
| 158 | enabled: true, |
| 159 | new_since: ":last-released-system-api", |
| 160 | baseline_file: "api/system-lint-baseline.txt", |
| 161 | }, |
| 162 | }, |
Anton Hansson | d9a3fee | 2020-03-23 18:08:55 +0000 | [diff] [blame] | 163 | dist: { |
| 164 | targets: ["sdk", "win_sdk"], |
| 165 | dir: "apistubs/android/system/api", |
| 166 | dest: "android.txt", |
| 167 | }, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 168 | jdiff_enabled: true, |
| 169 | } |
| 170 | |
| 171 | droidstubs { |
| 172 | name: "test-api-stubs-docs", |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 173 | defaults: ["metalava-full-api-stubs-default"], |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 174 | arg_files: [ |
| 175 | "core/res/AndroidManifest.xml", |
| 176 | ], |
| 177 | args: metalava_framework_docs_args + " --show-annotation android.annotation.TestApi", |
| 178 | check_api: { |
| 179 | current: { |
| 180 | api_file: "api/test-current.txt", |
| 181 | removed_api_file: "api/test-removed.txt", |
| 182 | }, |
| 183 | api_lint: { |
| 184 | enabled: true, |
| 185 | baseline_file: "api/test-lint-baseline.txt", |
| 186 | }, |
| 187 | }, |
Anton Hansson | d9a3fee | 2020-03-23 18:08:55 +0000 | [diff] [blame] | 188 | dist: { |
| 189 | targets: ["sdk", "win_sdk"], |
| 190 | dir: "apistubs/android/test/api", |
| 191 | dest: "android.txt", |
| 192 | }, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | ///////////////////////////////////////////////////////////////////// |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 196 | // Following droidstubs modules are for extra APIs for modules. |
| 197 | // The framework currently have two more API surfaces for modules: |
| 198 | // @SystemApi(client=MODULE_APPS) and @SystemApi(client=MODULE_LIBRARIES) |
| 199 | ///////////////////////////////////////////////////////////////////// |
| 200 | |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 201 | // TODO(b/146727827) remove the *-api module when we can teach metalava |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 202 | // about the relationship among the API surfaces. Currently, these modules are only to generate |
| 203 | // the API signature files and ensure that the APIs evolve in a backwards compatible manner. |
| 204 | // They however are NOT used for building the API stub. |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 205 | |
| 206 | droidstubs { |
| 207 | name: "module-lib-api", |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 208 | defaults: ["metalava-full-api-stubs-default"], |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 209 | arg_files: ["core/res/AndroidManifest.xml"], |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 210 | args: metalava_framework_docs_args + module_libs, |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 211 | check_api: { |
| 212 | current: { |
| 213 | api_file: "api/module-lib-current.txt", |
| 214 | removed_api_file: "api/module-lib-removed.txt", |
| 215 | }, |
Anton Hansson | 79e35c3 | 2020-02-11 14:36:40 +0000 | [diff] [blame] | 216 | last_released: { |
| 217 | api_file: ":last-released-module-lib-api", |
| 218 | removed_api_file: "api/module-lib-removed.txt", |
| 219 | baseline_file: ":module-lib-api-incompatibilities-with-last-released" |
| 220 | }, |
| 221 | api_lint: { |
| 222 | enabled: true, |
| 223 | new_since: ":last-released-module-lib-api", |
| 224 | baseline_file: "api/module-lib-lint-baseline.txt", |
| 225 | }, |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 226 | }, |
Anton Hansson | d9a3fee | 2020-03-23 18:08:55 +0000 | [diff] [blame] | 227 | dist: { |
| 228 | targets: ["sdk", "win_sdk"], |
| 229 | dir: "apistubs/android/module-lib/api", |
| 230 | dest: "android.txt", |
| 231 | }, |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 232 | } |
| 233 | |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 234 | |
| 235 | // The following droidstub module generates source files for the API stub library for |
| 236 | // modules. Note that it not only includes its own APIs but also other APIs that have |
| 237 | // narrower scope (all @SystemApis, not just the ones with 'client=MODULE_LIBRARIES'). |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 238 | |
| 239 | droidstubs { |
| 240 | name: "module-lib-api-stubs-docs", |
Anton Hansson | 822cdb3 | 2020-03-06 17:16:06 +0000 | [diff] [blame] | 241 | defaults: ["metalava-non-updatable-api-stubs-default"], |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 242 | arg_files: ["core/res/AndroidManifest.xml"], |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 243 | args: metalava_framework_docs_args + priv_apps + module_libs, |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | ///////////////////////////////////////////////////////////////////// |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 247 | // android_*_stubs_current modules are the stubs libraries compiled |
| 248 | // from *-api-stubs-docs |
| 249 | ///////////////////////////////////////////////////////////////////// |
| 250 | |
| 251 | java_defaults { |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 252 | name: "android_defaults_stubs_current", |
Anton Hansson | 08b48bb | 2020-02-08 20:43:19 +0000 | [diff] [blame] | 253 | libs: [ "stub-annotations" ], |
| 254 | static_libs: [ "private-stub-annotations-jar" ], |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 255 | errorprone: { |
| 256 | javacflags: [ |
| 257 | "-XepDisableAllChecks", |
| 258 | ], |
| 259 | }, |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 260 | java_resources: [":notices-for-framework-stubs"], |
| 261 | sdk_version: "none", |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 262 | system_modules: "none", |
| 263 | java_version: "1.8", |
| 264 | compile_dex: true, |
| 265 | } |
| 266 | |
| 267 | java_library_static { |
| 268 | name: "android_stubs_current", |
Anton Hansson | 08b48bb | 2020-02-08 20:43:19 +0000 | [diff] [blame] | 269 | srcs: [ ":api-stubs-docs" ], |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 270 | defaults: ["android_defaults_stubs_current"], |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | java_library_static { |
| 274 | name: "android_system_stubs_current", |
Anton Hansson | 08b48bb | 2020-02-08 20:43:19 +0000 | [diff] [blame] | 275 | srcs: [ ":system-api-stubs-docs" ], |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 276 | defaults: ["android_defaults_stubs_current"], |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | java_library_static { |
| 280 | name: "android_test_stubs_current", |
Anton Hansson | 08b48bb | 2020-02-08 20:43:19 +0000 | [diff] [blame] | 281 | srcs: [ ":test-api-stubs-docs" ], |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 282 | defaults: ["android_defaults_stubs_current"], |
Jiyong Park | e309516 | 2019-12-20 15:30:28 +0900 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | java_library_static { |
Anton Hansson | 1b9cf09 | 2020-01-30 12:09:02 +0000 | [diff] [blame] | 286 | name: "android_module_lib_stubs_current", |
Anton Hansson | 08b48bb | 2020-02-08 20:43:19 +0000 | [diff] [blame] | 287 | srcs: [ ":module-lib-api-stubs-docs" ], |
Anton Hansson | 87c7d28 | 2020-04-09 14:16:37 +0100 | [diff] [blame] | 288 | defaults: ["android_defaults_stubs_current"], |
Anton Hansson | 394febc | 2020-04-14 16:35:36 +0100 | [diff] [blame] | 289 | libs: ["sdk_system_29_android"], |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 290 | } |
| 291 | |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 292 | ///////////////////////////////////////////////////////////////////// |
| 293 | // hwbinder.stubs provides APIs required for building HIDL Java |
| 294 | // libraries. |
| 295 | ///////////////////////////////////////////////////////////////////// |
| 296 | |
| 297 | droidstubs { |
| 298 | name: "hwbinder-stubs-docs", |
| 299 | srcs: [ |
| 300 | "core/java/android/os/HidlSupport.java", |
| 301 | "core/java/android/annotation/IntDef.java", |
| 302 | "core/java/android/annotation/IntRange.java", |
| 303 | "core/java/android/annotation/NonNull.java", |
| 304 | "core/java/android/annotation/SystemApi.java", |
| 305 | "core/java/android/os/HidlMemory.java", |
| 306 | "core/java/android/os/HwBinder.java", |
| 307 | "core/java/android/os/HwBlob.java", |
| 308 | "core/java/android/os/HwParcel.java", |
| 309 | "core/java/android/os/IHwBinder.java", |
| 310 | "core/java/android/os/IHwInterface.java", |
| 311 | "core/java/android/os/DeadObjectException.java", |
| 312 | "core/java/android/os/DeadSystemException.java", |
| 313 | "core/java/android/os/NativeHandle.java", |
| 314 | "core/java/android/os/RemoteException.java", |
| 315 | "core/java/android/util/AndroidException.java", |
| 316 | ], |
| 317 | installable: false, |
| 318 | sdk_version: "core_platform", |
| 319 | annotations_enabled: true, |
| 320 | previous_api: ":last-released-public-api", |
| 321 | merge_annotations_dirs: [ |
| 322 | "metalava-manual", |
| 323 | ], |
Anton Hansson | 81969c2 | 2020-02-03 20:45:56 +0000 | [diff] [blame] | 324 | args: priv_apps, |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | java_library_static { |
| 328 | name: "hwbinder.stubs", |
| 329 | sdk_version: "core_current", |
| 330 | srcs: [ |
| 331 | ":hwbinder-stubs-docs", |
| 332 | ], |
| 333 | } |
| 334 | |
| 335 | ///////////////////////////////////////////////////////////////////// |
Jiyong Park | 7fb4b18 | 2019-12-20 14:35:43 +0900 | [diff] [blame] | 336 | // api/*-current.txt files for use by modules in other directories |
| 337 | // like the CTS test |
| 338 | ///////////////////////////////////////////////////////////////////// |
| 339 | |
| 340 | filegroup { |
| 341 | name: "frameworks-base-api-current.txt", |
| 342 | srcs: [ |
| 343 | "api/current.txt", |
| 344 | ], |
| 345 | } |
| 346 | |
| 347 | filegroup { |
| 348 | name: "frameworks-base-api-system-current.txt", |
| 349 | srcs: [ |
| 350 | "api/system-current.txt", |
| 351 | ], |
| 352 | } |
| 353 | |
| 354 | filegroup { |
| 355 | name: "frameworks-base-api-system-removed.txt", |
| 356 | srcs: [ |
| 357 | "api/system-removed.txt", |
| 358 | ], |
| 359 | } |