Introduce cc_api_library

Introduce cc_api_library, which reflects imported API from other
inner-tree. This cc_api_library module type will later refer from
the other ninja module which generates stub library from the interface
description.

Tested environment :
* original libc definition has been removed temporarily, to ensure that
  imported api stub library is being used from build
* Added new definition of libc as below
 cc_api_library {
  name: "libc",
  arch: {
    x86: {
      src: "libs/x86/libc.so",
    },
    x86_64: {
      src: "libs/x86_64/libc.so",
    },
  },
  header_libs: [
    "libc_headers",
  ],
  export_header_lib_headers: ["libc_headers"],
  min_sdk_version: "9",
  vendor_available: true,
 }

Bug: 236087698
Test: `ALLOW_MISSING_DEPENDENCIES=true m vendorimage` succeeded
Change-Id: I67070b0f3561aa2afd73b6c1c0fdf4255218baac
This commit is contained in:
Kiyoung Kim
2022-07-26 09:48:22 +09:00
parent b7873a8b0f
commit 487689eaee
8 changed files with 447 additions and 32 deletions

View File

@@ -26,6 +26,7 @@ import (
"strings"
"testing"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -9546,6 +9547,63 @@ func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {
}
}
func TestApexBuildsAgainstApiSurfaceStubLibraries(t *testing.T) {
bp := `
apex {
name: "myapex",
key: "myapex.key",
native_shared_libs: ["libfoo"],
min_sdk_version: "29",
}
apex_key {
name: "myapex.key",
}
cc_library {
name: "libfoo",
shared_libs: ["libc"],
apex_available: ["myapex"],
min_sdk_version: "29",
}
cc_api_library {
name: "libc",
src: "libc.so",
min_sdk_version: "29",
recovery_available: true,
}
api_imports {
name: "api_imports",
shared_libs: [
"libc",
],
header_libs: [],
}
`
result := testApex(t, bp)
hasDep := func(m android.Module, wantDep android.Module) bool {
t.Helper()
var found bool
result.VisitDirectDeps(m, func(dep blueprint.Module) {
if dep == wantDep {
found = true
}
})
return found
}
libfooApexVariant := result.ModuleForTests("libfoo", "android_arm64_armv8-a_shared_apex29").Module()
libcApexVariant := result.ModuleForTests("libc.apiimport", "android_arm64_armv8-a_shared_apex29").Module()
android.AssertBoolEquals(t, "apex variant should link against API surface stub libraries", true, hasDep(libfooApexVariant, libcApexVariant))
// libfoo core variant should be buildable in the same inner tree since
// certain mcombo files might build system and apexes in the same inner tree
// libfoo core variant should link against source libc
libfooCoreVariant := result.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Module()
libcCoreVariant := result.ModuleForTests("libc.apiimport", "android_arm64_armv8-a_shared").Module()
android.AssertBoolEquals(t, "core variant should link against source libc", true, hasDep(libfooCoreVariant, libcCoreVariant))
}
func TestMain(m *testing.M) {
os.Exit(m.Run())
}