Merge "Implement fake vendor snapshot" am: 56bfef1032
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1538640 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I3e692235fd03ae3ae42444ebc05c04cf337d27ad
This commit is contained in:
@@ -1248,6 +1248,15 @@ func TestVendorSnapshotCapture(t *testing.T) {
|
|||||||
t.Errorf("%q expected but not found", jsonFile)
|
t.Errorf("%q expected but not found", jsonFile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fake snapshot should have all outputs in the normal snapshot.
|
||||||
|
fakeSnapshotSingleton := ctx.SingletonForTests("vendor-fake-snapshot")
|
||||||
|
for _, output := range snapshotSingleton.AllOutputs() {
|
||||||
|
fakeOutput := strings.Replace(output, "/vendor-snapshot/", "/fake/vendor-snapshot/", 1)
|
||||||
|
if fakeSnapshotSingleton.MaybeOutput(fakeOutput).Rule == nil {
|
||||||
|
t.Errorf("%q expected but not found", fakeOutput)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVendorSnapshotUse(t *testing.T) {
|
func TestVendorSnapshotUse(t *testing.T) {
|
||||||
@@ -1679,6 +1688,8 @@ func TestVendorSnapshotExcludeInVendorProprietaryPathErrors(t *testing.T) {
|
|||||||
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
||||||
`module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
`module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
||||||
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
||||||
|
`module "libvendor\{.+,image:vendor.+,arch:arm64_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
||||||
|
`module "libvendor\{.+,image:vendor.+,arch:arm_.+\}" in vendor proprietary path "device" may not use "exclude_from_vendor_snapshot: true"`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1722,6 +1733,10 @@ func TestVendorSnapshotExcludeWithVendorAvailable(t *testing.T) {
|
|||||||
`module "libinclude\{.+,image:,arch:arm_.+\}" 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: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: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"`,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -94,6 +94,8 @@ func (vendorSnapshotImage) init() {
|
|||||||
android.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
|
android.RegisterModuleType("vendor_snapshot_header", VendorSnapshotHeaderFactory)
|
||||||
android.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
|
android.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
|
||||||
android.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
|
android.RegisterModuleType("vendor_snapshot_object", VendorSnapshotObjectFactory)
|
||||||
|
|
||||||
|
android.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vendorSnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool {
|
func (vendorSnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool {
|
||||||
|
@@ -577,6 +577,7 @@ func CreateTestContext(config android.Config) *android.TestContext {
|
|||||||
RegisterRequiredBuildComponentsForTest(ctx)
|
RegisterRequiredBuildComponentsForTest(ctx)
|
||||||
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
||||||
ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
|
ctx.RegisterSingletonType("vendor-snapshot", VendorSnapshotSingleton)
|
||||||
|
ctx.RegisterSingletonType("vendor-fake-snapshot", VendorFakeSnapshotSingleton)
|
||||||
ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
|
ctx.RegisterSingletonType("recovery-snapshot", RecoverySnapshotSingleton)
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
|
@@ -34,6 +34,16 @@ var vendorSnapshotSingleton = snapshotSingleton{
|
|||||||
android.OptionalPath{},
|
android.OptionalPath{},
|
||||||
true,
|
true,
|
||||||
vendorSnapshotImageSingleton,
|
vendorSnapshotImageSingleton,
|
||||||
|
false, /* fake */
|
||||||
|
}
|
||||||
|
|
||||||
|
var vendorFakeSnapshotSingleton = snapshotSingleton{
|
||||||
|
"vendor",
|
||||||
|
"SOONG_VENDOR_FAKE_SNAPSHOT_ZIP",
|
||||||
|
android.OptionalPath{},
|
||||||
|
true,
|
||||||
|
vendorSnapshotImageSingleton,
|
||||||
|
true, /* fake */
|
||||||
}
|
}
|
||||||
|
|
||||||
var recoverySnapshotSingleton = snapshotSingleton{
|
var recoverySnapshotSingleton = snapshotSingleton{
|
||||||
@@ -42,12 +52,17 @@ var recoverySnapshotSingleton = snapshotSingleton{
|
|||||||
android.OptionalPath{},
|
android.OptionalPath{},
|
||||||
false,
|
false,
|
||||||
recoverySnapshotImageSingleton,
|
recoverySnapshotImageSingleton,
|
||||||
|
false, /* fake */
|
||||||
}
|
}
|
||||||
|
|
||||||
func VendorSnapshotSingleton() android.Singleton {
|
func VendorSnapshotSingleton() android.Singleton {
|
||||||
return &vendorSnapshotSingleton
|
return &vendorSnapshotSingleton
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func VendorFakeSnapshotSingleton() android.Singleton {
|
||||||
|
return &vendorFakeSnapshotSingleton
|
||||||
|
}
|
||||||
|
|
||||||
func RecoverySnapshotSingleton() android.Singleton {
|
func RecoverySnapshotSingleton() android.Singleton {
|
||||||
return &recoverySnapshotSingleton
|
return &recoverySnapshotSingleton
|
||||||
}
|
}
|
||||||
@@ -70,6 +85,11 @@ type snapshotSingleton struct {
|
|||||||
// associated with this snapshot (e.g., specific to the vendor image,
|
// associated with this snapshot (e.g., specific to the vendor image,
|
||||||
// recovery image, etc.).
|
// recovery image, etc.).
|
||||||
image snapshotImage
|
image snapshotImage
|
||||||
|
|
||||||
|
// Whether this singleton is for fake snapshot or not.
|
||||||
|
// Fake snapshot is a snapshot whose prebuilt binaries and headers are empty.
|
||||||
|
// It is much faster to generate, and can be used to inspect dependencies.
|
||||||
|
fake bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -332,6 +352,11 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
snapshotDir := c.name + "-snapshot"
|
snapshotDir := c.name + "-snapshot"
|
||||||
|
if c.fake {
|
||||||
|
// If this is a fake snapshot singleton, place all files under fake/ subdirectory to avoid
|
||||||
|
// collision with real snapshot files
|
||||||
|
snapshotDir = filepath.Join("fake", snapshotDir)
|
||||||
|
}
|
||||||
snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
|
snapshotArchDir := filepath.Join(snapshotDir, ctx.DeviceConfig().DeviceArch())
|
||||||
|
|
||||||
includeDir := filepath.Join(snapshotArchDir, "include")
|
includeDir := filepath.Join(snapshotArchDir, "include")
|
||||||
@@ -343,6 +368,15 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
|
|
||||||
var headers android.Paths
|
var headers android.Paths
|
||||||
|
|
||||||
|
copyFile := copyFileRule
|
||||||
|
if c.fake {
|
||||||
|
// All prebuilt binaries and headers are installed by copyFile function. This makes a fake
|
||||||
|
// snapshot just touch prebuilts and headers, rather than installing real files.
|
||||||
|
copyFile = func(ctx android.SingletonContext, path android.Path, out string) android.OutputPath {
|
||||||
|
return writeStringToFileRule(ctx, "", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// installSnapshot function copies prebuilt file (.so, .a, or executable) and json flag file.
|
// installSnapshot function copies prebuilt file (.so, .a, or executable) and json flag file.
|
||||||
// For executables, init_rc and vintf_fragments files are also copied.
|
// For executables, init_rc and vintf_fragments files are also copied.
|
||||||
installSnapshot := func(m *Module) android.Paths {
|
installSnapshot := func(m *Module) android.Paths {
|
||||||
@@ -381,7 +415,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
out := filepath.Join(configsDir, path.Base())
|
out := filepath.Join(configsDir, path.Base())
|
||||||
if !installedConfigs[out] {
|
if !installedConfigs[out] {
|
||||||
installedConfigs[out] = true
|
installedConfigs[out] = true
|
||||||
ret = append(ret, copyFileRule(ctx, path, out))
|
ret = append(ret, copyFile(ctx, path, out))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +466,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
prop.ModuleName += ".cfi"
|
prop.ModuleName += ".cfi"
|
||||||
}
|
}
|
||||||
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, stem)
|
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, stem)
|
||||||
ret = append(ret, copyFileRule(ctx, libPath, snapshotLibOut))
|
ret = append(ret, copyFile(ctx, libPath, snapshotLibOut))
|
||||||
} else {
|
} else {
|
||||||
stem = ctx.ModuleName(m)
|
stem = ctx.ModuleName(m)
|
||||||
}
|
}
|
||||||
@@ -446,7 +480,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
// install bin
|
// install bin
|
||||||
binPath := m.outputFile.Path()
|
binPath := m.outputFile.Path()
|
||||||
snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base())
|
snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base())
|
||||||
ret = append(ret, copyFileRule(ctx, binPath, snapshotBinOut))
|
ret = append(ret, copyFile(ctx, binPath, snapshotBinOut))
|
||||||
propOut = snapshotBinOut + ".json"
|
propOut = snapshotBinOut + ".json"
|
||||||
} else if m.object() {
|
} else if m.object() {
|
||||||
// object files aren't installed to the device, so their names can conflict.
|
// object files aren't installed to the device, so their names can conflict.
|
||||||
@@ -454,7 +488,7 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
objPath := m.outputFile.Path()
|
objPath := m.outputFile.Path()
|
||||||
snapshotObjOut := filepath.Join(snapshotArchDir, targetArch, "object",
|
snapshotObjOut := filepath.Join(snapshotArchDir, targetArch, "object",
|
||||||
ctx.ModuleName(m)+filepath.Ext(objPath.Base()))
|
ctx.ModuleName(m)+filepath.Ext(objPath.Base()))
|
||||||
ret = append(ret, copyFileRule(ctx, objPath, snapshotObjOut))
|
ret = append(ret, copyFile(ctx, objPath, snapshotObjOut))
|
||||||
propOut = snapshotObjOut + ".json"
|
propOut = snapshotObjOut + ".json"
|
||||||
} else {
|
} else {
|
||||||
ctx.Errorf("unknown module %q in vendor snapshot", m.String())
|
ctx.Errorf("unknown module %q in vendor snapshot", m.String())
|
||||||
@@ -519,16 +553,14 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
// skip already copied notice file
|
// skip already copied notice file
|
||||||
if !installedNotices[noticeOut] {
|
if !installedNotices[noticeOut] {
|
||||||
installedNotices[noticeOut] = true
|
installedNotices[noticeOut] = true
|
||||||
snapshotOutputs = append(snapshotOutputs, combineNoticesRule(
|
snapshotOutputs = append(snapshotOutputs, combineNoticesRule(ctx, m.NoticeFiles(), noticeOut))
|
||||||
ctx, m.NoticeFiles(), noticeOut))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// install all headers after removing duplicates
|
// install all headers after removing duplicates
|
||||||
for _, header := range android.FirstUniquePaths(headers) {
|
for _, header := range android.FirstUniquePaths(headers) {
|
||||||
snapshotOutputs = append(snapshotOutputs, copyFileRule(
|
snapshotOutputs = append(snapshotOutputs, copyFile(ctx, header, filepath.Join(includeDir, header.String())))
|
||||||
ctx, header, filepath.Join(includeDir, header.String())))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// All artifacts are ready. Sort them to normalize ninja and then zip.
|
// All artifacts are ready. Sort them to normalize ninja and then zip.
|
||||||
|
Reference in New Issue
Block a user