aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Mortimer <sam@mortimer.me.uk>2018-09-18 13:41:03 -0700
committerRashed Abdel-Tawab <rashed@linux.com>2019-09-07 14:54:28 -0700
commitad4e97edb4ea4917247fb11c45c6441735a2b445 (patch)
tree88e2ddb78be57964123dbae9654cca4a802952ee
parentc5a265e2c2b0d3c0266c0596bfb8faf24b6f05db (diff)
downloadbuild_soong-ad4e97edb4ea4917247fb11c45c6441735a2b445.tar.gz
build_soong-ad4e97edb4ea4917247fb11c45c6441735a2b445.tar.bz2
build_soong-ad4e97edb4ea4917247fb11c45c6441735a2b445.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
-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 {