• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
15package {
16    // See: http://go/android-license-faq
17    default_applicable_licenses: ["Android-Apache-2.0"],
18}
19
20java_library {
21    name: "cts-api-signature-multilib-test",
22    srcs: ["src/**/*.java"],
23    sdk_version: "test_current",
24    static_libs: [
25        "cts-api-signature-test",
26        "compatibility-device-util-axt",
27        "junit-params",
28    ],
29}
30
31android_test {
32    name: "CtsSharedLibsApiSignatureTestCases",
33    defaults: ["cts_defaults"],
34
35    // Ensure that any android.test and junit classes embedded within this test do not conflict with
36    // the classes provided by the android.test.base or android.test.runner shared libraries.
37    jarjar_rules: ":cts-android-test-jarjar-rules",
38
39    java_resources: [
40        ":cts-current-api-gz",
41        ":cts-shared-libs-names.txt",
42        ":CtsSharedLibsApiSignatureTestCases_cts-shared-libs-all-current.api",
43        ":CtsSharedLibsApiSignatureTestCases_cts-shared-libs-all-previous.api",
44    ],
45    static_libs: [
46        "cts-api-signature-multilib-test",
47        "cts-api-signature-test",
48    ],
49    test_suites: [
50        "cts",
51        "general-tests",
52    ],
53    sdk_version: "current",
54    jni_libs: ["libclassdescriptors"],
55    compile_multilib: "both",
56    dex_preopt: {
57        enabled: false,
58    },
59    optimize: {
60        enabled: false,
61    },
62    use_embedded_native_libs: false,
63    srcs: ["src/**/*.java"],
64}
65
66genrule {
67    name: "cts-shared-libs-names.txt",
68    srcs: [
69        "AndroidManifest.xml",
70    ],
71    out: [
72        "shared-libs-names.txt",
73    ],
74    cmd: "grep 'uses-library' $(in) | cut -f2 -d\\\" | sort > $(out)",
75}
76
77// Generates a zip file containing the current public and system API files for shared libraries.
78genrule {
79    name: "CtsSharedLibsApiSignatureTestCases_cts-shared-libs-all-current.api",
80    srcs: [
81        ":android.net.ipsec.ike{.public.api.txt}",
82        ":android.net.ipsec.ike{.system.api.txt}",
83        ":android.test.base{.public.api.txt}",
84        ":android.test.base{.system.api.txt}",
85        ":android.test.runner{.public.api.txt}",
86        ":android.test.runner{.system.api.txt}",
87        ":android.test.mock{.public.api.txt}",
88        ":android.test.mock{.system.api.txt}",
89        ":com.android.future.usb.accessory{.public.api.txt}",
90        ":com.android.future.usb.accessory{.system.api.txt}",
91        ":com.android.libraries.tv.tvsystem{.public.api.txt}",
92        ":com.android.libraries.tv.tvsystem{.system.api.txt}",
93        ":com.android.location.provider{.public.api.txt}",
94        ":com.android.location.provider{.system.api.txt}",
95        ":com.android.mediadrm.signer{.public.api.txt}",
96        ":com.android.mediadrm.signer{.system.api.txt}",
97        ":com.android.media.remotedisplay{.public.api.txt}",
98        ":com.android.media.remotedisplay{.system.api.txt}",
99        ":com.android.media.tv.remoteprovider{.public.api.txt}",
100        ":com.android.media.tv.remoteprovider{.system.api.txt}",
101        ":com.android.nfc_extras{.public.api.txt}",
102        ":com.android.nfc_extras{.system.api.txt}",
103        ":javax.obex{.public.api.txt}",
104        ":javax.obex{.system.api.txt}",
105        ":org.apache.http.legacy{.public.api.txt}",
106        ":org.apache.http.legacy{.system.api.txt}",
107    ],
108    tools: [
109        "soong_zip",
110        "metalava",
111    ],
112    out: [
113        "shared-libs-all-current.api.zip",
114    ],
115    cmd: "mkdir -p $(genDir)/list && " +
116        "for f in $(in); do " +
117        // Extract the module name from the path.
118        "  fileName=$$(basename $${f} .txt) && " +
119        "  fileName=$${fileName%%.stubs.source*} && " +
120        // Extract the api level, i.e. public|system from the path.
121        "  apiLevel=$${f##*.stubs.source} && " +
122        "  apiLevel=$${apiLevel#.} && " +
123        "  apiLevel=$${apiLevel%_api.txt} && " +
124        "  if [ -z $${apiLevel} ]; then apiLevel=public; fi && " +
125        // Convert the .txt file into its XML representation.
126        "  $(location metalava) -J--add-opens=java.base/java.util=ALL-UNNAMED --no-banner " +
127        "    -convert2xmlnostrip $${f} $(genDir)/list/$${fileName}-current-$${apiLevel}.api; " +
128        "done && " +
129        "$(location soong_zip) -o $(out) -C $(genDir)/list -D $(genDir)/list",
130}
131
132// Generates a zip file containing all the API files from previous releases >= 28 excluding the
133// android.txt and removed files.
134genrule {
135    name: "CtsSharedLibsApiSignatureTestCases_cts-shared-libs-all-previous.api",
136    srcs: [
137        ":prebuilt_sdk_system_public_api_txt",
138    ],
139    tools: [
140        "soong_zip",
141        "metalava",
142    ],
143    out: [
144        "shared-libs-all-previous.api.zip",
145    ],
146    cmd: "for f in $(in); do " +
147        "  fileName=$$(basename $${f} .txt) && " +
148        "  if [ $${fileName} == android ] || [[ $${fileName} =~ removed ]] || [[ $${fileName} =~ incompatibilities ]]; " +
149        "    then continue; fi && " +
150        "  platformSdkVersion=$$(echo $${f} | awk -F/ '{print $$(3)}') && " +
151        "  if [ $${platformSdkVersion} -lt 28 ]; then continue; fi && " +
152        "  apiLevel=$$(echo $${f} | awk -F/ '{print $$(4)}') && " +
153        "  $(location metalava) -J--add-opens=java.base/java.util=ALL-UNNAMED --no-banner " +
154        "    -convert2xmlnostrip $${f} $(genDir)/list/$${fileName}-$${platformSdkVersion}-$${apiLevel}.api; " +
155        "done && " +
156        "$(location soong_zip) -o $(out) -C $(genDir)/list -D $(genDir)/list",
157}
158