Merge "Support ninja rsp files in soong_zip"
This commit is contained in:
@@ -68,7 +68,7 @@ func robolectricTestSuite(ctx SingletonContext, files map[string]InstallPaths) W
|
|||||||
FlagWithOutput("-o ", outputFile).
|
FlagWithOutput("-o ", outputFile).
|
||||||
FlagWithArg("-P ", "host/testcases").
|
FlagWithArg("-P ", "host/testcases").
|
||||||
FlagWithArg("-C ", testCasesDir.String()).
|
FlagWithArg("-C ", testCasesDir.String()).
|
||||||
FlagWithRspFileInputList("-l ", installedPaths.Paths())
|
FlagWithRspFileInputList("-r ", installedPaths.Paths())
|
||||||
rule.Build(pctx, ctx, "robolectric_tests_zip", "robolectric-tests.zip")
|
rule.Build(pctx, ctx, "robolectric_tests_zip", "robolectric-tests.zip")
|
||||||
|
|
||||||
return outputFile
|
return outputFile
|
||||||
|
@@ -186,8 +186,8 @@ var (
|
|||||||
// OutputFile here is $in for remote-execution since its possible that
|
// OutputFile here is $in for remote-execution since its possible that
|
||||||
// clang-tidy modifies the given input file itself and $out refers to the
|
// clang-tidy modifies the given input file itself and $out refers to the
|
||||||
// ".tidy" file generated for ninja-dependency reasons.
|
// ".tidy" file generated for ninja-dependency reasons.
|
||||||
OutputFiles: []string{"$in"},
|
OutputFiles: []string{"$in"},
|
||||||
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
||||||
}, []string{"cFlags", "tidyFlags"}, []string{})
|
}, []string{"cFlags", "tidyFlags"}, []string{})
|
||||||
|
|
||||||
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
||||||
@@ -265,9 +265,9 @@ var (
|
|||||||
|
|
||||||
zip = pctx.AndroidStaticRule("zip",
|
zip = pctx.AndroidStaticRule("zip",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp",
|
Command: "${SoongZipCmd} -o ${out} -C $$OUT_DIR -r ${out}.rsp",
|
||||||
CommandDeps: []string{"${SoongZipCmd}"},
|
CommandDeps: []string{"${SoongZipCmd}"},
|
||||||
Rspfile: "$out.rsp",
|
Rspfile: "${out}.rsp",
|
||||||
RspfileContent: "$in",
|
RspfileContent: "$in",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -402,7 +402,7 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
||||||
Flag("-j").
|
Flag("-j").
|
||||||
FlagWithOutput("-o ", corpusZip)
|
FlagWithOutput("-o ", corpusZip)
|
||||||
command.FlagWithRspFileInputList("-l ", fuzzModule.corpus)
|
command.FlagWithRspFileInputList("-r ", fuzzModule.corpus)
|
||||||
files = append(files, fileToZip{corpusZip, ""})
|
files = append(files, fileToZip{corpusZip, ""})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -513,7 +513,7 @@ func lintZip(ctx android.BuilderContext, paths android.Paths, outputPath android
|
|||||||
rule.Command().BuiltTool(ctx, "soong_zip").
|
rule.Command().BuiltTool(ctx, "soong_zip").
|
||||||
FlagWithOutput("-o ", outputPath).
|
FlagWithOutput("-o ", outputPath).
|
||||||
FlagWithArg("-C ", android.PathForIntermediates(ctx).String()).
|
FlagWithArg("-C ", android.PathForIntermediates(ctx).String()).
|
||||||
FlagWithRspFileInputList("-l ", paths)
|
FlagWithRspFileInputList("-r ", paths)
|
||||||
|
|
||||||
rule.Build(pctx, ctx, outputPath.Base(), outputPath.Base())
|
rule.Build(pctx, ctx, outputPath.Base(), outputPath.Base())
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ var (
|
|||||||
|
|
||||||
zipFiles = pctx.AndroidStaticRule("SnapshotZipFiles",
|
zipFiles = pctx.AndroidStaticRule("SnapshotZipFiles",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: `${config.SoongZipCmd} -C $basedir -l $out.rsp -o $out`,
|
Command: `${config.SoongZipCmd} -C $basedir -r $out.rsp -o $out`,
|
||||||
CommandDeps: []string{
|
CommandDeps: []string{
|
||||||
"${config.SoongZipCmd}",
|
"${config.SoongZipCmd}",
|
||||||
},
|
},
|
||||||
|
@@ -62,6 +62,15 @@ func (listFiles) Set(s string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type rspFiles struct{}
|
||||||
|
|
||||||
|
func (rspFiles) String() string { return `""` }
|
||||||
|
|
||||||
|
func (rspFiles) Set(s string) error {
|
||||||
|
fileArgsBuilder.RspFile(s)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type dir struct{}
|
type dir struct{}
|
||||||
|
|
||||||
func (dir) String() string { return `""` }
|
func (dir) String() string { return `""` }
|
||||||
@@ -143,7 +152,8 @@ func main() {
|
|||||||
traceFile := flags.String("trace", "", "write trace to file")
|
traceFile := flags.String("trace", "", "write trace to file")
|
||||||
|
|
||||||
flags.Var(&rootPrefix{}, "P", "path prefix within the zip at which to place files")
|
flags.Var(&rootPrefix{}, "P", "path prefix within the zip at which to place files")
|
||||||
flags.Var(&listFiles{}, "l", "file containing list of .class files")
|
flags.Var(&listFiles{}, "l", "file containing list of files to zip")
|
||||||
|
flags.Var(&rspFiles{}, "r", "file containing list of files to zip with Ninja rsp file escaping")
|
||||||
flags.Var(&dir{}, "D", "directory to include in zip")
|
flags.Var(&dir{}, "D", "directory to include in zip")
|
||||||
flags.Var(&file{}, "f", "file to include in zip")
|
flags.Var(&file{}, "f", "file to include in zip")
|
||||||
flags.Var(&nonDeflatedFiles, "s", "file path to be stored within the zip without compression")
|
flags.Var(&nonDeflatedFiles, "s", "file path to be stored within the zip without compression")
|
||||||
|
24
zip/zip.go
24
zip/zip.go
@@ -150,6 +150,30 @@ func (b *FileArgsBuilder) List(name string) *FileArgsBuilder {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *FileArgsBuilder) RspFile(name string) *FileArgsBuilder {
|
||||||
|
if b.err != nil {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := b.fs.Open(name)
|
||||||
|
if err != nil {
|
||||||
|
b.err = err
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
list, err := ioutil.ReadAll(f)
|
||||||
|
if err != nil {
|
||||||
|
b.err = err
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
arg := b.state
|
||||||
|
arg.SourceFiles = ReadRespFile(list)
|
||||||
|
b.fileArgs = append(b.fileArgs, arg)
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
func (b *FileArgsBuilder) Error() error {
|
func (b *FileArgsBuilder) Error() error {
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@@ -49,6 +49,9 @@ var mockFs = pathtools.MockFs(map[string][]byte{
|
|||||||
"l_nl": []byte("a/a/a\na/a/b\nc\n"),
|
"l_nl": []byte("a/a/a\na/a/b\nc\n"),
|
||||||
"l_sp": []byte("a/a/a a/a/b c"),
|
"l_sp": []byte("a/a/a a/a/b c"),
|
||||||
"l2": []byte("missing\n"),
|
"l2": []byte("missing\n"),
|
||||||
|
"rsp": []byte("'a/a/a'\na/a/b\n'@'\n'foo'\\''bar'"),
|
||||||
|
"@ -> c": nil,
|
||||||
|
"foo'bar -> c": nil,
|
||||||
"manifest.txt": fileCustomManifest,
|
"manifest.txt": fileCustomManifest,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -246,6 +249,19 @@ func TestZip(t *testing.T) {
|
|||||||
fh("c", fileC, zip.Deflate),
|
fh("c", fileC, zip.Deflate),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "rsp",
|
||||||
|
args: fileArgsBuilder().
|
||||||
|
RspFile("rsp"),
|
||||||
|
compressionLevel: 9,
|
||||||
|
|
||||||
|
files: []zip.FileHeader{
|
||||||
|
fh("a/a/a", fileA, zip.Deflate),
|
||||||
|
fh("a/a/b", fileB, zip.Deflate),
|
||||||
|
fh("@", fileC, zip.Deflate),
|
||||||
|
fh("foo'bar", fileC, zip.Deflate),
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "prefix in zip",
|
name: "prefix in zip",
|
||||||
args: fileArgsBuilder().
|
args: fileArgsBuilder().
|
||||||
@@ -568,6 +584,11 @@ func TestReadRespFile(t *testing.T) {
|
|||||||
in: `./cmd "\""-C`,
|
in: `./cmd "\""-C`,
|
||||||
out: []string{"./cmd", `"-C`},
|
out: []string{"./cmd", `"-C`},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "ninja rsp file",
|
||||||
|
in: "'a'\nb\n'@'\n'foo'\\''bar'\n'foo\"bar'",
|
||||||
|
out: []string{"a", "b", "@", "foo'bar", `foo"bar`},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
|
Reference in New Issue
Block a user