aboutsummaryrefslogtreecommitdiffstats
path: root/pathutil.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-09 12:56:22 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-09 13:01:04 +0900
commit1a77c8cbba2405cbaee852644a16670c99009b57 (patch)
treec12c949070e623892a00a2bfa26661363f17962b /pathutil.go
parent106fb791bfc5b3bcb3f75ac43ae3b94b44ada67f (diff)
downloadandroid_build_kati-1a77c8cbba2405cbaee852644a16670c99009b57.tar.gz
android_build_kati-1a77c8cbba2405cbaee852644a16670c99009b57.tar.bz2
android_build_kati-1a77c8cbba2405cbaee852644a16670c99009b57.zip
use_find_cache: add another pattern
cd ${LOCAL_PATH} ; find -L $1 -name "*.java" -and -not -name ".*" fix a bug to scan find cache dir dir-x dir/foo find from dir should detect dir and dir/foo and should not stop at dir-x. % 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 35.43s user 44.23s system 132% cpu 1:00.14 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 32.02s user 17.76s system 146% cpu 33.947 total
Diffstat (limited to 'pathutil.go')
-rw-r--r--pathutil.go65
1 files changed, 60 insertions, 5 deletions
diff --git a/pathutil.go b/pathutil.go
index a60668e..4a9113c 100644
--- a/pathutil.go
+++ b/pathutil.go
@@ -130,11 +130,16 @@ func (c *androidFindCacheT) findInDir(sw *ssvWriter, dir string) {
i := sort.Search(len(c.files), func(i int) bool {
return c.files[i].path >= dir
})
- Logf("android find cache in dir: %s i=%d/%d", dir, i, len(c.files))
+ Logf("android find in dir cache: %s i=%d/%d", dir, i, len(c.files))
for ; i < len(c.files); i++ {
- if c.files[i].path != dir && !strings.HasPrefix(c.files[i].path, dir+"/") {
- Logf("android find cache in dir: %s different prefix: %s", dir, c.files[i].path)
- break
+ if c.files[i].path != dir {
+ if !strings.HasPrefix(c.files[i].path, dir) {
+ Logf("android find in dir cache: %s different prefix at %d: %s", dir, i, c.files[i].path)
+ break
+ }
+ if !strings.HasPrefix(c.files[i].path, dir+"/") {
+ continue
+ }
}
// -not -name '.*'
if strings.HasPrefix(filepath.Base(c.files[i].path), ".") {
@@ -148,6 +153,56 @@ func (c *androidFindCacheT) findInDir(sw *ssvWriter, dir string) {
name := strings.TrimPrefix(c.files[i].path, dir+"/")
name = "./" + name
sw.WriteString(name)
- Logf("android find cache in dir: %s=> %s", dir, name)
+ Logf("android find in dir cache: %s=> %s", dir, name)
+ }
+}
+
+// cd ${LOCAL_PATH} ; find -L $1 -name "*.java" -and -not -name ".*"
+// returns false if symlink is found.
+func (c *androidFindCacheT) findJavaInDir(sw *ssvWriter, chdir string, root string) bool {
+ chdir = strings.TrimPrefix(chdir, "./")
+ dir := filepath.Join(chdir, root)
+ i := sort.Search(len(c.files), func(i int) bool {
+ return c.files[i].path >= dir
+ })
+ Logf("android find java in dir cache: %s i=%d/%d", dir, i, len(c.files))
+ start := i
+ end := len(c.files)
+ // check symlinks
+ for ; i < len(c.files); i++ {
+ if c.files[i].path != dir {
+ if !strings.HasPrefix(c.files[i].path, dir) {
+ Logf("android find in dir cache: %s different prefix at %d: %s", dir, i, c.files[i].path)
+ end = i
+ break
+ }
+ if !strings.HasPrefix(c.files[i].path, dir+"/") {
+ continue
+ }
+ }
+ if c.files[i].mode&os.ModeSymlink == os.ModeSymlink {
+ Logf("android find java in dir cache: detect symlink %s %v", c.files[i].path, c.files[i].mode)
+ return false
+ }
+ }
+
+ // no symlinks
+ for i := start; i < end; i++ {
+ if c.files[i].path != dir && !strings.HasPrefix(c.files[i].path, dir+"/") {
+ continue
+ }
+ base := filepath.Base(c.files[i].path)
+ // -name "*.java"
+ if filepath.Ext(base) != ".java" {
+ continue
+ }
+ // -not -name ".*"
+ if strings.HasPrefix(base, ".") {
+ continue
+ }
+ name := strings.TrimPrefix(c.files[i].path, chdir+"/")
+ sw.WriteString(name)
+ Logf("android find java in dir cache: %s=> %s", dir, name)
}
+ return true
}