Rename exported make variables for system headers
Add SYSTEM_ to variables that contain headers that are used with -isystem, and split -I and -isystem variables into separate make variables. Also export SRC_HEADERS and SRC_SYSTEM_HEADERS to compare against make. Change-Id: I02097c35d1d5342ebce8311d8878fff33b118adb
This commit is contained in:
parent
3d92b27717
commit
10c78c6b97
1 changed files with 47 additions and 1 deletions
|
@ -42,6 +42,14 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
|||
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
||||
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
||||
|
||||
includeFlags, err := ctx.Eval("${commonGlobalIncludes}")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
includes, systemIncludes := splitSystemIncludes(ctx, includeFlags)
|
||||
ctx.StrictRaw("SRC_HEADERS", strings.Join(includes, " "))
|
||||
ctx.StrictRaw("SRC_SYSTEM_HEADERS", strings.Join(systemIncludes, " "))
|
||||
|
||||
hostTargets := ctx.Config().Targets[android.Host]
|
||||
makeVarsToolchain(ctx, "", hostTargets[0])
|
||||
if len(hostTargets) > 1 {
|
||||
|
@ -115,7 +123,9 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ctx.StrictRaw(makePrefix+"C_INCLUDES", strings.Replace(includeFlags, "-isystem ", "", -1))
|
||||
includes, systemIncludes := splitSystemIncludes(ctx, includeFlags)
|
||||
ctx.StrictRaw(makePrefix+"C_INCLUDES", strings.Join(includes, " "))
|
||||
ctx.StrictRaw(makePrefix+"C_SYSTEM_INCLUDES", strings.Join(systemIncludes, " "))
|
||||
|
||||
if target.Arch.ArchType == android.Arm {
|
||||
flags, err := toolchain.InstructionSetFlags("arm")
|
||||
|
@ -195,3 +205,39 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
|||
ctx.Strict(makePrefix+"SHLIB_SUFFIX", toolchain.ShlibSuffix())
|
||||
ctx.Strict(makePrefix+"EXECUTABLE_SUFFIX", toolchain.ExecutableSuffix())
|
||||
}
|
||||
|
||||
func splitSystemIncludes(ctx android.MakeVarsContext, val string) (includes, systemIncludes []string) {
|
||||
flags, err := ctx.Eval(val)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
extract := func(flags string, dirs []string, prefix string) (string, []string, bool) {
|
||||
if strings.HasPrefix(flags, prefix) {
|
||||
flags = strings.TrimPrefix(flags, prefix)
|
||||
flags = strings.TrimLeft(flags, " ")
|
||||
s := strings.SplitN(flags, " ", 2)
|
||||
dirs = append(dirs, s[0])
|
||||
if len(s) > 1 {
|
||||
return strings.TrimLeft(s[1], " "), dirs, true
|
||||
}
|
||||
return "", dirs, true
|
||||
} else {
|
||||
return flags, dirs, false
|
||||
}
|
||||
}
|
||||
|
||||
flags = strings.TrimLeft(flags, " ")
|
||||
for flags != "" {
|
||||
found := false
|
||||
flags, includes, found = extract(flags, includes, "-I")
|
||||
if !found {
|
||||
flags, systemIncludes, found = extract(flags, systemIncludes, "-isystem ")
|
||||
}
|
||||
if !found {
|
||||
panic(fmt.Errorf("Unexpected flag in %q", flags))
|
||||
}
|
||||
}
|
||||
|
||||
return includes, systemIncludes
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue