summaryrefslogtreecommitdiff
path: root/sdk/cc_sdk_test.go
diff options
context:
space:
mode:
author Paul Duffin <paulduffin@google.com> 2019-11-19 19:44:10 +0000
committer Paul Duffin <paulduffin@google.com> 2021-09-23 11:37:57 +0100
commit93b750e2a0d8872829a7efb911eef5fdda530628 (patch)
tree192e1303934f10f60e799d098f1e6a1e45fbbdf6 /sdk/cc_sdk_test.go
parentfefdb0bf0a4265706e67716fb8aa504fff713699 (diff)
Add support for native bridge trait
Adds a native bridge trait that if required will cause a cc_library_header module to generate a cc_prebuilt_library_headers with native_bridge_supported: true. It will fail if the cc_library_header's native bridge variant would produce native bridge specific properties, distinct from the other architecture variants, in the generated cc_prebuilt_library_headers. Bug: 195754365 Test: m nothing Change-Id: I282fbb9095de6c6af57cca4eb4260e2c6c2da8cc
Diffstat (limited to 'sdk/cc_sdk_test.go')
-rw-r--r--sdk/cc_sdk_test.go102
1 files changed, 102 insertions, 0 deletions
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 25e35fcdb..da90c6dfc 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -32,6 +32,23 @@ var ccTestFs = android.MockFS{
"some/where/stubslib.map.txt": nil,
}
+// Adds a native bridge target to the configured list of targets.
+var prepareForTestWithNativeBridgeTarget = android.FixtureModifyConfig(func(config android.Config) {
+ config.Targets[android.Android] = append(config.Targets[android.Android], android.Target{
+ Os: android.Android,
+ Arch: android.Arch{
+ ArchType: android.Arm64,
+ ArchVariant: "armv8-a",
+ CpuVariant: "cpu",
+ Abi: nil,
+ ArchFeatures: nil,
+ },
+ NativeBridge: android.NativeBridgeEnabled,
+ NativeBridgeHostArchName: "x86_64",
+ NativeBridgeRelativePath: "native_bridge",
+ })
+})
+
func testSdkWithCc(t *testing.T, bp string) *android.TestResult {
t.Helper()
return testSdkWithFs(t, bp, ccTestFs)
@@ -1979,6 +1996,91 @@ myinclude/Test.h -> include/myinclude/Test.h
)
}
+func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ cc.PrepareForTestWithCcDefaultModules,
+ PrepareForTestWithSdkBuildComponents,
+ ccTestFs.AddToFixture(),
+ prepareForTestWithNativeBridgeTarget,
+ ).RunTestWithBp(t, `
+ sdk {
+ name: "mysdk",
+ native_header_libs: ["mynativeheaders"],
+ traits: {
+ native_bridge_support: ["mynativeheaders"],
+ },
+ }
+
+ cc_library_headers {
+ name: "mynativeheaders",
+ export_include_dirs: ["myinclude"],
+ stl: "none",
+ system_shared_libs: [],
+ native_bridge_supported: true,
+ }
+ `)
+
+ CheckSnapshot(t, result, "mysdk", "",
+ checkUnversionedAndroidBpContents(`
+// This is auto-generated. DO NOT EDIT.
+
+cc_prebuilt_library_headers {
+ name: "mynativeheaders",
+ prefer: false,
+ visibility: ["//visibility:public"],
+ apex_available: ["//apex_available:platform"],
+ native_bridge_supported: true,
+ stl: "none",
+ compile_multilib: "both",
+ system_shared_libs: [],
+ export_include_dirs: ["include/myinclude"],
+}
+`),
+ checkAllCopyRules(`
+myinclude/Test.h -> include/myinclude/Test.h
+`),
+ )
+}
+
+// TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties verifies that when a
+// module that has different output files for a native bridge target requests the native bridge
+// variants are copied into the sdk snapshot that it reports an error.
+func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) {
+ android.GroupFixturePreparers(
+ cc.PrepareForTestWithCcDefaultModules,
+ PrepareForTestWithSdkBuildComponents,
+ ccTestFs.AddToFixture(),
+ prepareForTestWithNativeBridgeTarget,
+ ).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
+ `\QArchitecture variant "arm64_native_bridge" of sdk member "mynativeheaders" has properties distinct from other variants; this is not yet supported. The properties are:
+ export_include_dirs: [
+ "arm64_native_bridge/include/myinclude_nativebridge",
+ "arm64_native_bridge/include/myinclude",
+ ],\E`)).
+ RunTestWithBp(t, `
+ sdk {
+ name: "mysdk",
+ native_header_libs: ["mynativeheaders"],
+ traits: {
+ native_bridge_support: ["mynativeheaders"],
+ },
+ }
+
+ cc_library_headers {
+ name: "mynativeheaders",
+ export_include_dirs: ["myinclude"],
+ stl: "none",
+ system_shared_libs: [],
+ native_bridge_supported: true,
+ target: {
+ native_bridge: {
+ export_include_dirs: ["myinclude_nativebridge"],
+ },
+ },
+ }
+ `)
+}
+
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
result := testSdkWithCc(t, `
sdk {