Merge "Rename build.ninja with product name" am: 5500fc89c1
am: babe56a6c8
am: 1fcb13ac2e
am: 0b814fe80e
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2546570 Change-Id: I092f36c848535a18a107866056204460cff6070d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -80,9 +80,10 @@ type SoongBuildMode int
|
||||
|
||||
type CmdArgs struct {
|
||||
bootstrap.Args
|
||||
RunGoTests bool
|
||||
OutDir string
|
||||
SoongOutDir string
|
||||
RunGoTests bool
|
||||
OutDir string
|
||||
SoongOutDir string
|
||||
SoongVariables string
|
||||
|
||||
SymlinkForestMarker string
|
||||
Bp2buildMarker string
|
||||
@@ -491,7 +492,7 @@ func NullConfig(outDir, soongOutDir string) Config {
|
||||
func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) {
|
||||
// Make a config with default options.
|
||||
config := &config{
|
||||
ProductVariablesFileName: filepath.Join(cmdArgs.SoongOutDir, productVariablesFileName),
|
||||
ProductVariablesFileName: cmdArgs.SoongVariables,
|
||||
|
||||
env: availableEnv,
|
||||
|
||||
|
@@ -78,6 +78,7 @@ func init() {
|
||||
flag.StringVar(&cmdlineArgs.Bp2buildMarker, "bp2build_marker", "", "If set, run bp2build, touch the specified marker file then exit")
|
||||
flag.StringVar(&cmdlineArgs.SymlinkForestMarker, "symlink_forest_marker", "", "If set, create the bp2build symlink forest, touch the specified marker file, then exit")
|
||||
flag.StringVar(&cmdlineArgs.OutFile, "o", "build.ninja", "the Ninja file to output")
|
||||
flag.StringVar(&cmdlineArgs.SoongVariables, "soong_variables", "soong.variables", "the file contains all build variables")
|
||||
flag.StringVar(&cmdlineArgs.BazelForceEnabledModules, "bazel-force-enabled-modules", "", "additional modules to build with Bazel. Comma-delimited")
|
||||
flag.BoolVar(&cmdlineArgs.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file")
|
||||
flag.BoolVar(&cmdlineArgs.MultitreeBuild, "multitree-build", false, "this is a multitree build")
|
||||
@@ -517,6 +518,8 @@ func main() {
|
||||
|
||||
var finalOutputFile string
|
||||
|
||||
writeSymlink := false
|
||||
|
||||
// Run Soong for a specific activity, like bp2build, queryview
|
||||
// or the actual Soong build for the build.ninja file.
|
||||
switch configuration.BuildMode {
|
||||
@@ -539,8 +542,13 @@ func main() {
|
||||
maybeQuit(err, "")
|
||||
}
|
||||
}
|
||||
writeSymlink = true
|
||||
} else {
|
||||
finalOutputFile = runSoongOnlyBuild(ctx, extraNinjaDeps)
|
||||
|
||||
if configuration.BuildMode == android.AnalysisNoBazel {
|
||||
writeSymlink = true
|
||||
}
|
||||
}
|
||||
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
||||
}
|
||||
@@ -551,6 +559,24 @@ func main() {
|
||||
// are ninja inputs to the main output file, then ninja would superfluously
|
||||
// rebuild this output file on the next build invocation.
|
||||
touch(shared.JoinPath(topDir, finalOutputFile))
|
||||
|
||||
// TODO(b/277029044): Remove this function once build.<product>.ninja lands
|
||||
if writeSymlink {
|
||||
writeBuildNinjaSymlink(configuration, finalOutputFile)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(b/277029044): Remove this function once build.<product>.ninja lands
|
||||
func writeBuildNinjaSymlink(config android.Config, source string) {
|
||||
targetPath := shared.JoinPath(topDir, config.SoongOutDir(), "build.ninja")
|
||||
sourcePath := shared.JoinPath(topDir, source)
|
||||
|
||||
if targetPath == sourcePath {
|
||||
return
|
||||
}
|
||||
|
||||
os.Remove(targetPath)
|
||||
os.Symlink(sourcePath, targetPath)
|
||||
}
|
||||
|
||||
func writeUsedEnvironmentFile(configuration android.Config) {
|
||||
|
@@ -1229,6 +1229,13 @@ func (c *configImpl) TargetProduct() string {
|
||||
panic("TARGET_PRODUCT is not defined")
|
||||
}
|
||||
|
||||
func (c *configImpl) TargetProductOrErr() (string, error) {
|
||||
if v, ok := c.environ.Get("TARGET_PRODUCT"); ok {
|
||||
return v, nil
|
||||
}
|
||||
return "", fmt.Errorf("TARGET_PRODUCT is not defined")
|
||||
}
|
||||
|
||||
func (c *configImpl) TargetDevice() string {
|
||||
return c.targetDevice
|
||||
}
|
||||
@@ -1554,11 +1561,21 @@ func (c *configImpl) KatiPackageNinjaFile() string {
|
||||
}
|
||||
|
||||
func (c *configImpl) SoongVarsFile() string {
|
||||
return filepath.Join(c.SoongOutDir(), "soong.variables")
|
||||
targetProduct, err := c.TargetProductOrErr()
|
||||
if err != nil {
|
||||
return filepath.Join(c.SoongOutDir(), "soong.variables")
|
||||
} else {
|
||||
return filepath.Join(c.SoongOutDir(), "soong."+targetProduct+".variables")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *configImpl) SoongNinjaFile() string {
|
||||
return filepath.Join(c.SoongOutDir(), "build.ninja")
|
||||
targetProduct, err := c.TargetProductOrErr()
|
||||
if err != nil {
|
||||
return filepath.Join(c.SoongOutDir(), "build.ninja")
|
||||
} else {
|
||||
return filepath.Join(c.SoongOutDir(), "build."+targetProduct+".ninja")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *configImpl) CombinedNinjaFile() string {
|
||||
|
@@ -235,7 +235,7 @@ func bootstrapEpochCleanup(ctx Context, config Config) {
|
||||
} else if !exists {
|
||||
// The tree is out of date for the current epoch, delete files used by bootstrap
|
||||
// and force the primary builder to rerun.
|
||||
os.Remove(filepath.Join(config.SoongOutDir(), "build.ninja"))
|
||||
os.Remove(config.SoongNinjaFile())
|
||||
for _, globFile := range bootstrapGlobFileList(config) {
|
||||
os.Remove(globFile)
|
||||
}
|
||||
@@ -263,7 +263,9 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
||||
// Clean up some files for incremental builds across incompatible changes.
|
||||
bootstrapEpochCleanup(ctx, config)
|
||||
|
||||
mainSoongBuildExtraArgs := []string{"-o", config.SoongNinjaFile()}
|
||||
baseArgs := []string{"--soong_variables", config.SoongVarsFile()}
|
||||
|
||||
mainSoongBuildExtraArgs := append(baseArgs, "-o", config.SoongNinjaFile())
|
||||
if config.EmptyNinjaFile() {
|
||||
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--empty-ninja-file")
|
||||
}
|
||||
@@ -306,49 +308,59 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
||||
specificArgs: mainSoongBuildExtraArgs,
|
||||
},
|
||||
{
|
||||
name: bp2buildFilesTag,
|
||||
description: fmt.Sprintf("converting Android.bp files to BUILD files at %s/bp2build", config.SoongOutDir()),
|
||||
config: config,
|
||||
output: config.Bp2BuildFilesMarkerFile(),
|
||||
specificArgs: []string{"--bp2build_marker", config.Bp2BuildFilesMarkerFile()},
|
||||
name: bp2buildFilesTag,
|
||||
description: fmt.Sprintf("converting Android.bp files to BUILD files at %s/bp2build", config.SoongOutDir()),
|
||||
config: config,
|
||||
output: config.Bp2BuildFilesMarkerFile(),
|
||||
specificArgs: append(baseArgs,
|
||||
"--bp2build_marker", config.Bp2BuildFilesMarkerFile(),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: bp2buildWorkspaceTag,
|
||||
description: "Creating Bazel symlink forest",
|
||||
config: config,
|
||||
output: config.Bp2BuildWorkspaceMarkerFile(),
|
||||
specificArgs: []string{"--symlink_forest_marker", config.Bp2BuildWorkspaceMarkerFile()},
|
||||
name: bp2buildWorkspaceTag,
|
||||
description: "Creating Bazel symlink forest",
|
||||
config: config,
|
||||
output: config.Bp2BuildWorkspaceMarkerFile(),
|
||||
specificArgs: append(baseArgs,
|
||||
"--symlink_forest_marker", config.Bp2BuildWorkspaceMarkerFile(),
|
||||
),
|
||||
},
|
||||
{
|
||||
name: jsonModuleGraphTag,
|
||||
description: fmt.Sprintf("generating the Soong module graph at %s", config.ModuleGraphFile()),
|
||||
config: config,
|
||||
output: config.ModuleGraphFile(),
|
||||
specificArgs: []string{
|
||||
specificArgs: append(baseArgs,
|
||||
"--module_graph_file", config.ModuleGraphFile(),
|
||||
"--module_actions_file", config.ModuleActionsFile(),
|
||||
},
|
||||
),
|
||||
},
|
||||
{
|
||||
name: queryviewTag,
|
||||
description: fmt.Sprintf("generating the Soong module graph as a Bazel workspace at %s", queryviewDir),
|
||||
config: config,
|
||||
output: config.QueryviewMarkerFile(),
|
||||
specificArgs: []string{"--bazel_queryview_dir", queryviewDir},
|
||||
name: queryviewTag,
|
||||
description: fmt.Sprintf("generating the Soong module graph as a Bazel workspace at %s", queryviewDir),
|
||||
config: config,
|
||||
output: config.QueryviewMarkerFile(),
|
||||
specificArgs: append(baseArgs,
|
||||
"--bazel_queryview_dir", queryviewDir,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: apiBp2buildTag,
|
||||
description: fmt.Sprintf("generating BUILD files for API contributions at %s", apiBp2buildDir),
|
||||
config: config,
|
||||
output: config.ApiBp2buildMarkerFile(),
|
||||
specificArgs: []string{"--bazel_api_bp2build_dir", apiBp2buildDir},
|
||||
name: apiBp2buildTag,
|
||||
description: fmt.Sprintf("generating BUILD files for API contributions at %s", apiBp2buildDir),
|
||||
config: config,
|
||||
output: config.ApiBp2buildMarkerFile(),
|
||||
specificArgs: append(baseArgs,
|
||||
"--bazel_api_bp2build_dir", apiBp2buildDir,
|
||||
),
|
||||
},
|
||||
{
|
||||
name: soongDocsTag,
|
||||
description: fmt.Sprintf("generating Soong docs at %s", config.SoongDocsHtml()),
|
||||
config: config,
|
||||
output: config.SoongDocsHtml(),
|
||||
specificArgs: []string{"--soong_docs", config.SoongDocsHtml()},
|
||||
name: soongDocsTag,
|
||||
description: fmt.Sprintf("generating Soong docs at %s", config.SoongDocsHtml()),
|
||||
config: config,
|
||||
output: config.SoongDocsHtml(),
|
||||
specificArgs: append(baseArgs,
|
||||
"--soong_docs", config.SoongDocsHtml(),
|
||||
),
|
||||
},
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user