From ac5e1cb30fd05bfb10caee517521fd512fc6bd49 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Tue, 12 Jan 2016 16:22:40 -0800 Subject: Change clang extra flags behavior Move the clang extra flags into the *ClangGlobal*flags variables, instead of adding them to every clang-based module. This means that they're only applied when !no_default_compiler_flags, like make. Change-Id: I43b1378d1d932d9aecfd8724a492d0d7716f7631 --- cc/cc.go | 14 +++++--------- cc/clang.go | 10 ++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/cc/cc.go b/cc/cc.go index ce3a464c..c8341d4c 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -115,13 +115,13 @@ func init() { pctx.StaticVariable("commonGlobalCppflags", strings.Join(commonGlobalCppflags, " ")) pctx.StaticVariable("commonClangGlobalCflags", - strings.Join(clangFilterUnknownCflags(commonGlobalCflags), " ")) + strings.Join(append(clangFilterUnknownCflags(commonGlobalCflags), "${clangExtraCflags}"), " ")) pctx.StaticVariable("deviceClangGlobalCflags", - strings.Join(clangFilterUnknownCflags(deviceGlobalCflags), " ")) + strings.Join(append(clangFilterUnknownCflags(deviceGlobalCflags), "${clangExtraTargetCflags}"), " ")) pctx.StaticVariable("hostClangGlobalCflags", strings.Join(clangFilterUnknownCflags(hostGlobalCflags), " ")) pctx.StaticVariable("commonClangGlobalCppflags", - strings.Join(clangFilterUnknownCflags(commonGlobalCppflags), " ")) + strings.Join(append(clangFilterUnknownCflags(commonGlobalCppflags), "${clangExtraCppflags}"), " ")) // Everything in this list is a crime against abstraction and dependency tracking. // Do not add anything to this list. @@ -550,12 +550,6 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha flags.ConlyFlags = clangFilterUnknownCflags(flags.ConlyFlags) flags.LdFlags = clangFilterUnknownCflags(flags.LdFlags) - flags.CFlags = append(flags.CFlags, "${clangExtraCflags}") - flags.ConlyFlags = append(flags.ConlyFlags, "${clangExtraConlyflags}") - if ctx.Device() { - flags.CFlags = append(flags.CFlags, "${clangExtraTargetCflags}") - } - target := "-target " + toolchain.ClangTriple() gccPrefix := "-B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin") @@ -577,6 +571,8 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha toolchain.ClangCflags(), "${commonClangGlobalCflags}", fmt.Sprintf("${%sClangGlobalCflags}", ctx.HostOrDevice())) + + flags.ConlyFlags = append(flags.ConlyFlags, "${clangExtraConlyflags}") } else { flags.CppFlags = append(flags.CppFlags, "${commonGlobalCppflags}") flags.GlobalFlags = append(flags.GlobalFlags, diff --git a/cc/clang.go b/cc/clang.go index 6a01010d..5e0302a5 100644 --- a/cc/clang.go +++ b/cc/clang.go @@ -84,10 +84,6 @@ func init() { // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html. "-Wno-unused-command-line-argument", - // Disable -Winconsistent-missing-override until we can clean up the existing - // codebase for it. - "-Wno-inconsistent-missing-override", - // Force clang to always output color diagnostics. Ninja will strip the ANSI // color codes if it is not running in a terminal. "-fcolor-diagnostics", @@ -97,6 +93,12 @@ func init() { "-std=gnu99", }, " ")) + pctx.StaticVariable("clangExtraCppflags", strings.Join([]string{ + // Disable -Winconsistent-missing-override until we can clean up the existing + // codebase for it. + "-Wno-inconsistent-missing-override", + }, " ")) + pctx.StaticVariable("clangExtraTargetCflags", strings.Join([]string{ "-nostdlibinc", }, " ")) -- cgit v1.2.3