Merge "Ignore bazel-generated paths in dangling rule test"
This commit is contained in:
@@ -896,6 +896,10 @@ func (c *configImpl) BazelOutDir() string {
|
|||||||
return filepath.Join(c.OutDir(), "bazel")
|
return filepath.Join(c.OutDir(), "bazel")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) bazelOutputBase() string {
|
||||||
|
return filepath.Join(c.BazelOutDir(), "output")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) SoongOutDir() string {
|
func (c *configImpl) SoongOutDir() string {
|
||||||
return filepath.Join(c.OutDir(), "soong")
|
return filepath.Join(c.OutDir(), "soong")
|
||||||
}
|
}
|
||||||
|
@@ -418,7 +418,7 @@ func runSoong(ctx Context, config Config) {
|
|||||||
// Bazel's HOME var is set to an output subdirectory which doesn't exist. This
|
// Bazel's HOME var is set to an output subdirectory which doesn't exist. This
|
||||||
// prevents Bazel from file I/O in the actual user HOME directory.
|
// prevents Bazel from file I/O in the actual user HOME directory.
|
||||||
soongBuildEnv.Set("BAZEL_HOME", absPath(ctx, filepath.Join(config.BazelOutDir(), "bazelhome")))
|
soongBuildEnv.Set("BAZEL_HOME", absPath(ctx, filepath.Join(config.BazelOutDir(), "bazelhome")))
|
||||||
soongBuildEnv.Set("BAZEL_OUTPUT_BASE", filepath.Join(config.BazelOutDir(), "output"))
|
soongBuildEnv.Set("BAZEL_OUTPUT_BASE", config.bazelOutputBase())
|
||||||
soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, "."))
|
soongBuildEnv.Set("BAZEL_WORKSPACE", absPath(ctx, "."))
|
||||||
soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())
|
soongBuildEnv.Set("BAZEL_METRICS_DIR", config.BazelMetricsDir())
|
||||||
soongBuildEnv.Set("LOG_DIR", config.LogsDir())
|
soongBuildEnv.Set("LOG_DIR", config.LogsDir())
|
||||||
|
@@ -18,14 +18,44 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"android/soong/ui/metrics"
|
"android/soong/ui/metrics"
|
||||||
"android/soong/ui/status"
|
"android/soong/ui/status"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// bazel output paths are in __main__/bazel-out/<config-specific-path>/bin
|
||||||
|
bazelOutputPathRegexOnce sync.Once
|
||||||
|
bazelOutputPathRegexp *regexp.Regexp
|
||||||
|
)
|
||||||
|
|
||||||
|
func bazelOutputPathPattern(config Config) *regexp.Regexp {
|
||||||
|
bazelOutputPathRegexOnce.Do(func() {
|
||||||
|
// Bazel output files are in <Bazel output base>/execroot/__main__/bazel-out/<config>/bin
|
||||||
|
bazelOutRoot := filepath.Join(regexp.QuoteMeta(config.bazelOutputBase()), "execroot", "__main__", "bazel-out")
|
||||||
|
bazelOutputPathRegexp = regexp.MustCompile(bazelOutRoot + "/[^/]+/bin")
|
||||||
|
})
|
||||||
|
return bazelOutputPathRegexp
|
||||||
|
}
|
||||||
|
|
||||||
|
func ignoreBazelPath(config Config, path string) bool {
|
||||||
|
bazelRoot := filepath.Join(config.bazelOutputBase(), "execroot")
|
||||||
|
// Don't check bazel output regexp unless it is Bazel path
|
||||||
|
if strings.HasPrefix(path, bazelRoot) {
|
||||||
|
bazelOutputRegexp := bazelOutputPathPattern(config)
|
||||||
|
// if the file is a bazel path that is _not_ a Bazel generated file output, we rely on Bazel to
|
||||||
|
// ensure the paths to exist. If it _is_ a Bazel output path, we expect that it should be built
|
||||||
|
// by Ninja.
|
||||||
|
return !bazelOutputRegexp.MatchString(path)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Checks for files in the out directory that have a rule that depends on them but no rule to
|
// Checks for files in the out directory that have a rule that depends on them but no rule to
|
||||||
// create them. This catches a common set of build failures where a rule to generate a file is
|
// create them. This catches a common set of build failures where a rule to generate a file is
|
||||||
// deleted (either by deleting a module in an Android.mk file, or by modifying the build system
|
// deleted (either by deleting a module in an Android.mk file, or by modifying the build system
|
||||||
@@ -97,6 +127,10 @@ func testForDanglingRules(ctx Context, config Config) {
|
|||||||
// full build rules in the primary build.ninja file.
|
// full build rules in the primary build.ninja file.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ignoreBazelPath(config, line) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
danglingRules[line] = true
|
danglingRules[line] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user