Spandan Das | 1278c2c | 2022-08-19 18:17:28 +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/cc" |
| 21 | ) |
| 22 | |
| 23 | func TestNdkLibraryContributionSymbolFile(t *testing.T) { |
| 24 | bp := ` |
| 25 | ndk_library { |
| 26 | name: "libfoo", |
| 27 | symbol_file: "libfoo.map.txt", |
| 28 | } |
| 29 | ` |
| 30 | expectedBazelTarget := MakeBazelTargetNoRestrictions( |
| 31 | "cc_api_contribution", |
| 32 | "libfoo.ndk.contribution", |
| 33 | AttrNameToString{ |
| 34 | "api": `"libfoo.map.txt"`, |
| 35 | "api_surfaces": `["publicapi"]`, |
| 36 | "library_name": `"libfoo"`, |
| 37 | "target_compatible_with": `["//build/bazel/platforms/os:android"]`, |
| 38 | }, |
| 39 | ) |
Spandan Das | 8b4a5f3 | 2022-09-29 00:28:24 +0000 | [diff] [blame] | 40 | RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{ |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 41 | Blueprint: bp, |
| 42 | ExpectedBazelTargets: []string{expectedBazelTarget}, |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | func TestNdkLibraryContributionHeaders(t *testing.T) { |
| 47 | bp := ` |
| 48 | ndk_library { |
| 49 | name: "libfoo", |
| 50 | symbol_file: "libfoo.map.txt", |
| 51 | export_header_libs: ["libfoo_headers"], |
| 52 | } |
| 53 | ` |
| 54 | fs := map[string]string{ |
| 55 | "header_directory/Android.bp": ` |
| 56 | ndk_headers { |
| 57 | name: "libfoo_headers", |
| 58 | } |
| 59 | `, |
| 60 | } |
| 61 | expectedBazelTarget := MakeBazelTargetNoRestrictions( |
| 62 | "cc_api_contribution", |
| 63 | "libfoo.ndk.contribution", |
| 64 | AttrNameToString{ |
| 65 | "api": `"libfoo.map.txt"`, |
| 66 | "api_surfaces": `["publicapi"]`, |
| 67 | "library_name": `"libfoo"`, |
| 68 | "hdrs": `["//header_directory:libfoo_headers.contribution"]`, |
| 69 | "target_compatible_with": `["//build/bazel/platforms/os:android"]`, |
| 70 | }, |
| 71 | ) |
Spandan Das | 8b4a5f3 | 2022-09-29 00:28:24 +0000 | [diff] [blame] | 72 | RunApiBp2BuildTestCase(t, cc.RegisterNdkModuleTypes, Bp2buildTestCase{ |
Spandan Das | 1278c2c | 2022-08-19 18:17:28 +0000 | [diff] [blame] | 73 | Blueprint: bp, |
| 74 | Filesystem: fs, |
| 75 | ExpectedBazelTargets: []string{expectedBazelTarget}, |
| 76 | }) |
| 77 | } |