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
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
@@ -98,6 +98,22 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
||||
toolchain.ToolchainLdflags(),
|
||||
productExtraLdflags,
|
||||
}, " "))
|
||||
ctx.Strict(makePrefix+"SYSTEMCPP_CPPFLAGS", toolchain.SystemCppCppflags())
|
||||
ctx.Strict(makePrefix+"SYSTEMCPP_LDFLAGS", toolchain.SystemCppLdflags())
|
||||
|
||||
includeFlags, err := ctx.Eval(toolchain.IncludeFlags())
|
||||
if err != nil { panic(err) }
|
||||
ctx.StrictRaw(makePrefix+"C_INCLUDES", strings.Replace(includeFlags, "-isystem ", "", -1))
|
||||
|
||||
if arch.ArchType == android.Arm {
|
||||
flags, err := toolchain.InstructionSetFlags("arm")
|
||||
if err != nil { panic(err) }
|
||||
ctx.Strict(makePrefix+"arm_CFLAGS", flags)
|
||||
|
||||
flags, err = toolchain.InstructionSetFlags("thumb")
|
||||
if err != nil { panic(err) }
|
||||
ctx.Strict(makePrefix+"thumb_CFLAGS", flags)
|
||||
}
|
||||
|
||||
if toolchain.ClangSupported() {
|
||||
clangPrefix := secondPrefix + "CLANG_" + typePrefix
|
||||
@@ -125,6 +141,14 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
||||
productExtraLdflags,
|
||||
clangExtras,
|
||||
}, " "))
|
||||
|
||||
if hod.Device() {
|
||||
ctx.Strict(secondPrefix + "ADDRESS_SANITIZER_RUNTIME_LIBRARY", strings.TrimSuffix(toolchain.AddressSanitizerRuntimeLibrary(), ".so"))
|
||||
}
|
||||
|
||||
// This is used by external/gentoo/...
|
||||
ctx.Strict("CLANG_CONFIG_" + arch.ArchType.Name + "_" + typePrefix + "TRIPLE",
|
||||
toolchain.ClangTriple())
|
||||
}
|
||||
|
||||
ctx.Strict(makePrefix+"CC", gccCmd(toolchain, "gcc"))
|
||||
@@ -146,7 +170,11 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
||||
ctx.Strict(makePrefix+"OBJCOPY", gccCmd(toolchain, "objcopy"))
|
||||
ctx.Strict(makePrefix+"LD", gccCmd(toolchain, "ld"))
|
||||
ctx.Strict(makePrefix+"STRIP", gccCmd(toolchain, "strip"))
|
||||
ctx.Strict(makePrefix+"GCC_VERSION", toolchain.GccVersion())
|
||||
ctx.Strict(makePrefix+"NDK_GCC_VERSION", toolchain.GccVersion())
|
||||
}
|
||||
|
||||
ctx.Strict(makePrefix+"TOOLS_PREFIX", gccCmd(toolchain, ""))
|
||||
ctx.Strict(makePrefix+"SHLIB_SUFFIX", toolchain.ShlibSuffix())
|
||||
ctx.Strict(makePrefix+"EXECUTABLE_SUFFIX", toolchain.ExecutableSuffix())
|
||||
}
|
||||
|
Reference in New Issue
Block a user