From 6f03752422c466bec6c618cea7e4d77aac95ab69 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sun, 21 Oct 2018 09:20:47 -0700 Subject: [PATCH] Allow DIST_DIR to be read via dumpvars DIST_DIR is controlled by soong_ui, and the make dumpvars code no longer has access to it. So instead, handle some dumpvar requests inside soong_ui itself. Test: get_build_var DIST_DIR Test: get_build_var OUT_DIR Test: get_build_var BUILD_SYSTEM Test: build/soong/soong_ui.bash --dumpvars-mode --vars="DIST_DIR BUILD_SYSTEM" Change-Id: Id3bcb8b0748db67c83d0e42d1ae5be564c5eb2f7 --- ui/build/dumpvars.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go index bea08b67c..ad57d02bd 100644 --- a/ui/build/dumpvars.go +++ b/ui/build/dumpvars.go @@ -32,8 +32,40 @@ import ( // // vars is the list of variables to read. The values will be put in the // returned map. +// +// variables controlled by soong_ui directly are now returned without needing +// to call into make, to retain compatibility. func DumpMakeVars(ctx Context, config Config, goals, vars []string) (map[string]string, error) { - return dumpMakeVars(ctx, config, goals, vars, false) + soongUiVars := map[string]func() string{ + "OUT_DIR": func() string { return config.OutDir() }, + "DIST_DIR": func() string { return config.DistDir() }, + } + + makeVars := make([]string, 0, len(vars)) + for _, v := range vars { + if _, ok := soongUiVars[v]; !ok { + makeVars = append(makeVars, v) + } + } + + var ret map[string]string + if len(makeVars) > 0 { + var err error + ret, err = dumpMakeVars(ctx, config, goals, makeVars, false) + if err != nil { + return ret, err + } + } else { + ret = make(map[string]string) + } + + for _, v := range vars { + if f, ok := soongUiVars[v]; ok { + ret[v] = f() + } + } + + return ret, nil } func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_vars bool) (map[string]string, error) {