Port GLOBAL[_CLANG]_CFLAGS_NO_OVERRIDE from make

Change-Id: I4f0f8ec7620e4477f60bf9cf1ae0c005470c89d4
This commit is contained in:
Dan Willemsen
2016-03-03 17:21:04 -08:00
parent f778e12c57
commit be03f346b3
3 changed files with 23 additions and 0 deletions

View File

@@ -149,6 +149,14 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
cppflags := flags.globalFlags + " " + flags.cFlags + " " + flags.cppFlags
asflags := flags.globalFlags + " " + flags.asFlags
if flags.clang {
cflags += " ${noOverrideClangGlobalCflags}"
cppflags += " ${noOverrideClangGlobalCflags}"
} else {
cflags += " ${noOverrideGlobalCflags}"
cppflags += " ${noOverrideGlobalCflags}"
}
for i, srcFile := range srcFiles {
objFile := common.ObjPathWithExt(ctx, srcFile, subdir, "o")

View File

@@ -103,6 +103,11 @@ var (
"-Wsign-promo",
}
noOverrideGlobalCflags = []string{
"-Werror=int-to-pointer-cast",
"-Werror=pointer-to-int-cast",
}
illegalFlags = []string{
"-w",
}
@@ -112,6 +117,7 @@ func init() {
pctx.StaticVariable("commonGlobalCflags", strings.Join(commonGlobalCflags, " "))
pctx.StaticVariable("deviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
pctx.StaticVariable("hostGlobalCflags", strings.Join(hostGlobalCflags, " "))
pctx.StaticVariable("noOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
pctx.StaticVariable("commonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
@@ -121,6 +127,9 @@ func init() {
strings.Join(append(clangFilterUnknownCflags(deviceGlobalCflags), "${clangExtraTargetCflags}"), " "))
pctx.StaticVariable("hostClangGlobalCflags",
strings.Join(clangFilterUnknownCflags(hostGlobalCflags), " "))
pctx.StaticVariable("noOverrideClangGlobalCflags",
strings.Join(append(clangFilterUnknownCflags(noOverrideGlobalCflags), "${clangExtraNoOverrideCflags}"), " "))
pctx.StaticVariable("commonClangGlobalCppflags",
strings.Join(append(clangFilterUnknownCflags(commonGlobalCppflags), "${clangExtraCppflags}"), " "))

View File

@@ -101,6 +101,12 @@ func init() {
pctx.StaticVariable("clangExtraTargetCflags", strings.Join([]string{
"-nostdlibinc",
}, " "))
pctx.StaticVariable("clangExtraNoOverrideCflags", strings.Join([]string{
"-Werror=address-of-temporary",
"-Werror=null-dereference",
"-Werror=return-type",
}, " "))
}
func clangFilterUnknownCflags(cflags []string) []string {