diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-07-14 11:29:29 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-10-17 12:57:41 -0700 |
commit | 051133ba5481ea5f9dd850d6870c2f94223db476 (patch) | |
tree | 85ec83c0d558fd43bc0708365434c0b3d454fef6 /ui | |
parent | 0e8afed83a27c26e52fd2c05b38869cc867123d2 (diff) | |
download | build_soong-051133ba5481ea5f9dd850d6870c2f94223db476.tar.gz build_soong-051133ba5481ea5f9dd850d6870c2f94223db476.tar.bz2 build_soong-051133ba5481ea5f9dd850d6870c2f94223db476.zip |
Add --dumpvar[s]-mode to replace config.mk uses
build/soong/soong_ui.bash --dumpvars-mode \
--vars="..." \
--abs-vars="..." \
--var-prefix="..." \
--abs-var-prefix="..."
is similar to the previous:
CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
make -f build/core/config.mk dump-many-vars \
DUMP_MANY_VARS="..." \
DUMP_MANY_ABS_VARS="..." \
DUMP_VAR_PREFIX="..." \
DUMP_ABS_VAR_PREFIX="..."
and
build/soong/soong_ui.bash --dumpvar-mode [--abs] VAR
is similar to the previous:
CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
make -f build/core/config.mk dumpvar-[abs-]-VAR
But uses soong_ui and ckati, so that we use a consistent make parser and
sandboxing configurations.
One major output difference between the pure make implementation and
this one is that report_config in Go is implemented using embedded
newlines in single quotes, while the make implementation uses `` with
embedded echo commands. This seems to work fine for both bash and zsh,
and report_config isn't meant to be machine-parsed anyways.
Test: build/soong/soong_ui.bash --dumpvar-mode report_config
Test: build/soong/soong_ui.bash --dumpvar-mode TARGET_DEVICE
Test: build/soong/soong_ui.bash --dumpvar-mode --abs PRODUCT_OUT
Test: build/soong/soong_ui.bash --dumpvar-mode --abs ALL_PRODUCTS
Test: build/soong/soong_ui.bash --dumpvars-mode --vars="report_config TARGET_DEVICE" --abs-vars="ALL_PRODUCTS"
Test: build/soong/soong_ui.bash --dumpvars-mode --vars=TARGET_DEVICE --abs-vars=PRODUCT_OUT --var-prefix=v_ --abs-var-prefix=a_
Change-Id: I0fbd0732bbf6fcfcd24084cf3c830a91a4b6bfc2
Diffstat (limited to 'ui')
-rw-r--r-- | ui/build/dumpvars.go | 83 |
1 files changed, 46 insertions, 37 deletions
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index e6c3f56b..fb20d63b 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -15,6 +15,7 @@ package build import ( + "bytes" "fmt" "strings" ) @@ -78,6 +79,49 @@ func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_ return ret, nil } +// Variables to print out in the top banner +var BannerVars = []string{ + "PLATFORM_VERSION_CODENAME", + "PLATFORM_VERSION", + "TARGET_PRODUCT", + "TARGET_BUILD_VARIANT", + "TARGET_BUILD_TYPE", + "TARGET_BUILD_APPS", + "TARGET_ARCH", + "TARGET_ARCH_VARIANT", + "TARGET_CPU_VARIANT", + "TARGET_2ND_ARCH", + "TARGET_2ND_ARCH_VARIANT", + "TARGET_2ND_CPU_VARIANT", + "HOST_ARCH", + "HOST_2ND_ARCH", + "HOST_OS", + "HOST_OS_EXTRA", + "HOST_CROSS_OS", + "HOST_CROSS_ARCH", + "HOST_CROSS_2ND_ARCH", + "HOST_BUILD_TYPE", + "BUILD_ID", + "OUT_DIR", + "AUX_OS_VARIANT_LIST", + "TARGET_BUILD_PDK", + "PDK_FUSION_PLATFORM_ZIP", +} + +func Banner(make_vars map[string]string) string { + b := &bytes.Buffer{} + + fmt.Fprintln(b, "============================================") + for _, name := range BannerVars { + if make_vars[name] != "" { + fmt.Fprintf(b, "%s=%s\n", name, make_vars[name]) + } + } + fmt.Fprint(b, "============================================") + + return b.String() +} + func runMakeProductConfig(ctx Context, config Config) { // Variables to export into the environment of Kati/Ninja exportEnvVars := []string{ @@ -99,35 +143,6 @@ func runMakeProductConfig(ctx Context, config Config) { "CCACHE_CPP2", } - // Variables to print out in the top banner - bannerVars := []string{ - "PLATFORM_VERSION_CODENAME", - "PLATFORM_VERSION", - "TARGET_PRODUCT", - "TARGET_BUILD_VARIANT", - "TARGET_BUILD_TYPE", - "TARGET_BUILD_APPS", - "TARGET_ARCH", - "TARGET_ARCH_VARIANT", - "TARGET_CPU_VARIANT", - "TARGET_2ND_ARCH", - "TARGET_2ND_ARCH_VARIANT", - "TARGET_2ND_CPU_VARIANT", - "HOST_ARCH", - "HOST_2ND_ARCH", - "HOST_OS", - "HOST_OS_EXTRA", - "HOST_CROSS_OS", - "HOST_CROSS_ARCH", - "HOST_CROSS_2ND_ARCH", - "HOST_BUILD_TYPE", - "BUILD_ID", - "OUT_DIR", - "AUX_OS_VARIANT_LIST", - "TARGET_BUILD_PDK", - "PDK_FUSION_PLATFORM_ZIP", - } - allVars := append(append([]string{ // Used to execute Kati and Ninja "NINJA_GOALS", @@ -135,7 +150,7 @@ func runMakeProductConfig(ctx Context, config Config) { // To find target/product/<DEVICE> "TARGET_DEVICE", - }, exportEnvVars...), bannerVars...) + }, exportEnvVars...), BannerVars...) make_vars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true) if err != nil { @@ -143,13 +158,7 @@ func runMakeProductConfig(ctx Context, config Config) { } // Print the banner like make does - fmt.Fprintln(ctx.Stdout(), "============================================") - for _, name := range bannerVars { - if make_vars[name] != "" { - fmt.Fprintf(ctx.Stdout(), "%s=%s\n", name, make_vars[name]) - } - } - fmt.Fprintln(ctx.Stdout(), "============================================") + fmt.Fprintln(ctx.Stdout(), Banner(make_vars)) // Populate the environment env := config.Environment() |