diff options
author | Nan Zhang <nanzhang@google.com> | 2018-02-14 13:27:26 -0800 |
---|---|---|
committer | Nan Zhang <nanzhang@google.com> | 2018-02-15 11:45:53 -0800 |
commit | 2e6a4ff3beaff084082a054c668ec5b6d29ffdf7 (patch) | |
tree | f2c460cd6009df52447cb7b9bd074eac1c5293ed /ui | |
parent | 4b5fe9d1b4c6e8491a0f793ad43710fef7b78b74 (diff) | |
download | build_soong-2e6a4ff3beaff084082a054c668ec5b6d29ffdf7.tar.gz build_soong-2e6a4ff3beaff084082a054c668ec5b6d29ffdf7.tar.bz2 build_soong-2e6a4ff3beaff084082a054c668ec5b6d29ffdf7.zip |
Let Soong_UI to handle build_date.txt file
Soong_UI will update timestamp to build_date.txt, and export variables
to kati/ninja.
Test: m -j32
Bug: b/70351683
Change-Id: I153897afdf2d3f39a32d757d4c3ae7515caea52d
Diffstat (limited to 'ui')
-rw-r--r-- | ui/build/config.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ui/build/config.go b/ui/build/config.go index 363121f9..27ed8e9f 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -15,12 +15,14 @@ package build import ( + "io/ioutil" "log" "os" "path/filepath" "runtime" "strconv" "strings" + "time" "android/soong/shared" ) @@ -181,6 +183,20 @@ func NewConfig(ctx Context, args ...string) Config { ret.environ.Set("ANDROID_JAVA9_HOME", java9Home) ret.environ.Set("PATH", strings.Join(newPath, string(filepath.ListSeparator))) + outDir := ret.OutDir() + buildDateTimeFile := filepath.Join(outDir, "build_date.txt") + var content string + if buildDateTime, ok := ret.environ.Get("BUILD_DATETIME"); ok && buildDateTime != "" { + content = buildDateTime + } else { + content = strconv.FormatInt(time.Now().Unix(), 10) + } + err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777) + if err != nil { + ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err) + } + ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile) + return Config{ret} } |