Check vndk-private with the IsVndkPrivate()
*_available will not provide if a module is VNDK-private or not.
Fixed it by using IsVndkPrivate() with private() interface.
By allowing exclude_from_vendor_snapshot for vendor_available
modules, available() interface is no longer required. Tests are
updated for exclude_from_vendor_snapshot on vendor_available modules.
Bug: 175768895
Test: m nothing
Change-Id: I9ff85256170d59b378a4c354d5c007cfbeacabc5
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 0cd83a7..d0d8759 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -1624,17 +1624,19 @@
assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a")
}
-func assertExcludeFromVendorSnapshotIs(t *testing.T, c *Module, expected bool) {
+func assertExcludeFromVendorSnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) {
t.Helper()
- if c.ExcludeFromVendorSnapshot() != expected {
- t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", c.String(), expected)
+ m := ctx.ModuleForTests(name, vendorVariant).Module().(*Module)
+ if m.ExcludeFromVendorSnapshot() != expected {
+ t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", m.String(), expected)
}
}
-func assertExcludeFromRecoverySnapshotIs(t *testing.T, c *Module, expected bool) {
+func assertExcludeFromRecoverySnapshotIs(t *testing.T, ctx *android.TestContext, name string, expected bool) {
t.Helper()
- if c.ExcludeFromRecoverySnapshot() != expected {
- t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", c.String(), expected)
+ m := ctx.ModuleForTests(name, recoveryVariant).Module().(*Module)
+ if m.ExcludeFromRecoverySnapshot() != expected {
+ t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected)
}
}
@@ -1658,6 +1660,12 @@
vendor: true,
exclude_from_vendor_snapshot: true,
}
+ cc_library_shared {
+ name: "libavailable_exclude",
+ srcs: ["src/exclude.cpp"],
+ vendor_available: true,
+ exclude_from_vendor_snapshot: true,
+ }
`
vendorProprietaryBp := `
@@ -1691,13 +1699,13 @@
android.FailIfErrored(t, errs)
// Test an include and exclude framework module.
- assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
- assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", vendorVariant).Module().(*Module), false)
- assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libexclude", vendorVariant).Module().(*Module), true)
+ assertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false)
+ assertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true)
+ assertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true)
// A vendor module is excluded, but by its path, not the
// exclude_from_vendor_snapshot property.
- assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libvendor", vendorVariant).Module().(*Module), false)
+ assertExcludeFromVendorSnapshotIs(t, ctx, "libvendor", false)
// Verify the content of the vendor snapshot.
@@ -1728,6 +1736,8 @@
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
+ checkSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant)
+ excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json"))
}
// Verify that each json file for an included module has a rule.
@@ -1789,53 +1799,6 @@
})
}
-func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) {
-
- // This test verifies that using the exclude_from_vendor_snapshot
- // property on a module that is vendor available generates an error. A
- // vendor available module must be captured in the vendor snapshot and
- // must not built from source when building the vendor image against
- // the vendor snapshot.
-
- frameworkBp := `
- cc_library_shared {
- name: "libinclude",
- srcs: ["src/include.cpp"],
- vendor_available: true,
- exclude_from_vendor_snapshot: true,
- }
- `
-
- depsBp := GatherRequiredDepsForTest(android.Android)
-
- mockFS := map[string][]byte{
- "deps/Android.bp": []byte(depsBp),
- "framework/Android.bp": []byte(frameworkBp),
- "framework/include.cpp": nil,
- }
-
- config := TestConfig(buildDir, android.Android, nil, "", mockFS)
- config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
- config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
- ctx := CreateTestContext(config)
- ctx.Register()
-
- _, errs := ctx.ParseFileList(".", []string{"deps/Android.bp", "framework/Android.bp"})
- android.FailIfErrored(t, errs)
-
- _, errs = ctx.PrepareBuildActions(config)
- android.CheckErrorsAgainstExpectations(t, errs, []string{
- `module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:vendor.+,arch:arm64_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- `module "libinclude\{.+,image:vendor.+,arch:arm_.+\}" may not use both "vendor_available: true" and "exclude_from_vendor_snapshot: true"`,
- })
-}
-
func TestRecoverySnapshotCapture(t *testing.T) {
bp := `
cc_library {
@@ -1973,7 +1936,7 @@
cc_library_shared {
name: "libinclude",
srcs: ["src/include.cpp"],
- recovery_available: true,
+ recovery_available: true,
}
cc_library_shared {
name: "libexclude",
@@ -1981,12 +1944,18 @@
recovery: true,
exclude_from_recovery_snapshot: true,
}
+ cc_library_shared {
+ name: "libavailable_exclude",
+ srcs: ["src/exclude.cpp"],
+ recovery_available: true,
+ exclude_from_recovery_snapshot: true,
+ }
`
vendorProprietaryBp := `
cc_library_shared {
- name: "libvendor",
- srcs: ["vendor.cpp"],
+ name: "librecovery",
+ srcs: ["recovery.cpp"],
recovery: true,
}
`
@@ -1999,7 +1968,7 @@
"framework/include.cpp": nil,
"framework/exclude.cpp": nil,
"device/Android.bp": []byte(vendorProprietaryBp),
- "device/vendor.cpp": nil,
+ "device/recovery.cpp": nil,
}
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
@@ -2014,13 +1983,13 @@
android.FailIfErrored(t, errs)
// Test an include and exclude framework module.
- assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
- assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", recoveryVariant).Module().(*Module), false)
- assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libexclude", recoveryVariant).Module().(*Module), true)
+ assertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false)
+ assertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true)
+ assertExcludeFromRecoverySnapshotIs(t, ctx, "libavailable_exclude", true)
- // A vendor module is excluded, but by its path, not the
+ // A recovery module is excluded, but by its path, not the
// exclude_from_recovery_snapshot property.
- assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libvendor", recoveryVariant).Module().(*Module), false)
+ assertExcludeFromRecoverySnapshotIs(t, ctx, "librecovery", false)
// Verify the content of the recovery snapshot.
@@ -2048,8 +2017,10 @@
// Excluded modules
checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant)
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
- checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
- excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
+ checkSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant)
+ excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "librecovery.so.json"))
+ checkSnapshotExclude(t, ctx, snapshotSingleton, "libavailable_exclude", "libavailable_exclude.so", sharedDir, sharedVariant)
+ excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libavailable_exclude.so.json"))
}
// Verify that each json file for an included module has a rule.
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index d9c46ea..2003e03 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -40,10 +40,10 @@
// evalution of a function that may be not be defined.
inImage(m *Module) func() bool
- // Returns the value of the "available" property for a given module for
- // and snapshot, e.g., "vendor_available", "recovery_available", etc.
- // or nil if the property is not defined.
- available(m *Module) *bool
+ // Returns true if the module is private and must not be included in the
+ // snapshot. For example VNDK-private modules must return true for the
+ // vendor snapshots. But false for the recovery snapshots.
+ private(m *Module) bool
// Returns true if a dir under source tree is an SoC-owned proprietary
// directory, such as device/, vendor/, etc.
@@ -112,8 +112,8 @@
return m.InVendor
}
-func (vendorSnapshotImage) available(m *Module) *bool {
- return m.VendorProperties.Vendor_available
+func (vendorSnapshotImage) private(m *Module) bool {
+ return m.IsVndkPrivate()
}
func (vendorSnapshotImage) isProprietaryPath(dir string) bool {
@@ -227,8 +227,9 @@
return m.InRecovery
}
-func (recoverySnapshotImage) available(m *Module) *bool {
- return m.Properties.Recovery_available
+// recovery snapshot does not have private libraries.
+func (recoverySnapshotImage) private(m *Module) bool {
+ return false
}
func (recoverySnapshotImage) isProprietaryPath(dir string) bool {
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 6bd095f..7346aac 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -23,8 +23,6 @@
"sort"
"strings"
- "github.com/google/blueprint/proptools"
-
"android/soong/android"
)
@@ -177,15 +175,15 @@
func isRecoveryProprietaryModule(ctx android.BaseModuleContext) bool {
- // Any module in a vendor proprietary path is a vendor proprietary
+ // Any module in a recovery proprietary path is a recovery proprietary
// module.
if isRecoveryProprietaryPath(ctx.ModuleDir()) {
return true
}
- // However if the module is not in a vendor proprietary path, it may
- // still be a vendor proprietary module. This happens for cc modules
- // that are excluded from the vendor snapshot, and it means that the
+ // However if the module is not in a recovery proprietary path, it may
+ // still be a recovery proprietary module. This happens for cc modules
+ // that are excluded from the recovery snapshot, and it means that the
// vendor has assumed control of the framework-provided module.
if c, ok := ctx.Module().(*Module); ok {
@@ -264,7 +262,7 @@
}
}
if l.static() {
- return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
+ return m.outputFile.Valid() && !image.private(m)
}
if l.shared() {
if !m.outputFile.Valid() {
@@ -282,7 +280,7 @@
// Binaries and Objects
if m.binary() || m.object() {
- return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
+ return m.outputFile.Valid()
}
return false
@@ -526,17 +524,6 @@
ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
return
}
- if Bool(c.image.available(m)) {
- // Error: may not combine "vendor_available:
- // true" with "exclude_from_vendor_snapshot:
- // true".
- ctx.Errorf(
- "module %q may not use both \""+
- c.name+
- "_available: true\" and \"exclude_from_vendor_snapshot: true\"",
- m.String())
- return
- }
}
if !isSnapshotAware(ctx.DeviceConfig(), m, inProprietaryPath, apexInfo, c.image) {