Make the bazel sandwich ignore targets that don't exist
So that things can be allowlisted that aren't in all branches, or that aren't present in tests. Then remove the example partition from the soong integration tests so that we don't need to pull all of the tools needed to build partitions into that test. Bug: 265127181 Fixes: 294220392 Test: ./build/soong/tests/run_integration_tests.sh and m bazel_sandwich Change-Id: I66fb1ad1c2eee815bfb9700595a26e74e54c6214
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -1054,9 +1055,23 @@ var (
|
||||
|
||||
func GetBazelSandwichCqueryRequests(config Config) ([]cqueryKey, error) {
|
||||
result := make([]cqueryKey, 0, len(allowlists.BazelSandwichTargets))
|
||||
labelRegex := regexp.MustCompile("^@?//([a-zA-Z0-9/_-]+):[a-zA-Z0-9_-]+$")
|
||||
// Note that bazel "targets" are different from soong "targets", the bazel targets are
|
||||
// synonymous with soong modules, and soong targets are a configuration a module is built in.
|
||||
for _, target := range allowlists.BazelSandwichTargets {
|
||||
match := labelRegex.FindStringSubmatch(target.Label)
|
||||
if match == nil {
|
||||
return nil, fmt.Errorf("invalid label, must match `^@?//([a-zA-Z0-9/_-]+):[a-zA-Z0-9_-]+$`: %s", target.Label)
|
||||
}
|
||||
if _, err := os.Stat(absolutePath(match[1])); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Ignore bazel sandwich targets that don't exist.
|
||||
continue
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
var soongTarget Target
|
||||
if target.Host {
|
||||
soongTarget = config.BuildOSTarget
|
||||
|
Reference in New Issue
Block a user