Rename BuildDir and NinjaBuildDir.
These are just out/ and out/soong/ and the old names were quite confusing. Test: Presubmits. Merged-In: I999ca62162062f27e449f83ffb00fa580d4065b8 Merged-In: I2fcd80a9e376a6842a06aa104a9f6f5c5e16f8c7 Change-Id: Ib481d2aac40df8da1b74174dc8ec576c1cb48be0
This commit is contained in:
@@ -106,7 +106,7 @@ type bazelPaths struct {
|
||||
bazelPath string
|
||||
outputBase string
|
||||
workspaceDir string
|
||||
buildDir string
|
||||
soongOutDir string
|
||||
metricsDir string
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ func NewBazelContext(c *config) (BazelContext, error) {
|
||||
|
||||
func bazelPathsFromConfig(c *config) (*bazelPaths, error) {
|
||||
p := bazelPaths{
|
||||
buildDir: c.buildDir,
|
||||
soongOutDir: c.soongOutDir,
|
||||
}
|
||||
missingEnvVars := []string{}
|
||||
if len(c.Getenv("BAZEL_HOME")) > 1 {
|
||||
@@ -382,7 +382,7 @@ func (r *builtinBazelRunner) issueBazelCommand(paths *bazelPaths, runName bazel.
|
||||
bazelCmd.Env = append(os.Environ(),
|
||||
"HOME="+paths.homeDir,
|
||||
pwdPrefix(),
|
||||
"BUILD_DIR="+absolutePath(paths.buildDir),
|
||||
"BUILD_DIR="+absolutePath(paths.soongOutDir),
|
||||
// Make OUT_DIR absolute here so tools/bazel.sh uses the correct
|
||||
// OUT_DIR at <root>/out, instead of <root>/out/soong/workspace/out.
|
||||
"OUT_DIR="+absolutePath(paths.outDir()),
|
||||
@@ -599,24 +599,24 @@ def format(target):
|
||||
// Returns a path containing build-related metadata required for interfacing
|
||||
// with Bazel. Example: out/soong/bazel.
|
||||
func (p *bazelPaths) intermediatesDir() string {
|
||||
return filepath.Join(p.buildDir, "bazel")
|
||||
return filepath.Join(p.soongOutDir, "bazel")
|
||||
}
|
||||
|
||||
// Returns the path where the contents of the @soong_injection repository live.
|
||||
// It is used by Soong to tell Bazel things it cannot over the command line.
|
||||
func (p *bazelPaths) injectedFilesDir() string {
|
||||
return filepath.Join(p.buildDir, bazel.SoongInjectionDirName)
|
||||
return filepath.Join(p.soongOutDir, bazel.SoongInjectionDirName)
|
||||
}
|
||||
|
||||
// Returns the path of the synthetic Bazel workspace that contains a symlink
|
||||
// forest composed the whole source tree and BUILD files generated by bp2build.
|
||||
func (p *bazelPaths) syntheticWorkspaceDir() string {
|
||||
return filepath.Join(p.buildDir, "workspace")
|
||||
return filepath.Join(p.soongOutDir, "workspace")
|
||||
}
|
||||
|
||||
// Returns the path to the top level out dir ($OUT_DIR).
|
||||
func (p *bazelPaths) outDir() string {
|
||||
return filepath.Dir(p.buildDir)
|
||||
return filepath.Dir(p.soongOutDir)
|
||||
}
|
||||
|
||||
// Issues commands to Bazel to receive results for all cquery requests
|
||||
|
@@ -101,7 +101,7 @@ func TestInvokeBazelPopulatesBuildStatements(t *testing.T) {
|
||||
func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string) (*bazelContext, string) {
|
||||
t.Helper()
|
||||
p := bazelPaths{
|
||||
buildDir: t.TempDir(),
|
||||
soongOutDir: t.TempDir(),
|
||||
outputBase: "outputbase",
|
||||
workspaceDir: "workspace_dir",
|
||||
}
|
||||
@@ -114,5 +114,5 @@ func testBazelContext(t *testing.T, bazelCommandResults map[bazelCommand]string)
|
||||
bazelRunner: runner,
|
||||
paths: &p,
|
||||
requests: map[cqueryKey]bool{},
|
||||
}, p.buildDir
|
||||
}, p.soongOutDir
|
||||
}
|
||||
|
@@ -414,7 +414,7 @@ func PathForBazelOut(ctx PathContext, paths ...string) BazelOutPath {
|
||||
}
|
||||
|
||||
outputPath := OutputPath{basePath{"", ""},
|
||||
ctx.Config().buildDir,
|
||||
ctx.Config().soongOutDir,
|
||||
ctx.Config().BazelContext.OutputBase()}
|
||||
|
||||
return BazelOutPath{
|
||||
|
@@ -67,12 +67,12 @@ type Config struct {
|
||||
}
|
||||
|
||||
// BuildDir returns the build output directory for the configuration.
|
||||
func (c Config) BuildDir() string {
|
||||
return c.buildDir
|
||||
func (c Config) SoongOutDir() string {
|
||||
return c.soongOutDir
|
||||
}
|
||||
|
||||
func (c Config) NinjaBuildDir() string {
|
||||
return c.buildDir
|
||||
func (c Config) OutDir() string {
|
||||
return c.soongOutDir
|
||||
}
|
||||
|
||||
func (c Config) DebugCompilation() bool {
|
||||
@@ -122,7 +122,7 @@ type config struct {
|
||||
|
||||
deviceConfig *deviceConfig
|
||||
|
||||
buildDir string // the path of the build output directory
|
||||
soongOutDir string // the path of the build output directory
|
||||
moduleListFile string // the path to the file which lists blueprint files to parse.
|
||||
|
||||
env map[string]string
|
||||
@@ -283,11 +283,11 @@ func saveToBazelConfigFile(config *productVariables, outDir string) error {
|
||||
|
||||
// NullConfig returns a mostly empty Config for use by standalone tools like dexpreopt_gen that
|
||||
// use the android package.
|
||||
func NullConfig(buildDir string) Config {
|
||||
func NullConfig(soongOutDir string) Config {
|
||||
return Config{
|
||||
config: &config{
|
||||
buildDir: buildDir,
|
||||
fs: pathtools.OsFs,
|
||||
soongOutDir: soongOutDir,
|
||||
fs: pathtools.OsFs,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
||||
ShippingApiLevel: stringPtr("30"),
|
||||
},
|
||||
|
||||
buildDir: buildDir,
|
||||
soongOutDir: buildDir,
|
||||
captureBuild: true,
|
||||
env: envCopy,
|
||||
|
||||
@@ -397,7 +397,7 @@ func TestArchConfig(buildDir string, env map[string]string, bp string, fs map[st
|
||||
// multiple runs in the same program execution is carried over (such as Bazel
|
||||
// context or environment deps).
|
||||
func ConfigForAdditionalRun(c Config) (Config, error) {
|
||||
newConfig, err := NewConfig(c.buildDir, c.moduleListFile, c.env)
|
||||
newConfig, err := NewConfig(c.soongOutDir, c.moduleListFile, c.env)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
@@ -408,14 +408,14 @@ func ConfigForAdditionalRun(c Config) (Config, error) {
|
||||
|
||||
// NewConfig creates a new Config object. The srcDir argument specifies the path
|
||||
// to the root source directory. It also loads the config file, if found.
|
||||
func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]string) (Config, error) {
|
||||
func NewConfig(soongOutDir string, moduleListFile string, availableEnv map[string]string) (Config, error) {
|
||||
// Make a config with default options.
|
||||
config := &config{
|
||||
ProductVariablesFileName: filepath.Join(buildDir, productVariablesFileName),
|
||||
ProductVariablesFileName: filepath.Join(soongOutDir, productVariablesFileName),
|
||||
|
||||
env: availableEnv,
|
||||
|
||||
buildDir: buildDir,
|
||||
soongOutDir: soongOutDir,
|
||||
multilibConflicts: make(map[ArchType]bool),
|
||||
|
||||
moduleListFile: moduleListFile,
|
||||
@@ -428,7 +428,7 @@ func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]s
|
||||
|
||||
// Soundness check of the build and source directories. This won't catch strange
|
||||
// configurations with symlinks, but at least checks the obvious case.
|
||||
absBuildDir, err := filepath.Abs(buildDir)
|
||||
absBuildDir, err := filepath.Abs(soongOutDir)
|
||||
if err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
@@ -448,7 +448,7 @@ func NewConfig(buildDir string, moduleListFile string, availableEnv map[string]s
|
||||
return Config{}, err
|
||||
}
|
||||
|
||||
KatiEnabledMarkerFile := filepath.Join(buildDir, ".soong.kati_enabled")
|
||||
KatiEnabledMarkerFile := filepath.Join(soongOutDir, ".soong.kati_enabled")
|
||||
if _, err := os.Stat(absolutePath(KatiEnabledMarkerFile)); err == nil {
|
||||
config.katiEnabled = true
|
||||
}
|
||||
@@ -556,7 +556,7 @@ var _ bootstrap.ConfigStopBefore = (*config)(nil)
|
||||
// BlueprintToolLocation returns the directory containing build system tools
|
||||
// from Blueprint, like soong_zip and merge_zips.
|
||||
func (c *config) BlueprintToolLocation() string {
|
||||
return filepath.Join(c.buildDir, "host", c.PrebuiltOS(), "bin")
|
||||
return filepath.Join(c.soongOutDir, "host", c.PrebuiltOS(), "bin")
|
||||
}
|
||||
|
||||
var _ bootstrap.ConfigBlueprintToolLocation = (*config)(nil)
|
||||
|
@@ -834,7 +834,7 @@ func (f *fixture) outputDebugState() {
|
||||
func (r *TestResult) NormalizePathForTesting(path Path) string {
|
||||
pathContext := PathContextForTesting(r.Config)
|
||||
pathAsString := path.String()
|
||||
if rel, isRel := MaybeRel(pathContext, r.Config.BuildDir(), pathAsString); isRel {
|
||||
if rel, isRel := MaybeRel(pathContext, r.Config.SoongOutDir(), pathAsString); isRel {
|
||||
return rel
|
||||
}
|
||||
return pathAsString
|
||||
|
@@ -186,13 +186,13 @@ type Path interface {
|
||||
// A standard build has the following structure:
|
||||
// ../top/
|
||||
// out/ - make install files go here.
|
||||
// out/soong - this is the buildDir passed to NewTestConfig()
|
||||
// out/soong - this is the soongOutDir passed to NewTestConfig()
|
||||
// ... - the source files
|
||||
//
|
||||
// This function converts a path so that it appears relative to the ../top/ directory, i.e.
|
||||
// * Make install paths, which have the pattern "buildDir/../<path>" are converted into the top
|
||||
// * Make install paths, which have the pattern "soongOutDir/../<path>" are converted into the top
|
||||
// relative path "out/<path>"
|
||||
// * Soong install paths and other writable paths, which have the pattern "buildDir/<path>" are
|
||||
// * Soong install paths and other writable paths, which have the pattern "soongOutDir/<path>" are
|
||||
// converted into the top relative path "out/soong/<path>".
|
||||
// * Source paths are already relative to the top.
|
||||
// * Phony paths are not relative to anything.
|
||||
@@ -211,7 +211,7 @@ type WritablePath interface {
|
||||
Path
|
||||
|
||||
// return the path to the build directory.
|
||||
getBuildDir() string
|
||||
getSoongOutDir() string
|
||||
|
||||
// the writablePath method doesn't directly do anything,
|
||||
// but it allows a struct to distinguish between whether or not it implements the WritablePath interface
|
||||
@@ -992,7 +992,7 @@ func safePathForSource(ctx PathContext, pathComponents ...string) (SourcePath, e
|
||||
}
|
||||
|
||||
// absolute path already checked by validateSafePath
|
||||
if strings.HasPrefix(ret.String(), ctx.Config().buildDir) {
|
||||
if strings.HasPrefix(ret.String(), ctx.Config().soongOutDir) {
|
||||
return ret, fmt.Errorf("source path %q is in output", ret.String())
|
||||
}
|
||||
|
||||
@@ -1008,7 +1008,7 @@ func pathForSource(ctx PathContext, pathComponents ...string) (SourcePath, error
|
||||
}
|
||||
|
||||
// absolute path already checked by validatePath
|
||||
if strings.HasPrefix(ret.String(), ctx.Config().buildDir) {
|
||||
if strings.HasPrefix(ret.String(), ctx.Config().soongOutDir) {
|
||||
return ret, fmt.Errorf("source path %q is in output", ret.String())
|
||||
}
|
||||
|
||||
@@ -1151,7 +1151,7 @@ type OutputPath struct {
|
||||
basePath
|
||||
|
||||
// The soong build directory, i.e. Config.BuildDir()
|
||||
buildDir string
|
||||
soongOutDir string
|
||||
|
||||
fullPath string
|
||||
}
|
||||
@@ -1167,8 +1167,8 @@ func (p OutputPath) WithoutRel() OutputPath {
|
||||
return p
|
||||
}
|
||||
|
||||
func (p OutputPath) getBuildDir() string {
|
||||
return p.buildDir
|
||||
func (p OutputPath) getSoongOutDir() string {
|
||||
return p.soongOutDir
|
||||
}
|
||||
|
||||
func (p OutputPath) RelativeToTop() Path {
|
||||
@@ -1176,8 +1176,8 @@ func (p OutputPath) RelativeToTop() Path {
|
||||
}
|
||||
|
||||
func (p OutputPath) outputPathRelativeToTop() OutputPath {
|
||||
p.fullPath = StringPathRelativeToTop(p.buildDir, p.fullPath)
|
||||
p.buildDir = OutSoongDir
|
||||
p.fullPath = StringPathRelativeToTop(p.soongOutDir, p.fullPath)
|
||||
p.soongOutDir = OutSoongDir
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -1218,12 +1218,12 @@ func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath {
|
||||
if err != nil {
|
||||
reportPathError(ctx, err)
|
||||
}
|
||||
fullPath := filepath.Join(ctx.Config().buildDir, path)
|
||||
fullPath := filepath.Join(ctx.Config().soongOutDir, path)
|
||||
path = fullPath[len(fullPath)-len(path):]
|
||||
return OutputPath{basePath{path, ""}, ctx.Config().buildDir, fullPath}
|
||||
return OutputPath{basePath{path, ""}, ctx.Config().soongOutDir, fullPath}
|
||||
}
|
||||
|
||||
// PathsForOutput returns Paths rooted from buildDir
|
||||
// PathsForOutput returns Paths rooted from soongOutDir
|
||||
func PathsForOutput(ctx PathContext, paths []string) WritablePaths {
|
||||
ret := make(WritablePaths, len(paths))
|
||||
for i, path := range paths {
|
||||
@@ -1545,7 +1545,7 @@ type InstallPath struct {
|
||||
basePath
|
||||
|
||||
// The soong build directory, i.e. Config.BuildDir()
|
||||
buildDir string
|
||||
soongOutDir string
|
||||
|
||||
// partitionDir is the part of the InstallPath that is automatically determined according to the context.
|
||||
// For example, it is host/<os>-<arch> for host modules, and target/product/<device>/<partition> for device modules.
|
||||
@@ -1565,12 +1565,12 @@ func ensureTestOnly() {
|
||||
|
||||
func (p InstallPath) RelativeToTop() Path {
|
||||
ensureTestOnly()
|
||||
p.buildDir = OutSoongDir
|
||||
p.soongOutDir = OutSoongDir
|
||||
return p
|
||||
}
|
||||
|
||||
func (p InstallPath) getBuildDir() string {
|
||||
return p.buildDir
|
||||
func (p InstallPath) getSoongOutDir() string {
|
||||
return p.soongOutDir
|
||||
}
|
||||
|
||||
func (p InstallPath) ReplaceExtension(ctx PathContext, ext string) OutputPath {
|
||||
@@ -1585,9 +1585,9 @@ func (p InstallPath) writablePath() {}
|
||||
func (p InstallPath) String() string {
|
||||
if p.makePath {
|
||||
// Make path starts with out/ instead of out/soong.
|
||||
return filepath.Join(p.buildDir, "../", p.path)
|
||||
return filepath.Join(p.soongOutDir, "../", p.path)
|
||||
} else {
|
||||
return filepath.Join(p.buildDir, p.path)
|
||||
return filepath.Join(p.soongOutDir, p.path)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1596,9 +1596,9 @@ func (p InstallPath) String() string {
|
||||
// The ./soong is dropped if the install path is for Make.
|
||||
func (p InstallPath) PartitionDir() string {
|
||||
if p.makePath {
|
||||
return filepath.Join(p.buildDir, "../", p.partitionDir)
|
||||
return filepath.Join(p.soongOutDir, "../", p.partitionDir)
|
||||
} else {
|
||||
return filepath.Join(p.buildDir, p.partitionDir)
|
||||
return filepath.Join(p.soongOutDir, p.partitionDir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1694,7 +1694,7 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string,
|
||||
|
||||
base := InstallPath{
|
||||
basePath: basePath{partionPath, ""},
|
||||
buildDir: ctx.Config().buildDir,
|
||||
soongOutDir: ctx.Config().soongOutDir,
|
||||
partitionDir: partionPath,
|
||||
makePath: false,
|
||||
}
|
||||
@@ -1705,7 +1705,7 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string,
|
||||
func pathForNdkOrSdkInstall(ctx PathContext, prefix string, paths []string) InstallPath {
|
||||
base := InstallPath{
|
||||
basePath: basePath{prefix, ""},
|
||||
buildDir: ctx.Config().buildDir,
|
||||
soongOutDir: ctx.Config().soongOutDir,
|
||||
partitionDir: prefix,
|
||||
makePath: false,
|
||||
}
|
||||
@@ -1851,7 +1851,7 @@ type PhonyPath struct {
|
||||
|
||||
func (p PhonyPath) writablePath() {}
|
||||
|
||||
func (p PhonyPath) getBuildDir() string {
|
||||
func (p PhonyPath) getSoongOutDir() string {
|
||||
// A phone path cannot contain any / so cannot be relative to the build directory.
|
||||
return ""
|
||||
}
|
||||
|
@@ -54,10 +54,10 @@ type SingletonContext interface {
|
||||
|
||||
RequireNinjaVersion(major, minor, micro int)
|
||||
|
||||
// SetNinjaBuildDir sets the value of the top-level "builddir" Ninja variable
|
||||
// SetOutDir sets the value of the top-level "builddir" Ninja variable
|
||||
// that controls where Ninja stores its build log files. This value can be
|
||||
// set at most one time for a single build, later calls are ignored.
|
||||
SetNinjaBuildDir(pctx PackageContext, value string)
|
||||
SetOutDir(pctx PackageContext, value string)
|
||||
|
||||
// Eval takes a string with embedded ninja variables, and returns a string
|
||||
// with all of the variables recursively expanded. Any variables references
|
||||
@@ -180,8 +180,8 @@ func (s *singletonContextAdaptor) Phony(name string, deps ...Path) {
|
||||
addPhony(s.Config(), name, deps...)
|
||||
}
|
||||
|
||||
func (s *singletonContextAdaptor) SetNinjaBuildDir(pctx PackageContext, value string) {
|
||||
s.SingletonContext.SetNinjaBuildDir(pctx.PackageContext, value)
|
||||
func (s *singletonContextAdaptor) SetOutDir(pctx PackageContext, value string) {
|
||||
s.SingletonContext.SetOutDir(pctx.PackageContext, value)
|
||||
}
|
||||
|
||||
func (s *singletonContextAdaptor) Eval(pctx PackageContext, ninjaStr string) (string, error) {
|
||||
|
@@ -77,14 +77,14 @@ func AssertPathsRelativeToTopEquals(t *testing.T, message string, expected []str
|
||||
// StringPathRelativeToTop on the actual string path.
|
||||
func AssertStringPathRelativeToTopEquals(t *testing.T, message string, config Config, expected string, actual string) {
|
||||
t.Helper()
|
||||
AssertStringEquals(t, message, expected, StringPathRelativeToTop(config.buildDir, actual))
|
||||
AssertStringEquals(t, message, expected, StringPathRelativeToTop(config.soongOutDir, actual))
|
||||
}
|
||||
|
||||
// AssertStringPathsRelativeToTopEquals checks if the expected value is equal to the result of
|
||||
// calling StringPathsRelativeToTop on the actual string paths.
|
||||
func AssertStringPathsRelativeToTopEquals(t *testing.T, message string, config Config, expected []string, actual []string) {
|
||||
t.Helper()
|
||||
AssertDeepEquals(t, message, expected, StringPathsRelativeToTop(config.buildDir, actual))
|
||||
AssertDeepEquals(t, message, expected, StringPathsRelativeToTop(config.soongOutDir, actual))
|
||||
}
|
||||
|
||||
// AssertErrorMessageEquals checks if the error is not nil and has the expected message. If it does
|
||||
|
@@ -664,15 +664,15 @@ func newBaseTestingComponent(config Config, provider testBuildProvider) baseTest
|
||||
// containing at most one instance of the temporary build directory at the start of the path while
|
||||
// this assumes that there can be any number at any position.
|
||||
func normalizeStringRelativeToTop(config Config, s string) string {
|
||||
// The buildDir usually looks something like: /tmp/testFoo2345/001
|
||||
// The soongOutDir usually looks something like: /tmp/testFoo2345/001
|
||||
//
|
||||
// Replace any usage of the buildDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with
|
||||
// Replace any usage of the soongOutDir with out/soong, e.g. replace "/tmp/testFoo2345/001" with
|
||||
// "out/soong".
|
||||
outSoongDir := filepath.Clean(config.buildDir)
|
||||
outSoongDir := filepath.Clean(config.soongOutDir)
|
||||
re := regexp.MustCompile(`\Q` + outSoongDir + `\E\b`)
|
||||
s = re.ReplaceAllString(s, "out/soong")
|
||||
|
||||
// Replace any usage of the buildDir/.. with out, e.g. replace "/tmp/testFoo2345" with
|
||||
// Replace any usage of the soongOutDir/.. with out, e.g. replace "/tmp/testFoo2345" with
|
||||
// "out". This must come after the previous replacement otherwise this would replace
|
||||
// "/tmp/testFoo2345/001" with "out/001" instead of "out/soong".
|
||||
outDir := filepath.Dir(outSoongDir)
|
||||
@@ -991,7 +991,7 @@ func NormalizePathForTesting(path Path) string {
|
||||
}
|
||||
p := path.String()
|
||||
if w, ok := path.(WritablePath); ok {
|
||||
rel, err := filepath.Rel(w.getBuildDir(), p)
|
||||
rel, err := filepath.Rel(w.getSoongOutDir(), p)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@@ -34,12 +34,12 @@ func DocsSingleton() Singleton {
|
||||
type docsSingleton struct{}
|
||||
|
||||
func primaryBuilderPath(ctx SingletonContext) Path {
|
||||
buildDir := absolutePath(ctx.Config().BuildDir())
|
||||
soongOutDir := absolutePath(ctx.Config().SoongOutDir())
|
||||
binary := absolutePath(os.Args[0])
|
||||
primaryBuilder, err := filepath.Rel(buildDir, binary)
|
||||
primaryBuilder, err := filepath.Rel(soongOutDir, binary)
|
||||
if err != nil {
|
||||
ctx.Errorf("path to primary builder %q is not in build dir %q (%q)",
|
||||
os.Args[0], ctx.Config().BuildDir(), err)
|
||||
os.Args[0], ctx.Config().SoongOutDir(), err)
|
||||
}
|
||||
|
||||
return PathForOutput(ctx, primaryBuilder)
|
||||
|
Reference in New Issue
Block a user