• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2020 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
15package {
16    default_visibility: ["//visibility:private"],
17    // See: http://go/android-license-faq
18    // A large-scale-change added 'default_applicable_licenses' to import
19    // all of the 'license_kinds' from "frameworks_base_license"
20    // to get the below license kinds:
21    //   SPDX-license-identifier-Apache-2.0
22    //   SPDX-license-identifier-MIT
23    //   SPDX-license-identifier-Unicode-DFS
24    default_applicable_licenses: ["frameworks_base_license"],
25}
26
27bootstrap_go_package {
28    name: "soong-api",
29    pkgPath: "android/soong/api",
30    deps: [
31        "blueprint",
32        "soong",
33        "soong-android",
34        "soong-genrule",
35        "soong-java",
36    ],
37    srcs: ["api.go"],
38    pluginFor: ["soong_build"],
39}
40
41python_binary_host {
42    name: "merge_annotation_zips",
43    srcs: ["merge_annotation_zips.py"],
44}
45
46python_test_host {
47    name: "merge_annotation_zips_test",
48    main: "merge_annotation_zips_test.py",
49    srcs: [
50        "merge_annotation_zips.py",
51        "merge_annotation_zips_test.py",
52    ],
53    test_options: {
54        unit_test: true,
55    },
56}
57
58metalava_cmd = "$(location metalava)"
59// Silence reflection warnings. See b/168689341
60metalava_cmd += " -J--add-opens=java.base/java.util=ALL-UNNAMED "
61metalava_cmd += " --quiet "
62
63soong_config_module_type {
64    name: "enable_crashrecovery_module",
65    module_type: "combined_apis_defaults",
66    config_namespace: "ANDROID",
67    bool_variables: ["release_crashrecovery_module"],
68    properties: [
69        "bootclasspath",
70        "system_server_classpath",
71    ],
72}
73
74soong_config_bool_variable {
75    name: "release_crashrecovery_module",
76}
77
78enable_crashrecovery_module {
79    name: "crashrecovery_module_defaults",
80    soong_config_variables: {
81        release_crashrecovery_module: {
82            bootclasspath: [
83                "framework-crashrecovery",
84            ],
85            system_server_classpath: [
86                "service-crashrecovery",
87            ],
88        },
89    },
90}
91
92combined_apis {
93    name: "frameworks-base-api",
94    defaults: [
95        "crashrecovery_module_defaults",
96    ],
97    bootclasspath: [
98        "android.net.ipsec.ike",
99        "art.module.public.api",
100        "conscrypt.module.public.api",
101        "framework-adservices",
102        "framework-appsearch",
103        "framework-bluetooth",
104        "framework-configinfrastructure",
105        "framework-connectivity",
106        "framework-connectivity-t",
107        "framework-devicelock",
108        "framework-graphics",
109        "framework-healthfitness",
110        "framework-location",
111        "framework-media",
112        "framework-mediaprovider",
113        "framework-nfc",
114        "framework-ondevicepersonalization",
115        "framework-pdf",
116        "framework-pdf-v",
117        "framework-permission",
118        "framework-permission-s",
119        "framework-profiling",
120        "framework-scheduling",
121        "framework-sdkextensions",
122        "framework-statsd",
123        "framework-sdksandbox",
124        "framework-tethering",
125        "framework-uwb",
126        "framework-virtualization",
127        "framework-wifi",
128        "i18n.module.public.api",
129    ],
130    system_server_classpath: [
131        "service-art",
132        "service-configinfrastructure",
133        "service-healthfitness",
134        "service-media-s",
135        "service-permission",
136        "service-rkp",
137        "service-sdksandbox",
138    ],
139}
140
141genrule {
142    name: "frameworks-base-api-current-compat",
143    srcs: [
144        ":android.api.public.latest",
145        ":android-incompatibilities.api.public.latest",
146        ":frameworks-base-api-current.txt",
147    ],
148    out: ["updated-baseline.txt"],
149    tools: ["metalava"],
150    cmd: metalava_cmd +
151        "--check-compatibility:api:released $(location :android.api.public.latest) " +
152        "--baseline:compatibility:released $(location :android-incompatibilities.api.public.latest) " +
153        "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +
154        "$(location :frameworks-base-api-current.txt)",
155}
156
157genrule {
158    name: "frameworks-base-api-system-current-compat",
159    srcs: [
160        ":android.api.system.latest",
161        ":android-incompatibilities.api.system.latest",
162        ":frameworks-base-api-current.txt",
163        ":frameworks-base-api-system-current.txt",
164    ],
165    out: ["updated-baseline.txt"],
166    tools: ["metalava"],
167    cmd: metalava_cmd +
168        "--check-compatibility:api:released $(location :android.api.system.latest) " +
169        "--check-compatibility:base $(location :frameworks-base-api-current.txt) " +
170        "--baseline:compatibility:released $(location :android-incompatibilities.api.system.latest) " +
171        "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +
172        "$(location :frameworks-base-api-system-current.txt)",
173}
174
175genrule {
176    name: "frameworks-base-api-module-lib-current-compat",
177    srcs: [
178        ":android.api.module-lib.latest",
179        ":android-incompatibilities.api.module-lib.latest",
180        ":frameworks-base-api-current.txt",
181        ":frameworks-base-api-module-lib-current.txt",
182    ],
183    out: ["updated-baseline.txt"],
184    tools: ["metalava"],
185    cmd: metalava_cmd +
186        "--check-compatibility:api:released $(location :android.api.module-lib.latest) " +
187        // Note: having "public" be the base of module-lib is not perfect -- it should
188        // ideally be a merged public+system (which metalava is not currently able to generate).
189        // This "base" will help when migrating from MODULE_LIBS -> public, but not when
190        // migrating from MODULE_LIBS -> system (where it needs to instead be listed as
191        // an incompatibility).
192        "--check-compatibility:base $(location :frameworks-base-api-current.txt) " +
193        "--baseline:compatibility:released $(location :android-incompatibilities.api.module-lib.latest) " +
194        "--update-baseline:compatibility:released $(genDir)/updated-baseline.txt " +
195        "$(location :frameworks-base-api-module-lib-current.txt)",
196}
197
198genrule {
199    name: "frameworks-base-api-current.srcjar",
200    tools: ["merge_zips"],
201    out: ["current.srcjar"],
202    cmd: "$(location merge_zips) $(out) $(in)",
203    srcs: [
204        ":api-stubs-docs-non-updatable{.exportable}",
205        ":all-modules-public-stubs-source",
206    ],
207    visibility: ["//visibility:private"], // Used by make module in //development, mind
208}
209
210// This produces the same annotations.zip as framework-doc-stubs, but by using
211// outputs from individual modules instead of all the source code.
212genrule_defaults {
213    name: "sdk-annotations-defaults",
214    out: ["annotations.zip"],
215    tools: [
216        "merge_annotation_zips",
217        "soong_zip",
218    ],
219    cmd: "$(location merge_annotation_zips) $(genDir)/out $(in) && " +
220        "$(location soong_zip) -o $(out) -C $(genDir)/out -D $(genDir)/out",
221}
222
223genrule {
224    name: "sdk-annotations.zip",
225    defaults: ["sdk-annotations-defaults"],
226    srcs: [
227        ":android-non-updatable-doc-stubs{.exportable.annotations.zip}",
228        ":all-modules-public-annotations",
229    ],
230}
231
232genrule {
233    name: "sdk-annotations-system.zip",
234    defaults: ["sdk-annotations-defaults"],
235    srcs: [
236        ":android-non-updatable-doc-stubs-system{.exportable.annotations.zip}",
237        ":all-modules-system-annotations",
238    ],
239}
240
241genrule {
242    name: "sdk-annotations-module-lib.zip",
243    defaults: ["sdk-annotations-defaults"],
244    srcs: [
245        ":android-non-updatable-doc-stubs-module-lib{.exportable.annotations.zip}",
246        ":all-modules-module-lib-annotations",
247    ],
248}
249
250genrule {
251    name: "sdk-annotations-system-server.zip",
252    defaults: ["sdk-annotations-defaults"],
253    srcs: [
254        ":android-non-updatable-doc-stubs-system-server{.exportable.annotations.zip}",
255        ":all-modules-system-server-annotations",
256    ],
257}
258
259genrule {
260    name: "combined-removed-dex",
261    visibility: [
262        "//frameworks/base/boot",
263    ],
264    srcs: [
265        ":frameworks-base-api-removed.txt",
266        ":frameworks-base-api-system-removed.txt",
267        ":android.car-stubs-docs{.removed-api.txt}",
268        ":android.car-system-stubs-docs{.removed-api.txt}",
269    ],
270    tool_files: ["gen_combined_removed_dex.sh"],
271    tools: ["metalava"],
272    out: ["combined-removed-dex.txt"],
273    cmd: "$(location gen_combined_removed_dex.sh) $(location metalava) $(genDir) $(in) > $(out)",
274}
275
276java_genrule {
277    name: "api_fingerprint",
278    srcs: [
279        ":frameworks-base-api-current.txt",
280        ":frameworks-base-api-system-current.txt",
281        ":frameworks-base-api-module-lib-current.txt",
282        ":frameworks-base-api-system-server-current.txt",
283    ],
284    out: ["api_fingerprint.txt"],
285    cmd: "cat $(in) | md5sum | cut -d' ' -f1 > $(out)",
286}
287
288packages_to_document = [
289    "android",
290    "dalvik",
291    "java",
292    "javax",
293    "junit",
294    "org.apache.http",
295    "org.json",
296    "org.w3c.dom",
297    "org.xml.sax",
298    "org.xmlpull",
299]
300
301// These are libs from framework-internal-utils that are required (i.e. being referenced)
302// from framework-non-updatable-sources. Add more here when there's a need.
303// DO NOT add the entire framework-internal-utils. It might cause unnecessary circular
304// dependencies gets bigger.
305android_non_updatable_stubs_libs = [
306    "android.hardware.cas-V1.2-java",
307    "android.hardware.health-V1.0-java-constants",
308    "android.hardware.thermal-V1.0-java-constants",
309    "android.hardware.thermal-V2.0-java",
310    "android.hardware.tv.input-V1.0-java-constants",
311    "android.hardware.usb-V1.0-java-constants",
312    "android.hardware.usb-V1.1-java-constants",
313    "android.hardware.usb.gadget-V1.0-java",
314    "android.hardware.vibrator-V1.3-java",
315    "framework-protos",
316]
317
318java_defaults {
319    name: "android-non-updatable-stubs-libs-defaults",
320    libs: android_non_updatable_stubs_libs,
321}
322
323// Defaults for all stubs that include the non-updatable framework. These defaults do not include
324// module symbols, so will not compile correctly on their own. Users must add module APIs to the
325// classpath (or sources) somehow.
326stubs_defaults {
327    name: "android-non-updatable-stubs-defaults",
328    aconfig_declarations: ["framework-minus-apex-aconfig-declarations"],
329    srcs: [":android-non-updatable-stub-sources"],
330    sdk_version: "none",
331    system_modules: "none",
332    java_version: "1.8",
333    arg_files: [":frameworks-base-core-AndroidManifest.xml"],
334    aidl: {
335        include_dirs: [
336            "frameworks/av/aidl",
337            "frameworks/base/media/aidl",
338            "frameworks/base/telephony/java",
339            "frameworks/native/libs/permission/aidl",
340            "packages/modules/Bluetooth/framework/aidl-export",
341            "packages/modules/Connectivity/framework/aidl-export",
342            "packages/modules/Media/apex/aidl/stable",
343            "hardware/interfaces/biometrics/common/aidl",
344            "hardware/interfaces/biometrics/fingerprint/aidl",
345            "hardware/interfaces/common/aidl",
346            "hardware/interfaces/common/fmq/aidl",
347            "hardware/interfaces/graphics/common/aidl",
348            "hardware/interfaces/keymaster/aidl",
349            "hardware/interfaces/power/aidl",
350            "system/hardware/interfaces/media/aidl",
351        ],
352    },
353    // These are libs from framework-internal-utils that are required (i.e. being referenced)
354    // from framework-non-updatable-sources. Add more here when there's a need.
355    // DO NOT add the entire framework-internal-utils. It might cause unnecessary circular
356    // dependencies gets bigger.
357    libs: android_non_updatable_stubs_libs,
358    flags: [
359        "--error NoSettingsProvider",
360        "--error UnhiddenSystemApi",
361        "--error UnflaggedApi",
362        "--force-convert-to-warning-nullability-annotations +*:-android.*:+android.icu.*:-dalvik.*",
363        // Disable CallbackInterface, as Java 8 default interface methods avoid the extensibility
364        // issue interfaces had previously.
365        "--hide CallbackInterface",
366        // Disable HiddenSuperclass, as Metalava handles this fine (it should be hidden by default)
367        "--hide HiddenSuperclass",
368        "--hide-package android.audio.policy.configuration.V7_0",
369        "--hide-package com.android.server",
370        "--manifest $(location :frameworks-base-core-AndroidManifest.xml)",
371    ],
372    filter_packages: packages_to_document,
373    high_mem: true, // Lots of sources => high memory use, see b/170701554
374    installable: false,
375    annotations_enabled: true,
376    previous_api: ":android.api.public.latest",
377    merge_annotations_dirs: ["metalava-manual"],
378    defaults_visibility: ["//frameworks/base/api"],
379    visibility: [
380        "//frameworks/base/api",
381        "//frameworks/base/core/api",
382    ],
383}
384
385soong_config_module_type {
386    name: "non_updatable_exportable_droidstubs",
387    module_type: "droidstubs",
388    config_namespace: "ANDROID",
389    bool_variables: [
390        "release_hidden_api_exportable_stubs",
391    ],
392    properties: [
393        "dists",
394    ],
395}
396
397// We resolve dependencies on APIs in modules by depending on a prebuilt of the whole
398// platform (sdk_system_current_android). That prebuilt does not include module-lib APIs,
399// so use the prebuilt module-lib stubs for modules that export module-lib stubs that the
400// non-updatable part depends on.
401non_updatable_api_deps_on_modules = [
402    "sdk_module-lib_current_framework-tethering",
403    "sdk_module-lib_current_framework-connectivity-t",
404    "sdk_system_current_android",
405]
406
407// Defaults with module APIs in the classpath (mostly from prebuilts).
408// Suitable for compiling android-non-updatable.
409stubs_defaults {
410    name: "module-classpath-stubs-defaults",
411    aidl: {
412        include_dirs: [
413            "packages/modules/Bluetooth/framework/aidl-export",
414            "packages/modules/Connectivity/framework/aidl-export",
415            "packages/modules/Media/apex/aidl/stable",
416        ],
417    },
418    libs: non_updatable_api_deps_on_modules,
419}
420
421// Defaults for the java_sdk_libraries of unbundled jars from framework.
422// java_sdk_libraries using these defaults should also add themselves to the
423// non_updatable_modules list in frameworks/base/api/api.go
424java_defaults {
425    name: "framework-non-updatable-unbundled-defaults",
426    defaults: [
427        "framework-non-updatable-lint-defaults",
428        "non-updatable-framework-module-defaults",
429    ],
430    public: {
431        libs: ["android_module_lib_stubs_current"],
432    },
433    system: {
434        libs: ["android_module_lib_stubs_current"],
435    },
436    module_lib: {
437        libs: ["android_module_lib_stubs_current"],
438    },
439    test: {
440        libs: ["android_test_frameworks_core_stubs_current"],
441    },
442    sdk_version: "core_platform",
443    stub_only_libs: ["framework-protos"],
444    impl_only_libs: ["framework-minus-apex-headers"], // the framework, including hidden API
445    impl_library_visibility: ["//frameworks/base"],
446    defaults_visibility: [
447        "//frameworks/base/location",
448        "//frameworks/base/nfc",
449    ],
450    plugins: ["error_prone_android_framework"],
451    errorprone: {
452        javacflags: [
453            "-Xep:AndroidFrameworkCompatChange:ERROR",
454            "-Xep:AndroidFrameworkUid:ERROR",
455        ],
456    },
457    // Include manual annotations in API txt files
458    merge_annotations_dirs: ["metalava-manual"],
459}
460
461build = [
462    "ApiDocs.bp",
463    "StubLibraries.bp",
464]
465
466genrule_defaults {
467    name: "flag-api-mapping-generation-defaults",
468    cmd: "$(location extract-flagged-apis) $(in) $(out)",
469    tools: ["extract-flagged-apis"],
470}
471
472genrule {
473    name: "flag-api-mapping-PublicApi",
474    defaults: ["flag-api-mapping-generation-defaults"],
475    srcs: [":frameworks-base-api-current.txt"],
476    out: ["flag_api_map.textproto"],
477    dist: {
478        targets: ["droid"],
479    },
480}
481
482genrule {
483    name: "flag-api-mapping-SystemApi",
484    defaults: ["flag-api-mapping-generation-defaults"],
485    srcs: [":frameworks-base-api-system-current.txt"],
486    out: ["system_flag_api_map.textproto"],
487    dist: {
488        targets: ["droid"],
489    },
490}
491
492genrule {
493    name: "flag-api-mapping-ModuleLibApi",
494    defaults: ["flag-api-mapping-generation-defaults"],
495    srcs: [":frameworks-base-api-module-lib-current.txt"],
496    out: ["module_lib_flag_api_map.textproto"],
497    dist: {
498        targets: ["droid"],
499    },
500}
501
502genrule {
503    name: "flag-api-mapping-SystemServerApi",
504    defaults: ["flag-api-mapping-generation-defaults"],
505    srcs: [":frameworks-base-api-system-server-current.txt"],
506    out: ["system_server_flag_api_map.textproto"],
507    dist: {
508        targets: ["droid"],
509    },
510}
511
512phony_rule {
513    name: "checkapi",
514    phony_deps: [
515        "frameworks-base-api-current-compat",
516        "frameworks-base-api-system-current-compat",
517        "frameworks-base-api-module-lib-current-compat",
518    ],
519}
520