diff options
| author | Colin Cross <ccross@android.com> | 2017-12-07 22:02:40 -0800 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2017-12-08 10:12:42 -0800 |
| commit | 741e14ebb944f9349346f2259fb539b631c69676 (patch) | |
| tree | bf98a223236d54e5b6e52c3699cf8e91b9e077eb /glob.go | |
| parent | 7a88d0db4d06b39809e6915f27063bd704a948e7 (diff) | |
| download | platform_build_blueprint-741e14ebb944f9349346f2259fb539b631c69676.tar.gz platform_build_blueprint-741e14ebb944f9349346f2259fb539b631c69676.tar.bz2 platform_build_blueprint-741e14ebb944f9349346f2259fb539b631c69676.zip | |
Limit length of glob result file names
Glob names were appending every excluded file, which could result
in too many / characters for ninja to handle. Use a hash if the
result contains too many / characters.
Change-Id: I88920f0596df49639a6c2b4f8af47ea8fdc1ee5a
Diffstat (limited to 'glob.go')
| -rw-r--r-- | glob.go | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -15,9 +15,11 @@ package blueprint import ( + "crypto/md5" "fmt" "reflect" "sort" + "strings" ) type GlobPath struct { @@ -106,9 +108,16 @@ func globToString(pattern string) string { } func globToFileName(pattern string, excludes []string) string { - ret := globToString(pattern) + name := globToString(pattern) + excludeName := "" for _, e := range excludes { - ret += "__" + globToString(e) + excludeName += "__" + globToString(e) } - return ret + ".glob" + + // Prevent file names from reaching ninja's path component limit + if strings.Count(name, "/")+strings.Count(excludeName, "/") > 30 { + excludeName = fmt.Sprintf("___%x", md5.Sum([]byte(excludeName))) + } + + return name + excludeName + ".glob" } |
