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