Set __<libname>_API__ macro when building against stubs

When building against libFoo#ver, __LIBFOO_API__ macro is set to ver so
that headers from libFoo can be conditionally compiled (e.g., hide APIs
that are not available for the version, etc.)

Bug: 112672359
Test: m (cc_test added)
Change-Id: I863ef95b385cdd842eec1bf34e81f44b5e3b58b3
This commit is contained in:
Jiyong Park
2018-11-02 18:23:15 +09:00
parent 1d7c30a4fc
commit da732bd63a
2 changed files with 47 additions and 0 deletions

View File

@@ -1738,13 +1738,16 @@ func TestVersionedStubs(t *testing.T) {
ctx := testCc(t, `
cc_library_shared {
name: "libFoo",
srcs: ["foo.c"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
cc_library_shared {
name: "libBar",
srcs: ["bar.c"],
shared_libs: ["libFoo#1"],
}`)
@@ -1786,4 +1789,11 @@ func TestVersionedStubs(t *testing.T) {
if !strings.Contains(libFlags, libFoo1StubPath) {
t.Errorf("%q is not found in %q", libFoo1StubPath, libFlags)
}
libBarCompileRule := ctx.ModuleForTests("libBar", "android_arm64_armv8-a_core_shared").Rule("cc")
cFlags := libBarCompileRule.Args["cFlags"]
libFoo1VersioningMacro := "-D__LIBFOO_API__=1"
if !strings.Contains(cFlags, libFoo1VersioningMacro) {
t.Errorf("%q is not found in %q", libFoo1VersioningMacro, cFlags)
}
}