Refactor vendor snapshot to use LinkableInterface.
Refactors the vendor snapshot support to use the LinkableInterface
so that support can be extended to Rust. This CL does not add
vendor snapshot support for Rust; that is left for a follow-on CL.
Bug: 184042776
Test: m nothing
Change-Id: Id0c4970ca00053484a52677d182153cbc454c301
diff --git a/cc/cc.go b/cc/cc.go
index 16a49d3..2520705 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -841,6 +841,10 @@
c.Properties.HideFromMake = true
}
+func (c *Module) HiddenFromMake() bool {
+ return c.Properties.HideFromMake
+}
+
func (c *Module) Toc() android.OptionalPath {
if c.linker != nil {
if library, ok := c.linker.(libraryInterface); ok {
@@ -1088,12 +1092,6 @@
return false
}
-// Returns true if the module is using VNDK libraries instead of the libraries in /system/lib or /system/lib64.
-// "product" and "vendor" variant modules return true for this function.
-// When BOARD_VNDK_VERSION is set, vendor variants of "vendor_available: true", "vendor: true",
-// "soc_specific: true" and more vendor installed modules are included here.
-// When PRODUCT_PRODUCT_VNDK_VERSION is set, product variants of "product_available: true" or
-// "product_specific: true" modules are included here.
func (c *Module) UseVndk() bool {
return c.Properties.VndkVersion != ""
}
@@ -1141,6 +1139,18 @@
return c.VendorProperties.IsVendorPublicLibrary
}
+func (c *Module) HasLlndkStubs() bool {
+ lib := moduleLibraryInterface(c)
+ return lib != nil && lib.hasLLNDKStubs()
+}
+
+func (c *Module) StubsVersion() string {
+ if lib, ok := c.linker.(versionedInterface); ok {
+ return lib.stubsVersion()
+ }
+ panic(fmt.Errorf("StubsVersion called on non-versioned module: %q", c.BaseModuleName()))
+}
+
// isImplementationForLLNDKPublic returns true for any variant of a cc_library that has LLNDK stubs
// and does not set llndk.vendor_available: false.
func (c *Module) isImplementationForLLNDKPublic() bool {
@@ -1185,7 +1195,7 @@
return false
}
-func (c *Module) isVndkSp() bool {
+func (c *Module) IsVndkSp() bool {
if vndkdep := c.vndkdep; vndkdep != nil {
return vndkdep.isVndkSp()
}
@@ -1204,7 +1214,7 @@
}
func (c *Module) MustUseVendorVariant() bool {
- return c.isVndkSp() || c.Properties.MustUseVendorVariant
+ return c.IsVndkSp() || c.Properties.MustUseVendorVariant
}
func (c *Module) getVndkExtendsModuleName() string {
@@ -1343,11 +1353,11 @@
}
func (ctx *moduleContextImpl) binary() bool {
- return ctx.mod.binary()
+ return ctx.mod.Binary()
}
func (ctx *moduleContextImpl) object() bool {
- return ctx.mod.object()
+ return ctx.mod.Object()
}
func (ctx *moduleContextImpl) canUseSdk() bool {
@@ -1445,7 +1455,7 @@
}
func (ctx *moduleContextImpl) isVndkSp() bool {
- return ctx.mod.isVndkSp()
+ return ctx.mod.IsVndkSp()
}
func (ctx *moduleContextImpl) IsVndkExt() bool {
@@ -1786,7 +1796,7 @@
// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or
// RECOVERY_SNAPSHOT_VERSION is current.
if i, ok := c.linker.(snapshotLibraryInterface); ok {
- if shouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
+ if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
i.collectHeadersForSnapshot(ctx)
}
}
@@ -1799,7 +1809,7 @@
// modules can be hidden from make as some are needed for resolving make side
// dependencies.
c.HideFromMake()
- } else if !c.installable(apexInfo) {
+ } else if !installable(c, apexInfo) {
c.SkipInstall()
}
@@ -2451,7 +2461,7 @@
return true
}
- if to.isVndkSp() || to.IsLlndk() {
+ if to.IsVndkSp() || to.IsLlndk() {
return false
}
@@ -3064,7 +3074,7 @@
return false
}
-func (c *Module) binary() bool {
+func (c *Module) Binary() bool {
if b, ok := c.linker.(interface {
binary() bool
}); ok {
@@ -3073,7 +3083,7 @@
return false
}
-func (c *Module) object() bool {
+func (c *Module) Object() bool {
if o, ok := c.linker.(interface {
object() bool
}); ok {
@@ -3155,18 +3165,25 @@
}
}
-// Return true if the module is ever installable.
func (c *Module) EverInstallable() bool {
return c.installer != nil &&
// Check to see whether the module is actually ever installable.
c.installer.everInstallable()
}
-func (c *Module) installable(apexInfo android.ApexInfo) bool {
+func (c *Module) PreventInstall() bool {
+ return c.Properties.PreventInstall
+}
+
+func (c *Module) Installable() *bool {
+ return c.Properties.Installable
+}
+
+func installable(c LinkableInterface, apexInfo android.ApexInfo) bool {
ret := c.EverInstallable() &&
// Check to see whether the module has been configured to not be installed.
- proptools.BoolDefault(c.Properties.Installable, true) &&
- !c.Properties.PreventInstall && c.outputFile.Valid()
+ proptools.BoolDefault(c.Installable(), true) &&
+ !c.PreventInstall() && c.OutputFile().Valid()
// The platform variant doesn't need further condition. Apex variants however might not
// be installable because it will likely to be included in the APEX and won't appear