aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler_wrapper/android_config_test.go13
-rw-r--r--compiler_wrapper/bisect_flag_test.go2
-rw-r--r--compiler_wrapper/clang_flags.go9
-rw-r--r--compiler_wrapper/command.go3
-rw-r--r--compiler_wrapper/compile_with_fallback_test.go2
-rw-r--r--compiler_wrapper/compiler_wrapper.go30
-rw-r--r--compiler_wrapper/testdata/android_golden/clang_path.json48
7 files changed, 89 insertions, 18 deletions
diff --git a/compiler_wrapper/android_config_test.go b/compiler_wrapper/android_config_test.go
index 4e2f1f5c..104be6df 100644
--- a/compiler_wrapper/android_config_test.go
+++ b/compiler_wrapper/android_config_test.go
@@ -35,6 +35,7 @@ func createAndroidClangPathGoldenInputs(ctx *testContext) goldenFile {
gomaPath := path.Join(ctx.tempDir, "gomacc")
ctx.writeFile(gomaPath, "")
defaultPath := filepath.Join(ctx.tempDir, "clang")
+ clangTidyPath := filepath.Join(ctx.tempDir, "clang-tidy")
deepPath := "a/b/c/d/e/f/g/clang"
linkedDeepPath := "symlinked/clang_other"
@@ -52,11 +53,21 @@ func createAndroidClangPathGoldenInputs(ctx *testContext) goldenFile {
Cmds: errorResults,
},
{
+ Env: []string{"WITH_TIDY=1"},
+ WrapperCmd: newGoldenCmd(defaultPath, mainCc),
+ Cmds: okResults,
+ },
+ {
WrapperCmd: newGoldenCmd(filepath.Join(ctx.tempDir, "clang++"), mainCc),
Cmds: okResults,
},
{
- WrapperCmd: newGoldenCmd(filepath.Join(ctx.tempDir, "clang-tidy"), mainCc),
+ WrapperCmd: newGoldenCmd(clangTidyPath, mainCc),
+ Cmds: okResults,
+ },
+ {
+ Env: []string{"WITH_TIDY=1"},
+ WrapperCmd: newGoldenCmd(clangTidyPath, mainCc),
Cmds: okResults,
},
{
diff --git a/compiler_wrapper/bisect_flag_test.go b/compiler_wrapper/bisect_flag_test.go
index 8500eef2..0bb6a820 100644
--- a/compiler_wrapper/bisect_flag_test.go
+++ b/compiler_wrapper/bisect_flag_test.go
@@ -85,7 +85,7 @@ func TestDefaultBisectDirAndroid(t *testing.T) {
"HOME=/somehome",
}
ctx.cfg.isAndroidWrapper = true
- cmd := mustCallBisectDriver(ctx, callCompiler(ctx, ctx.cfg, ctx.newCommand(gccX86_64, mainCc)))
+ cmd := mustCallBisectDriver(ctx, callCompiler(ctx, ctx.cfg, ctx.newCommand(clangAndroid, mainCc)))
if err := verifyArgOrder(cmd,
"someBisectStage", filepath.Join("/somehome", "ANDROID_BISECT")); err != nil {
t.Error(err)
diff --git a/compiler_wrapper/clang_flags.go b/compiler_wrapper/clang_flags.go
index ee041a2e..8b76e965 100644
--- a/compiler_wrapper/clang_flags.go
+++ b/compiler_wrapper/clang_flags.go
@@ -12,15 +12,6 @@ import (
)
func processClangFlags(builder *commandBuilder) error {
- if builder.cfg.isAndroidWrapper {
- // FIXME: This combination of using the directory of the symlink but the
- // basename of the link target is strange but is the logic that old android
- // wrapper uses. Change this to use directory and basename either from the
- // absWrapperPath or from the builder.path, but don't mix anymore.
- builder.path = filepath.Join(filepath.Dir(builder.path), filepath.Base(builder.absWrapperPath)+".real")
- return nil
- }
-
env := builder.env
clangDir, _ := env.getenv("CLANG")
diff --git a/compiler_wrapper/command.go b/compiler_wrapper/command.go
index 26f85568..69578597 100644
--- a/compiler_wrapper/command.go
+++ b/compiler_wrapper/command.go
@@ -129,6 +129,8 @@ func newCommandBuilder(env env, cfg *config, cmd *command) (*commandBuilder, err
var compilerType compilerType
switch {
+ case strings.HasPrefix(target.compiler, "clang-tidy"):
+ compilerType = clangTidyType
case strings.HasPrefix(target.compiler, "clang"):
compilerType = clangType
default:
@@ -172,6 +174,7 @@ type compilerType int32
const (
gccType compilerType = iota
clangType
+ clangTidyType
)
type builderTarget struct {
diff --git a/compiler_wrapper/compile_with_fallback_test.go b/compiler_wrapper/compile_with_fallback_test.go
index 32d1915b..4ea847f6 100644
--- a/compiler_wrapper/compile_with_fallback_test.go
+++ b/compiler_wrapper/compile_with_fallback_test.go
@@ -169,7 +169,7 @@ func TestCompileWithFallbackExtraArgs(t *testing.T) {
}{
{"./clang", true},
{"./clang++", true},
- {"./some_clang", false},
+ {"./clang-tidy", false},
}
ctx.env = append(ctx.env, "ANDROID_LLVM_FALLBACK_DISABLED_WARNINGS=-a -b")
extraArgs := []string{"-fno-color-diagnostics", "-a", "-b"}
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go
index b157687f..17c62db7 100644
--- a/compiler_wrapper/compiler_wrapper.go
+++ b/compiler_wrapper/compiler_wrapper.go
@@ -71,7 +71,27 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int
env = mainBuilder.env
var compilerCmd *command
clangSyntax := processClangSyntaxFlag(mainBuilder)
- if mainBuilder.target.compilerType == clangType {
+ if cfg.isAndroidWrapper {
+ // FIXME: This combination of using the directory of the symlink but the
+ // basename of the link target is strange but is the logic that old android
+ // wrapper uses. Change this to use directory and basename either from the
+ // absWrapperPath or from the builder.path, but don't mix anymore.
+ mainBuilder.path = filepath.Join(filepath.Dir(mainBuilder.path), filepath.Base(mainBuilder.absWrapperPath)+".real")
+
+ switch mainBuilder.target.compilerType {
+ case clangType:
+ mainBuilder.addPreUserArgs(mainBuilder.cfg.clangFlags...)
+ mainBuilder.addPreUserArgs(mainBuilder.cfg.commonFlags...)
+ if _, err := processGomaCccFlags(mainBuilder); err != nil {
+ return 0, err
+ }
+ compilerCmd = mainBuilder.build()
+ case clangTidyType:
+ compilerCmd = mainBuilder.build()
+ default:
+ return 0, newErrorwithSourceLocf("unsupported compiler: %s", mainBuilder.target.compiler)
+ }
+ } else if mainBuilder.target.compilerType == clangType {
cSrcFile, useClangTidy := processClangTidyFlags(mainBuilder)
sysroot, err := prepareClangCommand(mainBuilder)
if err != nil {
@@ -146,7 +166,7 @@ func callCompilerInternal(env env, cfg *config, inputCmd *command) (exitCode int
func prepareClangCommand(builder *commandBuilder) (sysroot string, err error) {
sysroot = ""
- if !builder.cfg.isHostWrapper && !builder.cfg.isAndroidWrapper {
+ if !builder.cfg.isHostWrapper {
sysroot = processSysrootFlag(builder)
}
builder.addPreUserArgs(builder.cfg.clangFlags...)
@@ -189,15 +209,13 @@ func calcGccCommand(builder *commandBuilder) (*command, error) {
func calcCommonPreUserArgs(builder *commandBuilder) {
builder.addPreUserArgs(builder.cfg.commonFlags...)
- if !builder.cfg.isHostWrapper && !builder.cfg.isAndroidWrapper {
+ if !builder.cfg.isHostWrapper {
processPieFlags(builder)
processThumbCodeFlags(builder)
processStackProtectorFlags(builder)
processX86Flags(builder)
}
- if !builder.cfg.isAndroidWrapper {
- processSanitizerFlags(builder)
- }
+ processSanitizerFlags(builder)
}
func processGomaCCacheFlags(sysroot string, allowCCache bool, builder *commandBuilder) (err error) {
diff --git a/compiler_wrapper/testdata/android_golden/clang_path.json b/compiler_wrapper/testdata/android_golden/clang_path.json
index b784feb5..5686b381 100644
--- a/compiler_wrapper/testdata/android_golden/clang_path.json
+++ b/compiler_wrapper/testdata/android_golden/clang_path.json
@@ -49,6 +49,30 @@
},
{
"wd": "/tmp/stable",
+ "env": [
+ "WITH_TIDY=1"
+ ],
+ "wrapper": {
+ "cmd": {
+ "path": "/tmp/stable/clang",
+ "args": [
+ "main.cc"
+ ]
+ }
+ },
+ "cmds": [
+ {
+ "cmd": {
+ "path": "/tmp/stable/clang.real",
+ "args": [
+ "main.cc"
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "wd": "/tmp/stable",
"wrapper": {
"cmd": {
"path": "/tmp/stable/clang++",
@@ -91,6 +115,30 @@
},
{
"wd": "/tmp/stable",
+ "env": [
+ "WITH_TIDY=1"
+ ],
+ "wrapper": {
+ "cmd": {
+ "path": "/tmp/stable/clang-tidy",
+ "args": [
+ "main.cc"
+ ]
+ }
+ },
+ "cmds": [
+ {
+ "cmd": {
+ "path": "/tmp/stable/clang-tidy.real",
+ "args": [
+ "main.cc"
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "wd": "/tmp/stable",
"wrapper": {
"cmd": {
"path": "a/b/c/d/e/f/g/clang",