Discard duplicate operations to copy files to snapshot am: c62a5107f8 am: 07d3de0b12

Change-Id: I267f823db85edaec756a8184d1933c824b2392b8
This commit is contained in:
Automerger Merge Worker
2019-12-12 14:28:10 +00:00
2 changed files with 61 additions and 7 deletions

View File

@@ -142,6 +142,45 @@ func TestBasicSdkWithCc(t *testing.T) {
ensureListContains(t, pathsToStrings(cpplibForMyApex2.Rule("ld").Implicits), sdkMemberV2.String())
}
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
native_shared_libs: ["mynativelib1", "mynativelib2"],
}
cc_library_shared {
name: "mynativelib1",
srcs: [
"Test.cpp",
],
export_include_dirs: ["include"],
system_shared_libs: [],
stl: "none",
}
cc_library_shared {
name: "mynativelib2",
srcs: [
"Test.cpp",
],
export_include_dirs: ["include"],
system_shared_libs: [],
stl: "none",
}
`)
result.CheckSnapshot("mysdk", "android_common", "",
checkAllCopyRules(`
include/Test.h -> include/include/Test.h
.intermediates/mynativelib1/android_arm64_armv8-a_core_shared/mynativelib1.so -> arm64/lib/mynativelib1.so
.intermediates/mynativelib1/android_arm_armv7-a-neon_core_shared/mynativelib1.so -> arm/lib/mynativelib1.so
.intermediates/mynativelib2/android_arm64_armv8-a_core_shared/mynativelib2.so -> arm64/lib/mynativelib2.so
.intermediates/mynativelib2/android_arm_armv7-a-neon_core_shared/mynativelib2.so -> arm/lib/mynativelib2.so
`),
)
}
func TestSnapshotWithCcShared(t *testing.T) {
result := testSdkWithCc(t, `
sdk {

View File

@@ -184,6 +184,7 @@ func (s *sdk) buildSnapshot(ctx android.ModuleContext) android.OutputPath {
sdk: s,
version: "current",
snapshotDir: snapshotDir.OutputPath,
copies: make(map[string]string),
filesToZip: []android.Path{bp.path},
bpFile: bpFile,
prebuiltModules: make(map[string]*bpModule),
@@ -337,6 +338,11 @@ type snapshotBuilder struct {
version string
snapshotDir android.OutputPath
bpFile *bpFile
// Map from destination to source of each copy - used to eliminate duplicates and
// detect conflicts.
copies map[string]string
filesToZip android.Paths
zipsToMerge android.Paths
@@ -345,13 +351,22 @@ type snapshotBuilder struct {
}
func (s *snapshotBuilder) CopyToSnapshot(src android.Path, dest string) {
path := s.snapshotDir.Join(s.ctx, dest)
s.ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: src,
Output: path,
})
s.filesToZip = append(s.filesToZip, path)
if existing, ok := s.copies[dest]; ok {
if existing != src.String() {
s.ctx.ModuleErrorf("conflicting copy, %s copied from both %s and %s", dest, existing, src)
return
}
} else {
path := s.snapshotDir.Join(s.ctx, dest)
s.ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: src,
Output: path,
})
s.filesToZip = append(s.filesToZip, path)
s.copies[dest] = src.String()
}
}
func (s *snapshotBuilder) UnzipToSnapshot(zipPath android.Path, destDir string) {