aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2019-03-29 13:54:39 -0700
committerColin Cross <ccross@android.com>2019-04-01 10:43:20 -0700
commitd1c1e6fd6c55f88e1d8322f9db9f99d9a3747ba8 (patch)
tree9cb5055b6e9867120505d8986b4b65dc16c88438 /cmd
parent65c95ff1fb3e50927f49e0e95c1f980af850f034 (diff)
downloadbuild_soong-d1c1e6fd6c55f88e1d8322f9db9f99d9a3747ba8.tar.gz
build_soong-d1c1e6fd6c55f88e1d8322f9db9f99d9a3747ba8.tar.bz2
build_soong-d1c1e6fd6c55f88e1d8322f9db9f99d9a3747ba8.zip
Touch output files in sbox
Some tools used by genrules set the timestamp of the generated file to an old value. For example, when using tar to extract files it will set the timestamp of the extracted file to the value stored in the tar file. This can cause unnecessary rebuilds due to output files that are older than their inputs. Touch output files in sbox before moving them into the output location. Test: m checkbuild && m checkbuild Change-Id: Idb0e71d2bf0ac3618338371132cc71be74bf9d9d
Diffstat (limited to 'cmd')
-rw-r--r--cmd/sbox/sbox.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/cmd/sbox/sbox.go b/cmd/sbox/sbox.go
index 0af18863..4167edb3 100644
--- a/cmd/sbox/sbox.go
+++ b/cmd/sbox/sbox.go
@@ -24,6 +24,7 @@ import (
"path"
"path/filepath"
"strings"
+ "time"
)
var (
@@ -265,6 +266,15 @@ func run() error {
if err != nil {
return err
}
+
+ // Update the timestamp of the output file in case the tool wrote an old timestamp (for example, tar can extract
+ // files with old timestamps).
+ now := time.Now()
+ err = os.Chtimes(tempPath, now, now)
+ if err != nil {
+ return err
+ }
+
err = os.Rename(tempPath, destPath)
if err != nil {
return err