summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2024-09-04 18:23:19 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-09-04 18:23:19 +0000
commit56aed2b0e8e73a33b2d22647be23f47b2f857245 (patch)
treedf7b006381d09e6fb4180abcc31c58bf01d8338c
parent13d8e82c5e6aeb2b5578d4e7a0563a9626c3c35d (diff)
parent0db999c45e4dc5c6544492d26728604fddce6011 (diff)
Merge changes from topic "libbinder_ndk-remove-cpp-headers" into main
* changes: ndk_library: limit exports Reland "Truely re-export export_header_libs from ndk_library" ndk_library depends on the correct arch variant of cc_library_headers
-rw-r--r--android/neverallow.go17
-rw-r--r--cc/cc.go10
-rw-r--r--cc/ndk_library.go3
3 files changed, 27 insertions, 3 deletions
diff --git a/android/neverallow.go b/android/neverallow.go
index 233ca61e3..b89d150cb 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -60,6 +60,7 @@ func init() {
AddNeverAllowRules(createCcStubsRule())
AddNeverAllowRules(createJavaExcludeStaticLibsRule())
AddNeverAllowRules(createProhibitHeaderOnlyRule())
+ AddNeverAllowRules(createLimitNdkExportRule()...)
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -267,6 +268,22 @@ func createProhibitHeaderOnlyRule() Rule {
Because("headers_only can only be used for generating framework-minus-apex headers for non-updatable modules")
}
+func createLimitNdkExportRule() []Rule {
+ reason := "If the headers you're trying to export are meant to be a part of the NDK, they should be exposed by an ndk_headers module. If the headers shouldn't be a part of the NDK, the headers should instead be exposed from a separate `cc_library_headers` which consumers depend on."
+ // DO NOT ADD HERE - please consult danalbert@
+ // b/357711733
+ return []Rule{
+ NeverAllow().
+ NotIn("frameworks/native/libs/binder/ndk").
+ ModuleType("ndk_library").
+ WithMatcher("export_header_libs", isSetMatcherInstance).Because(reason),
+ NeverAllow().ModuleType("ndk_library").WithMatcher("export_generated_headers", isSetMatcherInstance).Because(reason),
+ NeverAllow().ModuleType("ndk_library").WithMatcher("export_include_dirs", isSetMatcherInstance).Because(reason),
+ NeverAllow().ModuleType("ndk_library").WithMatcher("export_shared_lib_headers", isSetMatcherInstance).Because(reason),
+ NeverAllow().ModuleType("ndk_library").WithMatcher("export_static_lib_headers", isSetMatcherInstance).Because(reason),
+ }
+}
+
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {
diff --git a/cc/cc.go b/cc/cc.go
index 927935ceb..b53473765 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2507,8 +2507,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
if c.isNDKStubLibrary() {
- // ndk_headers do not have any variations
- actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
+ variationExists := actx.OtherModuleDependencyVariantExists(nil, lib)
+ if variationExists {
+ actx.AddVariationDependencies(nil, depTag, lib)
+ } else {
+ // dependencies to ndk_headers fall here as ndk_headers do not have
+ // any variants.
+ actx.AddFarVariationDependencies([]blueprint.Variation{}, depTag, lib)
+ }
} else if c.IsStubs() && !c.isImportedApiLibrary() {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
depTag, lib)
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 47b6114aa..bd6dfa301 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -493,7 +493,8 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
// Add a dependency on the header modules of this ndk_library
func (linker *stubDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
return Deps{
- HeaderLibs: linker.properties.Export_header_libs,
+ ReexportHeaderLibHeaders: linker.properties.Export_header_libs,
+ HeaderLibs: linker.properties.Export_header_libs,
}
}