Merge "Conditionally apply rustdoc flags to third party crates"

This commit is contained in:
Christian Wailes
2021-08-03 19:39:17 +00:00
committed by Gerrit Code Review
4 changed files with 33 additions and 27 deletions

View File

@@ -20,6 +20,7 @@ import (
"os"
"path/filepath"
"reflect"
"regexp"
"sort"
"strings"
@@ -2094,3 +2095,25 @@ func PathsIfNonNil(paths ...Path) Paths {
}
return ret
}
var thirdPartyDirPrefixExceptions = []*regexp.Regexp{
regexp.MustCompile("^vendor/[^/]*google[^/]*/"),
regexp.MustCompile("^hardware/google/"),
regexp.MustCompile("^hardware/interfaces/"),
regexp.MustCompile("^hardware/libhardware[^/]*/"),
regexp.MustCompile("^hardware/ril/"),
}
func IsThirdPartyPath(path string) bool {
thirdPartyDirPrefixes := []string{"external/", "vendor/", "hardware/"}
if HasAnyPrefix(path, thirdPartyDirPrefixes) {
for _, prefix := range thirdPartyDirPrefixExceptions {
if prefix.MatchString(path) {
return false
}
}
return true
}
return false
}