diff options
author | Dan Willemsen <dwillemsen@google.com> | 2016-05-19 16:58:46 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2016-05-20 00:19:14 -0700 |
commit | 558e517ae99d018305a45da6f46ee2a53f47c928 (patch) | |
tree | 5751bde31417be4b7844ed772c4bf8d042ec3a1f /android | |
parent | d87145fe0560f8a5f6a1b5d0e90c8dde30ee66cb (diff) | |
download | build_soong-558e517ae99d018305a45da6f46ee2a53f47c928.tar.gz build_soong-558e517ae99d018305a45da6f46ee2a53f47c928.tar.bz2 build_soong-558e517ae99d018305a45da6f46ee2a53f47c928.zip |
Check more Make variables
Some more common makevars methods were required in order to remove the
"-isystem" prefixes from the toolchain.IncludeFlags() value. In Make,
the -isystem is prepended at time of use, not in TARGET_C_INCLUDES
itself.
Change-Id: If07e69ddb7357d11c7dd48ab60f503d219f29de8
Diffstat (limited to 'android')
-rw-r--r-- | android/makevars.go | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/android/makevars.go b/android/makevars.go index d9c5c6d7..149f2f88 100644 --- a/android/makevars.go +++ b/android/makevars.go @@ -44,6 +44,17 @@ type MakeVarsContext interface { // string. StrictSorted(name, ninjaStr string) CheckSorted(name, ninjaStr string) + + // Evaluates a ninja string and returns the result. Used if more + // complicated modification needs to happen before giving it to Make. + Eval(ninjaStr string) (string, error) + + // These are equivalent to Strict and Check, but do not attempt to + // evaluate the values before writing them to the Makefile. They can + // be used when all ninja variables have already been evaluated through + // Eval(). + StrictRaw(name, value string) + CheckRaw(name, value string) } type MakeVarsProvider func(ctx MakeVarsContext) @@ -146,7 +157,7 @@ func (s *makeVarsSingleton) writeVars(vars []makeVarsVariable) []byte { # $(3): Extra snippet to run if it does not match define soong-compare-var ifneq ($$($(1)),) - my_val_make := $(if $(2),$$(sort $$($(1))),$$($(1))) + my_val_make := $$(strip $(if $(2),$$(sort $$($(1))),$$($(1)))) my_val_soong := $(if $(2),$$(sort $$(SOONG_$(1))),$$(SOONG_$(1))) ifneq ($$(my_val_make),$$(my_val_soong)) $$(warning $(1) does not match between Make and Soong:) @@ -214,11 +225,11 @@ func (c *makeVarsContext) Config() Config { return c.config } -func (c *makeVarsContext) addVariable(name, ninjaStr string, strict, sort bool) { - value, err := c.ctx.Eval(c.pctx, ninjaStr) - if err != nil { - c.ctx.Errorf(err.Error()) - } +func (c *makeVarsContext) Eval(ninjaStr string) (string, error) { + return c.ctx.Eval(c.pctx, ninjaStr) +} + +func (c *makeVarsContext) addVariableRaw(name, value string, strict, sort bool) { c.vars = append(c.vars, makeVarsVariable{ name: name, value: value, @@ -227,12 +238,23 @@ func (c *makeVarsContext) addVariable(name, ninjaStr string, strict, sort bool) }) } +func (c *makeVarsContext) addVariable(name, ninjaStr string, strict, sort bool) { + value, err := c.Eval(ninjaStr) + if err != nil { + c.ctx.Errorf(err.Error()) + } + c.addVariableRaw(name, value, strict, sort) +} + func (c *makeVarsContext) Strict(name, ninjaStr string) { c.addVariable(name, ninjaStr, true, false) } func (c *makeVarsContext) StrictSorted(name, ninjaStr string) { c.addVariable(name, ninjaStr, true, true) } +func (c *makeVarsContext) StrictRaw(name, value string) { + c.addVariableRaw(name, value, true, false) +} func (c *makeVarsContext) Check(name, ninjaStr string) { c.addVariable(name, ninjaStr, false, false) @@ -240,3 +262,6 @@ func (c *makeVarsContext) Check(name, ninjaStr string) { func (c *makeVarsContext) CheckSorted(name, ninjaStr string) { c.addVariable(name, ninjaStr, false, true) } +func (c *makeVarsContext) CheckRaw(name, value string) { + c.addVariableRaw(name, value, false, false) +} |