Check vndk-private with the IsVndkPrivate() am: e09ac17466
am: 9f900373d7
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1554987 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Ia34f3f59d47e1e9ca7bd7b3a65f38d1be0a44416
This commit is contained in:
107
cc/cc_test.go
107
cc/cc_test.go
@@ -1624,17 +1624,19 @@ func TestVendorSnapshotSanitizer(t *testing.T) {
|
|||||||
assertString(t, staticCfiModule.outputFile.Path().Base(), "libsnapshot.cfi.a")
|
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()
|
t.Helper()
|
||||||
if c.ExcludeFromVendorSnapshot() != expected {
|
m := ctx.ModuleForTests(name, vendorVariant).Module().(*Module)
|
||||||
t.Errorf("expected %q ExcludeFromVendorSnapshot to be %t", c.String(), expected)
|
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()
|
t.Helper()
|
||||||
if c.ExcludeFromRecoverySnapshot() != expected {
|
m := ctx.ModuleForTests(name, recoveryVariant).Module().(*Module)
|
||||||
t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", c.String(), expected)
|
if m.ExcludeFromRecoverySnapshot() != expected {
|
||||||
|
t.Errorf("expected %q ExcludeFromRecoverySnapshot to be %t", m.String(), expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1658,6 +1660,12 @@ func TestVendorSnapshotExclude(t *testing.T) {
|
|||||||
vendor: true,
|
vendor: true,
|
||||||
exclude_from_vendor_snapshot: 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 := `
|
vendorProprietaryBp := `
|
||||||
@@ -1691,13 +1699,13 @@ func TestVendorSnapshotExclude(t *testing.T) {
|
|||||||
android.FailIfErrored(t, errs)
|
android.FailIfErrored(t, errs)
|
||||||
|
|
||||||
// Test an include and exclude framework module.
|
// Test an include and exclude framework module.
|
||||||
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
|
assertExcludeFromVendorSnapshotIs(t, ctx, "libinclude", false)
|
||||||
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libinclude", vendorVariant).Module().(*Module), false)
|
assertExcludeFromVendorSnapshotIs(t, ctx, "libexclude", true)
|
||||||
assertExcludeFromVendorSnapshotIs(t, ctx.ModuleForTests("libexclude", vendorVariant).Module().(*Module), true)
|
assertExcludeFromVendorSnapshotIs(t, ctx, "libavailable_exclude", true)
|
||||||
|
|
||||||
// A vendor module is excluded, but by its path, not the
|
// A vendor module is excluded, but by its path, not the
|
||||||
// exclude_from_vendor_snapshot property.
|
// 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.
|
// Verify the content of the vendor snapshot.
|
||||||
|
|
||||||
@@ -1728,6 +1736,8 @@ func TestVendorSnapshotExclude(t *testing.T) {
|
|||||||
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
|
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
|
||||||
checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
|
checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
|
||||||
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
|
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.
|
// Verify that each json file for an included module has a rule.
|
||||||
@@ -1789,53 +1799,6 @@ func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
func TestRecoverySnapshotCapture(t *testing.T) {
|
||||||
bp := `
|
bp := `
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -1973,7 +1936,7 @@ func TestRecoverySnapshotExclude(t *testing.T) {
|
|||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libinclude",
|
name: "libinclude",
|
||||||
srcs: ["src/include.cpp"],
|
srcs: ["src/include.cpp"],
|
||||||
recovery_available: true,
|
recovery_available: true,
|
||||||
}
|
}
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libexclude",
|
name: "libexclude",
|
||||||
@@ -1981,12 +1944,18 @@ func TestRecoverySnapshotExclude(t *testing.T) {
|
|||||||
recovery: true,
|
recovery: true,
|
||||||
exclude_from_recovery_snapshot: 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 := `
|
vendorProprietaryBp := `
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "libvendor",
|
name: "librecovery",
|
||||||
srcs: ["vendor.cpp"],
|
srcs: ["recovery.cpp"],
|
||||||
recovery: true,
|
recovery: true,
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
@@ -1999,7 +1968,7 @@ func TestRecoverySnapshotExclude(t *testing.T) {
|
|||||||
"framework/include.cpp": nil,
|
"framework/include.cpp": nil,
|
||||||
"framework/exclude.cpp": nil,
|
"framework/exclude.cpp": nil,
|
||||||
"device/Android.bp": []byte(vendorProprietaryBp),
|
"device/Android.bp": []byte(vendorProprietaryBp),
|
||||||
"device/vendor.cpp": nil,
|
"device/recovery.cpp": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
config := TestConfig(buildDir, android.Android, nil, "", mockFS)
|
||||||
@@ -2014,13 +1983,13 @@ func TestRecoverySnapshotExclude(t *testing.T) {
|
|||||||
android.FailIfErrored(t, errs)
|
android.FailIfErrored(t, errs)
|
||||||
|
|
||||||
// Test an include and exclude framework module.
|
// Test an include and exclude framework module.
|
||||||
assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", coreVariant).Module().(*Module), false)
|
assertExcludeFromRecoverySnapshotIs(t, ctx, "libinclude", false)
|
||||||
assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libinclude", recoveryVariant).Module().(*Module), false)
|
assertExcludeFromRecoverySnapshotIs(t, ctx, "libexclude", true)
|
||||||
assertExcludeFromRecoverySnapshotIs(t, ctx.ModuleForTests("libexclude", recoveryVariant).Module().(*Module), 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.
|
// 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.
|
// Verify the content of the recovery snapshot.
|
||||||
|
|
||||||
@@ -2048,8 +2017,10 @@ func TestRecoverySnapshotExclude(t *testing.T) {
|
|||||||
// Excluded modules
|
// Excluded modules
|
||||||
checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant)
|
checkSnapshotExclude(t, ctx, snapshotSingleton, "libexclude", "libexclude.so", sharedDir, sharedVariant)
|
||||||
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
|
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libexclude.so.json"))
|
||||||
checkSnapshotExclude(t, ctx, snapshotSingleton, "libvendor", "libvendor.so", sharedDir, sharedVariant)
|
checkSnapshotExclude(t, ctx, snapshotSingleton, "librecovery", "librecovery.so", sharedDir, sharedVariant)
|
||||||
excludeJsonFiles = append(excludeJsonFiles, filepath.Join(sharedDir, "libvendor.so.json"))
|
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.
|
// Verify that each json file for an included module has a rule.
|
||||||
|
@@ -40,10 +40,10 @@ type snapshotImage interface {
|
|||||||
// evalution of a function that may be not be defined.
|
// evalution of a function that may be not be defined.
|
||||||
inImage(m *Module) func() bool
|
inImage(m *Module) func() bool
|
||||||
|
|
||||||
// Returns the value of the "available" property for a given module for
|
// Returns true if the module is private and must not be included in the
|
||||||
// and snapshot, e.g., "vendor_available", "recovery_available", etc.
|
// snapshot. For example VNDK-private modules must return true for the
|
||||||
// or nil if the property is not defined.
|
// vendor snapshots. But false for the recovery snapshots.
|
||||||
available(m *Module) *bool
|
private(m *Module) bool
|
||||||
|
|
||||||
// Returns true if a dir under source tree is an SoC-owned proprietary
|
// Returns true if a dir under source tree is an SoC-owned proprietary
|
||||||
// directory, such as device/, vendor/, etc.
|
// directory, such as device/, vendor/, etc.
|
||||||
@@ -112,8 +112,8 @@ func (vendorSnapshotImage) inImage(m *Module) func() bool {
|
|||||||
return m.InVendor
|
return m.InVendor
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vendorSnapshotImage) available(m *Module) *bool {
|
func (vendorSnapshotImage) private(m *Module) bool {
|
||||||
return m.VendorProperties.Vendor_available
|
return m.IsVndkPrivate()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vendorSnapshotImage) isProprietaryPath(dir string) bool {
|
func (vendorSnapshotImage) isProprietaryPath(dir string) bool {
|
||||||
@@ -227,8 +227,9 @@ func (recoverySnapshotImage) inImage(m *Module) func() bool {
|
|||||||
return m.InRecovery
|
return m.InRecovery
|
||||||
}
|
}
|
||||||
|
|
||||||
func (recoverySnapshotImage) available(m *Module) *bool {
|
// recovery snapshot does not have private libraries.
|
||||||
return m.Properties.Recovery_available
|
func (recoverySnapshotImage) private(m *Module) bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (recoverySnapshotImage) isProprietaryPath(dir string) bool {
|
func (recoverySnapshotImage) isProprietaryPath(dir string) bool {
|
||||||
|
@@ -23,8 +23,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -177,15 +175,15 @@ func isVendorProprietaryModule(ctx android.BaseModuleContext) bool {
|
|||||||
|
|
||||||
func isRecoveryProprietaryModule(ctx android.BaseModuleContext) bool {
|
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.
|
// module.
|
||||||
if isRecoveryProprietaryPath(ctx.ModuleDir()) {
|
if isRecoveryProprietaryPath(ctx.ModuleDir()) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// However if the module is not in a vendor proprietary path, it may
|
// However if the module is not in a recovery proprietary path, it may
|
||||||
// still be a vendor proprietary module. This happens for cc modules
|
// still be a recovery proprietary module. This happens for cc modules
|
||||||
// that are excluded from the vendor snapshot, and it means that the
|
// that are excluded from the recovery snapshot, and it means that the
|
||||||
// vendor has assumed control of the framework-provided module.
|
// vendor has assumed control of the framework-provided module.
|
||||||
|
|
||||||
if c, ok := ctx.Module().(*Module); ok {
|
if c, ok := ctx.Module().(*Module); ok {
|
||||||
@@ -264,7 +262,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m *Module, inProprietaryPath bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if l.static() {
|
if l.static() {
|
||||||
return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
|
return m.outputFile.Valid() && !image.private(m)
|
||||||
}
|
}
|
||||||
if l.shared() {
|
if l.shared() {
|
||||||
if !m.outputFile.Valid() {
|
if !m.outputFile.Valid() {
|
||||||
@@ -282,7 +280,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m *Module, inProprietaryPath bool
|
|||||||
|
|
||||||
// Binaries and Objects
|
// Binaries and Objects
|
||||||
if m.binary() || m.object() {
|
if m.binary() || m.object() {
|
||||||
return m.outputFile.Valid() && proptools.BoolDefault(image.available(m), true)
|
return m.outputFile.Valid()
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
@@ -526,17 +524,6 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
|
ctx.Errorf("module %q in vendor proprietary path %q may not use \"exclude_from_vendor_snapshot: true\"", m.String(), moduleDir)
|
||||||
return
|
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) {
|
if !isSnapshotAware(ctx.DeviceConfig(), m, inProprietaryPath, apexInfo, c.image) {
|
||||||
|
Reference in New Issue
Block a user