Rename build.ninja with product name
Current build.ninja does not contain any product name, while other ninja files (such as combined ninja) do. This change adds product name to the build.ninja so it can be separated over multiple lunch targets Bug: 277029044 Test: build succeeded and checked if out/soong/build.ninja has been renamed Change-Id: I16dc71f829fd76f01b98da0d509a8e0ef6f62fa9
This commit is contained in:
@@ -80,9 +80,10 @@ type SoongBuildMode int
|
|||||||
|
|
||||||
type CmdArgs struct {
|
type CmdArgs struct {
|
||||||
bootstrap.Args
|
bootstrap.Args
|
||||||
RunGoTests bool
|
RunGoTests bool
|
||||||
OutDir string
|
OutDir string
|
||||||
SoongOutDir string
|
SoongOutDir string
|
||||||
|
SoongVariables string
|
||||||
|
|
||||||
SymlinkForestMarker string
|
SymlinkForestMarker string
|
||||||
Bp2buildMarker string
|
Bp2buildMarker string
|
||||||
@@ -491,7 +492,7 @@ func NullConfig(outDir, soongOutDir string) Config {
|
|||||||
func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) {
|
func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) {
|
||||||
// Make a config with default options.
|
// Make a config with default options.
|
||||||
config := &config{
|
config := &config{
|
||||||
ProductVariablesFileName: filepath.Join(cmdArgs.SoongOutDir, productVariablesFileName),
|
ProductVariablesFileName: cmdArgs.SoongVariables,
|
||||||
|
|
||||||
env: availableEnv,
|
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.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.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.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.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.EmptyNinjaFile, "empty-ninja-file", false, "write out a 0-byte ninja file")
|
||||||
flag.BoolVar(&cmdlineArgs.MultitreeBuild, "multitree-build", false, "this is a multitree build")
|
flag.BoolVar(&cmdlineArgs.MultitreeBuild, "multitree-build", false, "this is a multitree build")
|
||||||
@@ -517,6 +518,8 @@ func main() {
|
|||||||
|
|
||||||
var finalOutputFile string
|
var finalOutputFile string
|
||||||
|
|
||||||
|
writeSymlink := false
|
||||||
|
|
||||||
// Run Soong for a specific activity, like bp2build, queryview
|
// Run Soong for a specific activity, like bp2build, queryview
|
||||||
// or the actual Soong build for the build.ninja file.
|
// or the actual Soong build for the build.ninja file.
|
||||||
switch configuration.BuildMode {
|
switch configuration.BuildMode {
|
||||||
@@ -539,8 +542,13 @@ func main() {
|
|||||||
maybeQuit(err, "")
|
maybeQuit(err, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
writeSymlink = true
|
||||||
} else {
|
} else {
|
||||||
finalOutputFile = runSoongOnlyBuild(ctx, extraNinjaDeps)
|
finalOutputFile = runSoongOnlyBuild(ctx, extraNinjaDeps)
|
||||||
|
|
||||||
|
if configuration.BuildMode == android.AnalysisNoBazel {
|
||||||
|
writeSymlink = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
writeMetrics(configuration, ctx.EventHandler, metricsDir)
|
||||||
}
|
}
|
||||||
@@ -551,6 +559,24 @@ func main() {
|
|||||||
// are ninja inputs to the main output file, then ninja would superfluously
|
// are ninja inputs to the main output file, then ninja would superfluously
|
||||||
// rebuild this output file on the next build invocation.
|
// rebuild this output file on the next build invocation.
|
||||||
touch(shared.JoinPath(topDir, finalOutputFile))
|
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) {
|
func writeUsedEnvironmentFile(configuration android.Config) {
|
||||||
|
@@ -1229,6 +1229,13 @@ func (c *configImpl) TargetProduct() string {
|
|||||||
panic("TARGET_PRODUCT is not defined")
|
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 {
|
func (c *configImpl) TargetDevice() string {
|
||||||
return c.targetDevice
|
return c.targetDevice
|
||||||
}
|
}
|
||||||
@@ -1554,11 +1561,21 @@ func (c *configImpl) KatiPackageNinjaFile() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *configImpl) SoongVarsFile() 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 {
|
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 {
|
func (c *configImpl) CombinedNinjaFile() string {
|
||||||
|
@@ -235,7 +235,7 @@ func bootstrapEpochCleanup(ctx Context, config Config) {
|
|||||||
} else if !exists {
|
} else if !exists {
|
||||||
// The tree is out of date for the current epoch, delete files used by bootstrap
|
// The tree is out of date for the current epoch, delete files used by bootstrap
|
||||||
// and force the primary builder to rerun.
|
// and force the primary builder to rerun.
|
||||||
os.Remove(filepath.Join(config.SoongOutDir(), "build.ninja"))
|
os.Remove(config.SoongNinjaFile())
|
||||||
for _, globFile := range bootstrapGlobFileList(config) {
|
for _, globFile := range bootstrapGlobFileList(config) {
|
||||||
os.Remove(globFile)
|
os.Remove(globFile)
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,9 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
|||||||
// Clean up some files for incremental builds across incompatible changes.
|
// Clean up some files for incremental builds across incompatible changes.
|
||||||
bootstrapEpochCleanup(ctx, config)
|
bootstrapEpochCleanup(ctx, config)
|
||||||
|
|
||||||
mainSoongBuildExtraArgs := []string{"-o", config.SoongNinjaFile()}
|
baseArgs := []string{"--soong_variables", config.SoongVarsFile()}
|
||||||
|
|
||||||
|
mainSoongBuildExtraArgs := append(baseArgs, "-o", config.SoongNinjaFile())
|
||||||
if config.EmptyNinjaFile() {
|
if config.EmptyNinjaFile() {
|
||||||
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--empty-ninja-file")
|
mainSoongBuildExtraArgs = append(mainSoongBuildExtraArgs, "--empty-ninja-file")
|
||||||
}
|
}
|
||||||
@@ -306,49 +308,59 @@ func bootstrapBlueprint(ctx Context, config Config) {
|
|||||||
specificArgs: mainSoongBuildExtraArgs,
|
specificArgs: mainSoongBuildExtraArgs,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: bp2buildFilesTag,
|
name: bp2buildFilesTag,
|
||||||
description: fmt.Sprintf("converting Android.bp files to BUILD files at %s/bp2build", config.SoongOutDir()),
|
description: fmt.Sprintf("converting Android.bp files to BUILD files at %s/bp2build", config.SoongOutDir()),
|
||||||
config: config,
|
config: config,
|
||||||
output: config.Bp2BuildFilesMarkerFile(),
|
output: config.Bp2BuildFilesMarkerFile(),
|
||||||
specificArgs: []string{"--bp2build_marker", config.Bp2BuildFilesMarkerFile()},
|
specificArgs: append(baseArgs,
|
||||||
|
"--bp2build_marker", config.Bp2BuildFilesMarkerFile(),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: bp2buildWorkspaceTag,
|
name: bp2buildWorkspaceTag,
|
||||||
description: "Creating Bazel symlink forest",
|
description: "Creating Bazel symlink forest",
|
||||||
config: config,
|
config: config,
|
||||||
output: config.Bp2BuildWorkspaceMarkerFile(),
|
output: config.Bp2BuildWorkspaceMarkerFile(),
|
||||||
specificArgs: []string{"--symlink_forest_marker", config.Bp2BuildWorkspaceMarkerFile()},
|
specificArgs: append(baseArgs,
|
||||||
|
"--symlink_forest_marker", config.Bp2BuildWorkspaceMarkerFile(),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: jsonModuleGraphTag,
|
name: jsonModuleGraphTag,
|
||||||
description: fmt.Sprintf("generating the Soong module graph at %s", config.ModuleGraphFile()),
|
description: fmt.Sprintf("generating the Soong module graph at %s", config.ModuleGraphFile()),
|
||||||
config: config,
|
config: config,
|
||||||
output: config.ModuleGraphFile(),
|
output: config.ModuleGraphFile(),
|
||||||
specificArgs: []string{
|
specificArgs: append(baseArgs,
|
||||||
"--module_graph_file", config.ModuleGraphFile(),
|
"--module_graph_file", config.ModuleGraphFile(),
|
||||||
"--module_actions_file", config.ModuleActionsFile(),
|
"--module_actions_file", config.ModuleActionsFile(),
|
||||||
},
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: queryviewTag,
|
name: queryviewTag,
|
||||||
description: fmt.Sprintf("generating the Soong module graph as a Bazel workspace at %s", queryviewDir),
|
description: fmt.Sprintf("generating the Soong module graph as a Bazel workspace at %s", queryviewDir),
|
||||||
config: config,
|
config: config,
|
||||||
output: config.QueryviewMarkerFile(),
|
output: config.QueryviewMarkerFile(),
|
||||||
specificArgs: []string{"--bazel_queryview_dir", queryviewDir},
|
specificArgs: append(baseArgs,
|
||||||
|
"--bazel_queryview_dir", queryviewDir,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: apiBp2buildTag,
|
name: apiBp2buildTag,
|
||||||
description: fmt.Sprintf("generating BUILD files for API contributions at %s", apiBp2buildDir),
|
description: fmt.Sprintf("generating BUILD files for API contributions at %s", apiBp2buildDir),
|
||||||
config: config,
|
config: config,
|
||||||
output: config.ApiBp2buildMarkerFile(),
|
output: config.ApiBp2buildMarkerFile(),
|
||||||
specificArgs: []string{"--bazel_api_bp2build_dir", apiBp2buildDir},
|
specificArgs: append(baseArgs,
|
||||||
|
"--bazel_api_bp2build_dir", apiBp2buildDir,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: soongDocsTag,
|
name: soongDocsTag,
|
||||||
description: fmt.Sprintf("generating Soong docs at %s", config.SoongDocsHtml()),
|
description: fmt.Sprintf("generating Soong docs at %s", config.SoongDocsHtml()),
|
||||||
config: config,
|
config: config,
|
||||||
output: config.SoongDocsHtml(),
|
output: config.SoongDocsHtml(),
|
||||||
specificArgs: []string{"--soong_docs", config.SoongDocsHtml()},
|
specificArgs: append(baseArgs,
|
||||||
|
"--soong_docs", config.SoongDocsHtml(),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user