Merge "Add flag to skip writing output from soong_zip." into main
This commit is contained in:
@@ -173,6 +173,7 @@ func main() {
|
|||||||
cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file")
|
cpuProfile := flags.String("cpuprofile", "", "write cpu profile to file")
|
||||||
traceFile := flags.String("trace", "", "write trace to file")
|
traceFile := flags.String("trace", "", "write trace to file")
|
||||||
sha256Checksum := flags.Bool("sha256", false, "add a zip header to each file containing its SHA256 digest")
|
sha256Checksum := flags.Bool("sha256", false, "add a zip header to each file containing its SHA256 digest")
|
||||||
|
doNotWrite := flags.Bool("n", false, "Nothing is written to disk -- all other work happens")
|
||||||
|
|
||||||
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 files to zip")
|
flags.Var(&listFiles{}, "l", "file containing list of files to zip")
|
||||||
@@ -236,6 +237,7 @@ func main() {
|
|||||||
StoreSymlinks: *symlinks,
|
StoreSymlinks: *symlinks,
|
||||||
IgnoreMissingFiles: *ignoreMissingFiles,
|
IgnoreMissingFiles: *ignoreMissingFiles,
|
||||||
Sha256Checksum: *sha256Checksum,
|
Sha256Checksum: *sha256Checksum,
|
||||||
|
DoNotWrite: *doNotWrite,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, "error:", err.Error())
|
fmt.Fprintln(os.Stderr, "error:", err.Error())
|
||||||
|
@@ -282,6 +282,7 @@ type ZipArgs struct {
|
|||||||
StoreSymlinks bool
|
StoreSymlinks bool
|
||||||
IgnoreMissingFiles bool
|
IgnoreMissingFiles bool
|
||||||
Sha256Checksum bool
|
Sha256Checksum bool
|
||||||
|
DoNotWrite bool
|
||||||
|
|
||||||
Stderr io.Writer
|
Stderr io.Writer
|
||||||
Filesystem pathtools.FileSystem
|
Filesystem pathtools.FileSystem
|
||||||
@@ -400,7 +401,9 @@ func Zip(args ZipArgs) error {
|
|||||||
|
|
||||||
var zipErr error
|
var zipErr error
|
||||||
|
|
||||||
if !args.WriteIfChanged {
|
if args.DoNotWrite {
|
||||||
|
out = io.Discard
|
||||||
|
} else if !args.WriteIfChanged {
|
||||||
f, err := os.Create(args.OutputFilePath)
|
f, err := os.Create(args.OutputFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -421,7 +424,7 @@ func Zip(args ZipArgs) error {
|
|||||||
return zipErr
|
return zipErr
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.WriteIfChanged {
|
if args.WriteIfChanged && !args.DoNotWrite {
|
||||||
err := pathtools.WriteFileIfChanged(args.OutputFilePath, buf.Bytes(), 0666)
|
err := pathtools.WriteFileIfChanged(args.OutputFilePath, buf.Bytes(), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user