aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorSam Mortimer <sam@mortimer.me.uk>2018-09-18 13:41:03 -0700
committerMichael Bestas <mkbestas@lineageos.org>2019-12-11 19:03:32 +0200
commit627fae94f946428bc406737aa37eadf16f7dd855 (patch)
tree9f91f31ac77531c6f7acdcd157f1a19cf0477964 /cmd
parent724cf3684b7fe1aec85b9ef0cb38611b1f2291df (diff)
downloadbuild_soong-627fae94f946428bc406737aa37eadf16f7dd855.tar.gz
build_soong-627fae94f946428bc406737aa37eadf16f7dd855.tar.bz2
build_soong-627fae94f946428bc406737aa37eadf16f7dd855.zip
soong sbox: Add option to allow copying all generated output
*) Add option --copy-all-files that copies all generated output. *) When enabled, do not error when unexpected output files are found. *) For use by lineage_generator module. Change-Id: Ia3cd2216807f6165b23a97a001db7303f15d33e2
Diffstat (limited to 'cmd')
-rw-r--r--cmd/sbox/sbox.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index 4167edb3..47e60b19 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -32,6 +32,7 @@ var (
rawCommand string
outputRoot string
keepOutDir bool
+ copyAllOutput bool
depfileOut string
)
@@ -44,6 +45,8 @@ func init() {
"root of directory to copy outputs into")
flag.BoolVar(&keepOutDir, "keep-out-dir", false,
"whether to keep the sandbox directory when done")
+ flag.BoolVar(&copyAllOutput, "copy-all-output", false,
+ "whether to copy all output files")
flag.StringVar(&depfileOut, "depfile-out", "",
"file path of the depfile to generate. This value will replace '__SBOX_DEPFILE__' in the command and will be treated as an output but won't be added to __SBOX_OUT_FILES__")
@@ -114,7 +117,7 @@ func run() error {
// the contents of the __SBOX_OUT_FILES__ variable
outputsVarEntries := flag.Args()
- if len(outputsVarEntries) == 0 {
+ if !copyAllOutput && len(outputsVarEntries) == 0 {
usageViolation("at least one output file must be given")
}
@@ -223,7 +226,7 @@ func run() error {
missingOutputErrors = append(missingOutputErrors, fmt.Sprintf("%s: not a file", filePath))
}
}
- if len(missingOutputErrors) > 0 {
+ if !copyAllOutput && len(missingOutputErrors) > 0 {
// find all created files for making a more informative error message
createdFiles := findAllFilesUnder(tempDir)
@@ -255,8 +258,14 @@ func run() error {
keepOutDir = true
return errors.New(errorMessage)
}
+ var filePathList []string
+ if copyAllOutput {
+ filePathList = findAllFilesUnder(tempDir)
+ } else {
+ filePathList = allOutputs
+ }
// the created files match the declared files; now move them
- for _, filePath := range allOutputs {
+ for _, filePath := range filePathList {
tempPath := filepath.Join(tempDir, filePath)
destPath := filePath
if len(outputRoot) != 0 {