aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-11 11:56:50 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-11 11:59:19 +0900
commit0daac1fbbb82ced82786bbdee2e716a38a16762b (patch)
tree93b9ad0c61a91fd679906d9bdcc1314d132195c6
parentb6ad7da06edc1b6c9c76f12dc2896a3458f9edd5 (diff)
downloadandroid_build_kati-0daac1fbbb82ced82786bbdee2e716a38a16762b.tar.gz
android_build_kati-0daac1fbbb82ced82786bbdee2e716a38a16762b.tar.bz2
android_build_kati-0daac1fbbb82ced82786bbdee2e716a38a16762b.zip
add -find_cache_prunes
specify prune directories, space spapated. imply -use_find_cache true if -find_cache_prunes given. e.g. kati -find_cache_prunes=".repo .git"
-rw-r--r--func.go6
-rw-r--r--main.go8
-rw-r--r--pathutil.go17
3 files changed, 24 insertions, 7 deletions
diff --git a/func.go b/func.go
index a0d743b..3a944d5 100644
--- a/func.go
+++ b/func.go
@@ -771,14 +771,14 @@ func (f *funcShell) Compact() Value {
}
}
if dir, ok := matchAndroidFindFileInDir(expr); ok {
- androidFindCache.init()
+ androidFindCache.init(nil)
return &funcShellAndroidFindFileInDir{
funcShell: f,
dir: dir,
}
}
if chdir, roots, ok := matchAndroidFindJavaInDir(expr); ok {
- androidFindCache.init()
+ androidFindCache.init(nil)
return &funcShellAndroidFindJavaInDir{
funcShell: f,
chdir: chdir,
@@ -786,7 +786,7 @@ func (f *funcShell) Compact() Value {
}
}
if dir, ok := matchAndroidFindJavaResourceFileGroup(expr); ok {
- androidFindCache.init()
+ androidFindCache.init(nil)
return &funcShellAndroidFindJavaResourceFileGroup{
funcShell: f,
dir: dir,
diff --git a/main.go b/main.go
index b7c35e4..ad01f8a 100644
--- a/main.go
+++ b/main.go
@@ -50,6 +50,7 @@ var (
useParaFlag bool
useCache bool
useFindCache bool
+ findCachePrunes string
useWildcardCache bool
generateNinja bool
ignoreOptionalInclude string
@@ -93,6 +94,8 @@ func parseFlags() {
// TODO: Make this default.
flag.BoolVar(&useCache, "use_cache", false, "Use cache.")
flag.BoolVar(&useFindCache, "use_find_cache", false, "Use find cache.")
+ flag.StringVar(&findCachePrunes, "find_cache_prunes", "",
+ "space separated prune directories for find cache.")
flag.BoolVar(&useWildcardCache, "use_wildcard_cache", true, "Use wildcard cache.")
flag.BoolVar(&generateNinja, "ninja", false, "Generate build.ninja.")
flag.StringVar(&ignoreOptionalInclude, "ignore_optional_include", "", "If specified, skip reading -include directives start with the specified path.")
@@ -306,6 +309,11 @@ func main() {
}()
}
+ if findCachePrunes != "" {
+ useFindCache = true
+ androidFindCache.init(strings.Fields(findCachePrunes))
+ }
+
clvars, targets := parseCommandLine()
InitMakefileCache()
diff --git a/pathutil.go b/pathutil.go
index 00162b5..31a9e55 100644
--- a/pathutil.go
+++ b/pathutil.go
@@ -98,14 +98,15 @@ func (c *androidFindCacheT) ready() bool {
return c.ok
}
-func (c *androidFindCacheT) init() {
+func (c *androidFindCacheT) init(prunes []string) {
c.once.Do(func() {
c.mu.Lock()
- go c.start()
+ go c.start(prunes)
})
}
-func (c *androidFindCacheT) start() {
+func (c *androidFindCacheT) start(prunes []string) {
+ Logf("find cache init: %q", prunes)
defer c.mu.Unlock()
t := time.Now()
defer func() {
@@ -114,13 +115,21 @@ func (c *androidFindCacheT) start() {
}()
err := filepath.Walk(".", func(path string, info os.FileInfo, err error) error {
+ if info.IsDir() {
+ for _, prune := range prunes {
+ if info.Name() == prune {
+ Logf("find cache prune: %s", path)
+ return filepath.SkipDir
+ }
+ }
+ }
c.files = append(c.files, fileInfo{
path: strings.TrimPrefix(path, "./"),
mode: info.Mode(),
})
return nil
})
- if err != nil {
+ if err != nil && err != filepath.SkipDir {
Logf("error in adnroid find cache: %v", err)
c.ok = false
return