Merge "Add support for PRODUCT_RELEASE_CONFIG_MAPS" into main
This commit is contained in:
commit
4c01bb49da
3 changed files with 62 additions and 5 deletions
|
@ -59,6 +59,9 @@ type command struct {
|
||||||
|
|
||||||
// run the command
|
// run the command
|
||||||
run func(ctx build.Context, config build.Config, args []string)
|
run func(ctx build.Context, config build.Config, args []string)
|
||||||
|
|
||||||
|
// whether to do common setup before calling run.
|
||||||
|
doSetup bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// list of supported commands (flags) supported by soong ui
|
// list of supported commands (flags) supported by soong ui
|
||||||
|
@ -69,6 +72,7 @@ var commands = []command{
|
||||||
config: build.NewConfig,
|
config: build.NewConfig,
|
||||||
stdio: stdio,
|
stdio: stdio,
|
||||||
run: runMake,
|
run: runMake,
|
||||||
|
doSetup: true,
|
||||||
}, {
|
}, {
|
||||||
flag: "--dumpvar-mode",
|
flag: "--dumpvar-mode",
|
||||||
description: "print the value of the legacy make variable VAR to stdout",
|
description: "print the value of the legacy make variable VAR to stdout",
|
||||||
|
@ -77,6 +81,7 @@ var commands = []command{
|
||||||
config: dumpVarConfig,
|
config: dumpVarConfig,
|
||||||
stdio: customStdio,
|
stdio: customStdio,
|
||||||
run: dumpVar,
|
run: dumpVar,
|
||||||
|
doSetup: true,
|
||||||
}, {
|
}, {
|
||||||
flag: "--dumpvars-mode",
|
flag: "--dumpvars-mode",
|
||||||
description: "dump the values of one or more legacy make variables, in shell syntax",
|
description: "dump the values of one or more legacy make variables, in shell syntax",
|
||||||
|
@ -85,6 +90,7 @@ var commands = []command{
|
||||||
config: dumpVarConfig,
|
config: dumpVarConfig,
|
||||||
stdio: customStdio,
|
stdio: customStdio,
|
||||||
run: dumpVars,
|
run: dumpVars,
|
||||||
|
doSetup: true,
|
||||||
}, {
|
}, {
|
||||||
flag: "--build-mode",
|
flag: "--build-mode",
|
||||||
description: "build modules based on the specified build action",
|
description: "build modules based on the specified build action",
|
||||||
|
@ -182,8 +188,12 @@ func main() {
|
||||||
CriticalPath: criticalPath,
|
CriticalPath: criticalPath,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
config := c.config(buildCtx, args...)
|
freshConfig := func() build.Config {
|
||||||
config.SetLogsPrefix(c.logsPrefix)
|
config := c.config(buildCtx, args...)
|
||||||
|
config.SetLogsPrefix(c.logsPrefix)
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
config := freshConfig()
|
||||||
logsDir := config.LogsDir()
|
logsDir := config.LogsDir()
|
||||||
buildStarted = config.BuildStartedTimeOrDefault(buildStarted)
|
buildStarted = config.BuildStartedTimeOrDefault(buildStarted)
|
||||||
|
|
||||||
|
@ -213,6 +223,16 @@ func main() {
|
||||||
log.Verbosef(" [%d] %s", i, arg)
|
log.Verbosef(" [%d] %s", i, arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.doSetup {
|
||||||
|
// We need to call logAndSymlinkSetup before we can do product
|
||||||
|
// config, which is how we get PRODUCT_CONFIG_RELEASE_MAPS set
|
||||||
|
// for the final product config for the build.
|
||||||
|
logAndSymlinkSetup(buildCtx, config)
|
||||||
|
if build.SetProductReleaseConfigMaps(buildCtx, config) {
|
||||||
|
config = freshConfig()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
stat.Finish()
|
stat.Finish()
|
||||||
criticalPath.WriteToMetrics(met)
|
criticalPath.WriteToMetrics(met)
|
||||||
|
@ -311,7 +331,6 @@ func removeBadTargetRename(ctx build.Context, config build.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpVar(ctx build.Context, config build.Config, args []string) {
|
func dumpVar(ctx build.Context, config build.Config, args []string) {
|
||||||
logAndSymlinkSetup(ctx, config)
|
|
||||||
flags := flag.NewFlagSet("dumpvar", flag.ExitOnError)
|
flags := flag.NewFlagSet("dumpvar", flag.ExitOnError)
|
||||||
flags.SetOutput(ctx.Writer)
|
flags.SetOutput(ctx.Writer)
|
||||||
|
|
||||||
|
@ -364,7 +383,6 @@ func dumpVar(ctx build.Context, config build.Config, args []string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dumpVars(ctx build.Context, config build.Config, args []string) {
|
func dumpVars(ctx build.Context, config build.Config, args []string) {
|
||||||
logAndSymlinkSetup(ctx, config)
|
|
||||||
|
|
||||||
flags := flag.NewFlagSet("dumpvars", flag.ExitOnError)
|
flags := flag.NewFlagSet("dumpvars", flag.ExitOnError)
|
||||||
flags.SetOutput(ctx.Writer)
|
flags.SetOutput(ctx.Writer)
|
||||||
|
@ -544,7 +562,6 @@ func buildActionConfig(ctx build.Context, args ...string) build.Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMake(ctx build.Context, config build.Config, _ []string) {
|
func runMake(ctx build.Context, config build.Config, _ []string) {
|
||||||
logAndSymlinkSetup(ctx, config)
|
|
||||||
logsDir := config.LogsDir()
|
logsDir := config.LogsDir()
|
||||||
if config.IsVerbose() {
|
if config.IsVerbose() {
|
||||||
writer := ctx.Writer
|
writer := ctx.Writer
|
||||||
|
|
|
@ -31,6 +31,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"android/soong/shared"
|
"android/soong/shared"
|
||||||
|
"android/soong/ui/metrics"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
|
|
||||||
|
@ -461,6 +462,42 @@ func NewBuildActionConfig(action BuildAction, dir string, ctx Context, args ...s
|
||||||
return NewConfig(ctx, getConfigArgs(action, dir, ctx, args)...)
|
return NewConfig(ctx, getConfigArgs(action, dir, ctx, args)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prepare for getting make variables. For them to be accurate, we need to have
|
||||||
|
// obtained PRODUCT_RELEASE_CONFIG_MAPS.
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
//
|
||||||
|
// Whether config should be called again.
|
||||||
|
//
|
||||||
|
// TODO: when converting product config to a declarative language, make sure
|
||||||
|
// that PRODUCT_RELEASE_CONFIG_MAPS is properly handled as a separate step in
|
||||||
|
// that process.
|
||||||
|
func SetProductReleaseConfigMaps(ctx Context, config Config) bool {
|
||||||
|
ctx.BeginTrace(metrics.RunKati, "SetProductReleaseConfigMaps")
|
||||||
|
defer ctx.EndTrace()
|
||||||
|
|
||||||
|
if config.SkipConfig() {
|
||||||
|
// This duplicates the logic from Build to skip product config
|
||||||
|
// if the user has explicitly said to.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
releaseConfigVars := []string{
|
||||||
|
"PRODUCT_RELEASE_CONFIG_MAPS",
|
||||||
|
}
|
||||||
|
|
||||||
|
origValue, _ := config.environ.Get("PRODUCT_RELEASE_CONFIG_MAPS")
|
||||||
|
// Get the PRODUCT_RELEASE_CONFIG_MAPS for this product, to avoid polluting the environment
|
||||||
|
// when we run product config to get the rest of the make vars.
|
||||||
|
releaseMapVars, err := dumpMakeVars(ctx, config, nil, releaseConfigVars, false, "")
|
||||||
|
if err != nil {
|
||||||
|
ctx.Fatalln("Error getting PRODUCT_RELEASE_CONFIG_MAPS:", err)
|
||||||
|
}
|
||||||
|
productReleaseConfigMaps := releaseMapVars["PRODUCT_RELEASE_CONFIG_MAPS"]
|
||||||
|
os.Setenv("PRODUCT_RELEASE_CONFIG_MAPS", productReleaseConfigMaps)
|
||||||
|
return origValue != productReleaseConfigMaps
|
||||||
|
}
|
||||||
|
|
||||||
// storeConfigMetrics selects a set of configuration information and store in
|
// storeConfigMetrics selects a set of configuration information and store in
|
||||||
// the metrics system for further analysis.
|
// the metrics system for further analysis.
|
||||||
func storeConfigMetrics(ctx Context, config Config) {
|
func storeConfigMetrics(ctx Context, config Config) {
|
||||||
|
|
|
@ -191,6 +191,9 @@ func runMakeProductConfig(ctx Context, config Config) {
|
||||||
"TARGET_BUILD_APPS",
|
"TARGET_BUILD_APPS",
|
||||||
"TARGET_BUILD_UNBUNDLED",
|
"TARGET_BUILD_UNBUNDLED",
|
||||||
|
|
||||||
|
// Additional release config maps
|
||||||
|
"PRODUCT_RELEASE_CONFIG_MAPS",
|
||||||
|
|
||||||
// compiler wrappers set up by make
|
// compiler wrappers set up by make
|
||||||
"CC_WRAPPER",
|
"CC_WRAPPER",
|
||||||
"CXX_WRAPPER",
|
"CXX_WRAPPER",
|
||||||
|
|
Loading…
Reference in a new issue