diff --git a/cc/cc.go b/cc/cc.go index fa33bc639..715919fc0 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -1422,7 +1422,9 @@ func vendorMutator(mctx android.BottomUpMutatorContext) { mctx.CreateVariations(vendorMode) } else if _, ok := m.linker.(*llndkHeadersDecorator); ok { // ... and LL-NDK headers as well - mctx.CreateVariations(vendorMode) + mod := mctx.CreateVariations(vendorMode) + vendor := mod[0].(*Module) + vendor.Properties.UseVndk = true } else if _, ok := m.linker.(*vndkPrebuiltLibraryDecorator); ok { // Make vendor variants only for the versions in BOARD_VNDK_VERSION and // PRODUCT_EXTRA_VNDK_VERSIONS. diff --git a/cc/cc_test.go b/cc/cc_test.go index 148b4ddc3..15e45d0c4 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -61,6 +61,7 @@ func testCc(t *testing.T, bp string) *android.TestContext { ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(toolchainLibraryFactory)) ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(llndkLibraryFactory)) + ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory)) ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(objectFactory)) ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(genrule.FileGroupFactory)) ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { @@ -138,6 +139,7 @@ func testCc(t *testing.T, bp string) *android.TestContext { "bar.c": nil, "a.proto": nil, "b.aidl": nil, + "my_include": nil, }) _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) @@ -583,6 +585,34 @@ func TestStaticLibDepReorderingWithShared(t *testing.T) { } } +func TestLlndkHeaders(t *testing.T) { + ctx := testCc(t, ` + llndk_headers { + name: "libllndk_headers", + export_include_dirs: ["my_include"], + } + llndk_library { + name: "libllndk", + export_llndk_headers: ["libllndk_headers"], + } + cc_library { + name: "libvendor", + shared_libs: ["libllndk"], + vendor: true, + srcs: ["foo.c"], + no_libgcc : true, + nocrt : true, + } + `) + + // _static variant is used since _shared reuses *.o from the static variant + cc := ctx.ModuleForTests("libvendor", "android_arm_armv7-a-neon_vendor_static").Rule("cc") + cflags := cc.Args["cFlags"] + if !strings.Contains(cflags, "-Imy_include") { + t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags) + } +} + var compilerFlagsTestCases = []struct { in string out bool diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 9a29964da..e824d0f6e 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -191,7 +191,6 @@ func (headers *llndkHeadersDecorator) Name(name string) string { func llndkHeadersFactory() android.Module { module, library := NewLibrary(android.DeviceSupported) library.HeaderOnly() - library.setStatic() decorator := &llndkHeadersDecorator{ libraryDecorator: library,