Merge "Copy the out/soong/build_number.txt file into sdk snapshots" am: d72c85219a
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2056132 Change-Id: I65933c6250c4a6b0c26948518f7fdde1b4eca24a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -25,6 +25,8 @@ import (
|
|||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
"android/soong/genrule"
|
"android/soong/genrule"
|
||||||
"android/soong/java"
|
"android/soong/java"
|
||||||
|
|
||||||
|
"github.com/google/blueprint/proptools"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Prepare for running an sdk test with an apex.
|
// Prepare for running an sdk test with an apex.
|
||||||
@@ -81,6 +83,11 @@ var prepareForSdkTest = android.GroupFixturePreparers(
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
// Add a build number file.
|
||||||
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
|
variables.BuildNumberFile = proptools.StringPtr(BUILD_NUMBER_FILE)
|
||||||
|
}),
|
||||||
|
|
||||||
// Make sure that every test provides all the source files.
|
// Make sure that every test provides all the source files.
|
||||||
android.PrepareForTestDisallowNonExistentPaths,
|
android.PrepareForTestDisallowNonExistentPaths,
|
||||||
android.MockFS{
|
android.MockFS{
|
||||||
@@ -143,6 +150,8 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk)
|
|||||||
copyRules := &strings.Builder{}
|
copyRules := &strings.Builder{}
|
||||||
otherCopyRules := &strings.Builder{}
|
otherCopyRules := &strings.Builder{}
|
||||||
snapshotDirPrefix := sdk.builderForTests.snapshotDir.String() + "/"
|
snapshotDirPrefix := sdk.builderForTests.snapshotDir.String() + "/"
|
||||||
|
|
||||||
|
seenBuildNumberFile := false
|
||||||
for _, bp := range buildParams {
|
for _, bp := range buildParams {
|
||||||
switch bp.Rule.String() {
|
switch bp.Rule.String() {
|
||||||
case android.Cp.String():
|
case android.Cp.String():
|
||||||
@@ -152,8 +161,14 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk)
|
|||||||
src := android.NormalizePathForTesting(bp.Input)
|
src := android.NormalizePathForTesting(bp.Input)
|
||||||
// We differentiate between copy rules for the snapshot, and copy rules for the install file.
|
// We differentiate between copy rules for the snapshot, and copy rules for the install file.
|
||||||
if strings.HasPrefix(output.String(), snapshotDirPrefix) {
|
if strings.HasPrefix(output.String(), snapshotDirPrefix) {
|
||||||
// Get source relative to build directory.
|
// Don't include the build-number.txt file in the copy rules as that would break lots of
|
||||||
_, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest)
|
// tests, just verify that it is copied here as it should appear in every snapshot.
|
||||||
|
if output.Base() == BUILD_NUMBER_FILE {
|
||||||
|
seenBuildNumberFile = true
|
||||||
|
} else {
|
||||||
|
// Get source relative to build directory.
|
||||||
|
_, _ = fmt.Fprintf(copyRules, "%s -> %s\n", src, dest)
|
||||||
|
}
|
||||||
info.snapshotContents = append(info.snapshotContents, dest)
|
info.snapshotContents = append(info.snapshotContents, dest)
|
||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintf(otherCopyRules, "%s -> %s\n", src, dest)
|
_, _ = fmt.Fprintf(otherCopyRules, "%s -> %s\n", src, dest)
|
||||||
@@ -189,6 +204,10 @@ func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !seenBuildNumberFile {
|
||||||
|
panic(fmt.Sprintf("Every snapshot must include the %s file", BUILD_NUMBER_FILE))
|
||||||
|
}
|
||||||
|
|
||||||
info.copyRules = copyRules.String()
|
info.copyRules = copyRules.String()
|
||||||
info.otherCopyRules = otherCopyRules.String()
|
info.otherCopyRules = otherCopyRules.String()
|
||||||
|
|
||||||
|
@@ -281,6 +281,10 @@ func appendUniqueVariants(variants []android.SdkAware, newVariant android.SdkAwa
|
|||||||
return append(variants, newVariant)
|
return append(variants, newVariant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BUILD_NUMBER_FILE is the name of the file in the snapshot zip that will contain the number of
|
||||||
|
// the build from which the snapshot was produced.
|
||||||
|
const BUILD_NUMBER_FILE = "snapshot-creation-build-number.txt"
|
||||||
|
|
||||||
// SDK directory structure
|
// SDK directory structure
|
||||||
// <sdk_root>/
|
// <sdk_root>/
|
||||||
// Android.bp : definition of a 'sdk' module is here. This is a hand-made one.
|
// Android.bp : definition of a 'sdk' module is here. This is a hand-made one.
|
||||||
@@ -479,6 +483,9 @@ be unnecessary as every module in the sdk already has its own licenses property.
|
|||||||
|
|
||||||
bp.build(pctx, ctx, nil)
|
bp.build(pctx, ctx, nil)
|
||||||
|
|
||||||
|
// Copy the build number file into the snapshot.
|
||||||
|
builder.CopyToSnapshot(ctx.Config().BuildNumberFile(ctx), BUILD_NUMBER_FILE)
|
||||||
|
|
||||||
filesToZip := builder.filesToZip
|
filesToZip := builder.filesToZip
|
||||||
|
|
||||||
// zip them all
|
// zip them all
|
||||||
|
Reference in New Issue
Block a user