aboutsummaryrefslogtreecommitdiffstats
path: root/func.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-09 15:34:26 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-09 15:38:34 +0900
commit7adc0f5392b543e892c5623c33f36071f10b56a7 (patch)
treec832dd24f56d0b34f1e7628f0532384fb4f517c0 /func.go
parent1a77c8cbba2405cbaee852644a16670c99009b57 (diff)
downloadandroid_build_kati-7adc0f5392b543e892c5623c33f36071f10b56a7.tar.gz
android_build_kati-7adc0f5392b543e892c5623c33f36071f10b56a7.tar.bz2
android_build_kati-7adc0f5392b543e892c5623c33f36071f10b56a7.zip
use_find_cache: add another pattern
in repo/android/build/core/base_rules.mk java_resource_file_groups+= ... cd ${TOP_DIR}${LOCAL_PATH}/${dir} && find . -type d -a -name ".svn" -prune \ -o -type f -a \! -name "*.java" -a \! -name "package.html" -a \! \ -name "overview.html" -a \! -name ".*.swp" -a \! -name ".DS_Store" \ -a \! -name "*~" -print ) refactor androidFindCache. add walk method. % time ./repo/android.sh kati -c > /dev/null find: `dummy': No such file or directory find: `dummy': No such file or directory fatal: Not a git repository: 'packages/apps/Camera2/.git' ./repo/android.sh kati -c > /dev/null 32.38s user 41.67s system 130% cpu 56.897 total % time ./repo/android.sh kati -c -use_find_cache > /dev/null fatal: Not a git repository: 'packages/apps/Camera2/.git' ./repo/android.sh kati -c -use_find_cache > /dev/null 33.26s user 18.88s system 153% cpu 33.974 total
Diffstat (limited to 'func.go')
-rw-r--r--func.go76
1 files changed, 72 insertions, 4 deletions
diff --git a/func.go b/func.go
index 93f9f31..6484ead 100644
--- a/func.go
+++ b/func.go
@@ -765,10 +765,19 @@ func (f *funcShell) Compact() Value {
roots: roots,
}
}
+ if dir, ok := matchAndroidFindJavaResourceFileGroup(expr); ok {
+ androidFindCache.init()
+ return &funcShellAndroidFindJavaResourceFileGroup{
+ funcShell: f,
+ dir: dir,
+ }
+ }
+ Logf("shell compact no match: %s", expr)
return f
}
-// pattern:
+// pattern in repo/android/build/core/definitions.mk
+// find-subdir-assets
// if [ -d $1 ] ; then cd $1 ; find ./ -not -name '.*' -and -type f -and -not -type l ; fi
func matchAndroidFindFileInDir(expr Expr) (Value, bool) {
// literal: "if [ -d "
@@ -822,7 +831,8 @@ func (f *funcShellAndroidFindFileInDir) Eval(w io.Writer, ev *Evaluator) {
androidFindCache.findInDir(&sw, dir)
}
-// pattern:
+// pattern in repo/android/build/core/definitions.mk
+// all-java-files-under
// cd ${LOCAL_PATH} ; find -L $1 -name "*.java" -and -not -name ".*"
func matchAndroidFindJavaInDir(expr Expr) (Value, Value, bool) {
// literal: "cd "
@@ -897,12 +907,70 @@ func (f *funcShellAndroidFindJavaInDir) Eval(w io.Writer, ev *Evaluator) {
freeBuf(buf)
}
-// TODO(ukai): pattern:
-//
+// pattern: in repo/android/build/core/base_rules.mk
+// java_resource_file_groups+= ...
// cd ${TOP_DIR}${LOCAL_PATH}/${dir} && find . -type d -a -name ".svn" -prune \
// -o -type f -a \! -name "*.java" -a \! -name "package.html" -a \! \
// -name "overview.html" -a \! -name ".*.swp" -a \! -name ".DS_Store" \
// -a \! -name "*~" -print )
+func matchAndroidFindJavaResourceFileGroup(expr Expr) (Value, bool) {
+ // literal: "cd "
+ // varref: TOP_DIR
+ // varref: LOCAL_PATH
+ // literal: "/"
+ // varref: dir
+ // literal: " && find . -type d -a name ".svn" -prune -o .."
+ if len(expr) != 6 {
+ return nil, false
+ }
+ if expr[0] != literal("cd ") {
+ return nil, false
+ }
+ if _, ok := expr[1].(varref); !ok {
+ return nil, false
+ }
+ if _, ok := expr[2].(varref); !ok {
+ return nil, false
+ }
+ if expr[3] != literal("/") {
+ return nil, false
+ }
+ if _, ok := expr[4].(varref); !ok {
+ return nil, false
+ }
+ if expr[5] != literal(` && find . -type d -a -name ".svn" -prune -o -type f -a \! -name "*.java" -a \! -name "package.html" -a \! -name "overview.html" -a \! -name ".*.swp" -a \! -name ".DS_Store" -a \! -name "*~" -print `) {
+ Logf("shell compact mismatch: expr[5]=%q", expr[5])
+ return nil, false
+ }
+ return expr[1:5], true
+}
+
+type funcShellAndroidFindJavaResourceFileGroup struct {
+ *funcShell
+ dir Value
+}
+
+func (f *funcShellAndroidFindJavaResourceFileGroup) Eval(w io.Writer, ev *Evaluator) {
+ abuf := newBuf()
+ fargs := ev.args(abuf, f.dir)
+ dir := string(trimSpaceBytes(fargs[0]))
+ freeBuf(abuf)
+ Logf("shellAndroidFindJavaResourceFileGroup %s => %s", f.dir.String(), dir)
+ if strings.Contains(dir, "..") {
+ Logf("shellAndroidFindJavaResourceFileGroup contains ..: call original shell")
+ f.funcShell.Eval(w, ev)
+ return
+ }
+ if !androidFindCache.ready() {
+ Logf("shellAndroidFindJavaResourceFileGroup androidFindCache is not ready: call original shell")
+ f.funcShell.Eval(w, ev)
+ return
+ }
+ sw := ssvWriter{w: w}
+ androidFindCache.findJavaResourceFileGroup(&sw, dir)
+}
+
+// TODO(ukai): pattern:
//
// echo $1 | tr 'a-zA-Z' 'n-za-mN-ZA-M'