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
This commit is contained in:
parent
7a88d0db4d
commit
741e14ebb9
1 changed files with 12 additions and 3 deletions
15
glob.go
15
glob.go
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue