aboutsummaryrefslogtreecommitdiffstats
path: root/serialize.go
diff options
context:
space:
mode:
authorShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-05-25 18:21:23 +0900
committerShinichiro Hamaji <shinichiro.hamaji@gmail.com>2015-05-25 18:29:36 +0900
commit45cde1dc5fa3e4126fc7e70926efe57b69b11446 (patch)
tree3d796271b90a35ff0094e9385fc7c306b48a1e60 /serialize.go
parent71fae4cd971ca9a0964b7ec5669b142dd1e2625b (diff)
downloadandroid_build_kati-45cde1dc5fa3e4126fc7e70926efe57b69b11446.tar.gz
android_build_kati-45cde1dc5fa3e4126fc7e70926efe57b69b11446.tar.bz2
android_build_kati-45cde1dc5fa3e4126fc7e70926efe57b69b11446.zip
Handle cache based on their contents instead of timestamps
Diffstat (limited to 'serialize.go')
-rw-r--r--serialize.go32
1 files changed, 15 insertions, 17 deletions
diff --git a/serialize.go b/serialize.go
index f8f509d..4c5c8ef 100644
--- a/serialize.go
+++ b/serialize.go
@@ -94,7 +94,7 @@ type SerializableGraph struct {
Tsvs []SerializableTargetSpecificVar
Targets []string
Roots []string
- ReadMks []ReadMakefile
+ ReadMks []*ReadMakefile
}
func encGob(v interface{}) string {
@@ -265,7 +265,7 @@ func DumpDepGraphCache(g *DepGraph, roots []string) {
cacheFile := GetCacheFilename(g.readMks[0].Filename, roots)
for _, mk := range g.readMks {
// Inconsistent, do not dump this result.
- if mk.Timestamp == -2 {
+ if mk.State == 2 {
if exists(cacheFile) {
os.Remove(cacheFile)
}
@@ -568,22 +568,20 @@ func LoadDepGraphCache(makefile string, roots []string) *DepGraph {
g := LoadDepGraph(filename)
for _, mk := range g.readMks {
- // TODO: A hack for Android build. Maybe we should
- // keep their contents instead of the timestamp.
- if mk.Filename == "out/target/product/generic/clean_steps.mk" ||
- mk.Filename == "out/target/common/obj/previous_aidl_config.mk" ||
- mk.Filename == "out/target/product/generic/previous_build_config.mk" {
- continue
- }
-
- ts := getTimestamp(mk.Filename)
- if mk.Timestamp >= 0 && ts < 0 {
- LogAlways("Cache expired: %s", mk.Filename)
- return nil
+ if mk.State != FILE_EXISTS && mk.State != FILE_NOT_EXISTS {
+ panic(fmt.Sprintf("Internal error: broken state: %d", mk.State))
}
- if mk.Timestamp <= ts {
- LogAlways("Cache expired: %s", mk.Filename)
- return nil
+ if mk.State == FILE_NOT_EXISTS {
+ if exists(mk.Filename) {
+ LogAlways("Cache expired: %s", mk.Filename)
+ return nil
+ }
+ } else {
+ c, err := readFile(mk.Filename)
+ if err != nil || !bytes.Equal(c, mk.Content) {
+ LogAlways("Cache expired: %s", mk.Filename)
+ return nil
+ }
}
}
g.isCached = true