Update prebuilt_etc available for snapshot

Make prebuilt_etc module available for the snapshot. This change
includes implementing snapshot interface for the prebuilt_etc module so
it can be added to the snapshot from the fake snapshot, or when the
module is specified in the list.

Bug: 192430376
Test: m nothing passed
Test: Checked if the module is included in the snapshot properly
Change-Id: I3574d2a1b8f8f4e5f083f3913e8768f5088d0c46
This commit is contained in:
Kiyoung Kim
2021-07-19 11:38:04 +09:00
parent 48f3778cb4
commit ae11c233b5
9 changed files with 339 additions and 33 deletions

View File

@@ -21,6 +21,7 @@ import (
"strings"
"android/soong/android"
"android/soong/snapshot"
)
// Efficiently converts a list of include directories to a single string
@@ -126,20 +127,6 @@ func makeSymlinkCmd(linkDirOnDevice string, linkName string, target string) stri
"ln -sf " + target + " " + filepath.Join(dir, linkName)
}
func copyFileRule(ctx android.SingletonContext, path android.Path, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: path,
Output: outPath,
Description: "copy " + path.String() + " -> " + out,
Args: map[string]string{
"cpFlags": "-f -L",
},
})
return outPath
}
func combineNoticesRule(ctx android.SingletonContext, paths android.Paths, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
ctx.Build(pctx, android.BuildParams{
@@ -151,12 +138,6 @@ func combineNoticesRule(ctx android.SingletonContext, paths android.Paths, out s
return outPath
}
func writeStringToFileRule(ctx android.SingletonContext, content, out string) android.OutputPath {
outPath := android.PathForOutput(ctx, out)
android.WriteFileRule(ctx, outPath, content)
return outPath
}
// Dump a map to a list file as:
//
// {key1} {value1}
@@ -172,5 +153,5 @@ func installMapListFileRule(ctx android.SingletonContext, m map[string]string, p
txtBuilder.WriteString(" ")
txtBuilder.WriteString(m[k])
}
return writeStringToFileRule(ctx, txtBuilder.String(), path)
return snapshot.WriteStringToFileRule(ctx, txtBuilder.String(), path)
}

View File

@@ -210,9 +210,9 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
if 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.
return writeStringToFileRule(ctx, "", out)
return snapshot.WriteStringToFileRule(ctx, "", out)
} else {
return copyFileRule(ctx, path, out)
return snapshot.CopyFileRule(pctx, ctx, path, out)
}
}
@@ -350,7 +350,7 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
return nil
}
ret = append(ret, writeStringToFileRule(ctx, string(j), propOut))
ret = append(ret, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
return ret
}

View File

@@ -25,6 +25,7 @@ import (
"android/soong/android"
"android/soong/cc/config"
"android/soong/etc"
"android/soong/snapshot"
"github.com/google/blueprint"
)
@@ -698,7 +699,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
libPath := m.outputFile.Path()
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, "shared", vndkType, libPath.Base())
ret = append(ret, copyFileRule(ctx, libPath, snapshotLibOut))
ret = append(ret, snapshot.CopyFileRule(pctx, ctx, libPath, snapshotLibOut))
if ctx.Config().VndkSnapshotBuildArtifacts() {
prop := struct {
@@ -720,7 +721,7 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
ctx.Errorf("json marshal to %q failed: %#v", propOut, err)
return nil, false
}
ret = append(ret, writeStringToFileRule(ctx, string(j), propOut))
ret = append(ret, snapshot.WriteStringToFileRule(ctx, string(j), propOut))
}
return ret, true
}
@@ -778,8 +779,8 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
// install all headers after removing duplicates
for _, header := range android.FirstUniquePaths(headers) {
snapshotOutputs = append(snapshotOutputs, copyFileRule(
ctx, header, filepath.Join(includeDir, header.String())))
snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
pctx, ctx, header, filepath.Join(includeDir, header.String())))
}
// install *.libraries.txt except vndkcorevariant.libraries.txt
@@ -788,8 +789,8 @@ func (c *vndkSnapshotSingleton) GenerateBuildActions(ctx android.SingletonContex
if !ok || !m.Enabled() || m.Name() == vndkUsingCoreVariantLibrariesTxt {
return
}
snapshotOutputs = append(snapshotOutputs, copyFileRule(
ctx, m.OutputFile(), filepath.Join(configsDir, m.Name())))
snapshotOutputs = append(snapshotOutputs, snapshot.CopyFileRule(
pctx, ctx, m.OutputFile(), filepath.Join(configsDir, m.Name())))
})
/*