Spandan Das | 8159389 | 2022-09-06 17:31:48 +0000 | [diff] [blame] | 1 | // Copyright 2022 Google Inc. All rights reserved. |
| 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 | package bp2build |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | |
| 20 | "android/soong/android" |
| 21 | "android/soong/cc" |
| 22 | ) |
| 23 | |
| 24 | func registerApiDomainModuleTypes(ctx android.RegistrationContext) { |
| 25 | android.RegisterApiDomainBuildComponents(ctx) |
| 26 | cc.RegisterNdkModuleTypes(ctx) |
| 27 | cc.RegisterLibraryBuildComponents(ctx) |
| 28 | } |
| 29 | |
| 30 | func TestApiDomainContributionsTest(t *testing.T) { |
| 31 | bp := ` |
| 32 | api_domain { |
| 33 | name: "system", |
| 34 | cc_api_contributions: [ |
| 35 | "libfoo.ndk", |
| 36 | "libbar", |
| 37 | ], |
| 38 | } |
| 39 | ` |
| 40 | fs := map[string]string{ |
| 41 | "libfoo/Android.bp": ` |
| 42 | ndk_library { |
| 43 | name: "libfoo", |
| 44 | } |
| 45 | `, |
| 46 | "libbar/Android.bp": ` |
| 47 | cc_library { |
| 48 | name: "libbar", |
| 49 | } |
| 50 | `, |
| 51 | } |
| 52 | expectedBazelTarget := MakeBazelTargetNoRestrictions( |
| 53 | "api_domain", |
| 54 | "system", |
| 55 | AttrNameToString{ |
| 56 | "cc_api_contributions": `[ |
| 57 | "//libfoo:libfoo.ndk.contribution", |
| 58 | "//libbar:libbar.contribution", |
| 59 | ]`, |
| 60 | "target_compatible_with": `["//build/bazel/platforms/os:android"]`, |
| 61 | }, |
| 62 | ) |
Spandan Das | 8b4a5f3 | 2022-09-29 00:28:24 +0000 | [diff] [blame^] | 63 | RunApiBp2BuildTestCase(t, registerApiDomainModuleTypes, Bp2buildTestCase{ |
Spandan Das | 8159389 | 2022-09-06 17:31:48 +0000 | [diff] [blame] | 64 | Blueprint: bp, |
| 65 | ExpectedBazelTargets: []string{expectedBazelTarget}, |
| 66 | Filesystem: fs, |
| 67 | }) |
| 68 | } |