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
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -265,6 +266,15 @@ func run() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
err = os.Rename(tempPath, destPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user