Merge "Use single clang-tidy build rule and clang-tidy.sh"
This commit is contained in:
commit
b12ae4f2bd
1 changed files with 16 additions and 42 deletions
|
@ -202,36 +202,22 @@ var (
|
|||
},
|
||||
"clangBin", "format")
|
||||
|
||||
// Rule for invoking clang-tidy (a clang-based linter).
|
||||
clangTidyDep, clangTidyDepRE = pctx.RemoteStaticRules("clangTidyDep",
|
||||
blueprint.RuleParams{
|
||||
Depfile: "$out",
|
||||
Deps: blueprint.DepsGCC,
|
||||
Command: "${config.CcWrapper}$ccCmd $cFlags -E -o /dev/null $in " +
|
||||
"-MQ $tidyFile -MD -MF $out",
|
||||
CommandDeps: []string{"$ccCmd"},
|
||||
},
|
||||
&remoteexec.REParams{
|
||||
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
||||
ExecStrategy: "${config.REClangTidyExecStrategy}",
|
||||
Inputs: []string{"$in"},
|
||||
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
||||
}, []string{"ccCmd", "cFlags", "tidyFile"}, []string{})
|
||||
|
||||
// Rules for invoking clang-tidy (a clang-based linter).
|
||||
clangTidy, clangTidyRE = pctx.RemoteStaticRules("clangTidy",
|
||||
blueprint.RuleParams{
|
||||
Depfile: "${out}.d",
|
||||
Deps: blueprint.DepsGCC,
|
||||
Command: "cp ${out}.dep ${out}.d && " +
|
||||
"$tidyVars$reTemplate${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && " +
|
||||
"touch $out",
|
||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
||||
Command: "CLANG_CMD=$clangCmd TIDY_FILE=$out " +
|
||||
"$tidyVars$reTemplate${config.ClangBin}/clang-tidy.sh $in $tidyFlags -- $cFlags",
|
||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy.sh", "$ccCmd", "$tidyCmd"},
|
||||
},
|
||||
&remoteexec.REParams{
|
||||
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
||||
ExecStrategy: "${config.REClangTidyExecStrategy}",
|
||||
Inputs: []string{"$in", "${out}.dep"},
|
||||
EnvironmentVariables: []string{"TIDY_TIMEOUT"},
|
||||
Inputs: []string{"$in"},
|
||||
OutputFiles: []string{"${out}", "${out}.d"},
|
||||
ToolchainInputs: []string{"$ccCmd", "$tidyCmd"},
|
||||
EnvironmentVariables: []string{"CLANG_CMD", "TIDY_FILE", "TIDY_TIMEOUT"},
|
||||
// Although clang-tidy has an option to "fix" source files, that feature is hardly useable
|
||||
// under parallel compilation and RBE. So we assume no OutputFiles here.
|
||||
// The clang-tidy fix option is best run locally in single thread.
|
||||
|
@ -239,7 +225,7 @@ var (
|
|||
// (1) New timestamps trigger clang and clang-tidy compilations again.
|
||||
// (2) Changing source files caused concurrent clang or clang-tidy jobs to crash.
|
||||
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
||||
}, []string{"cFlags", "tidyFlags", "tidyVars"}, []string{})
|
||||
}, []string{"cFlags", "ccCmd", "clangCmd", "tidyCmd", "tidyFlags", "tidyVars"}, []string{})
|
||||
|
||||
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
||||
|
||||
|
@ -636,6 +622,7 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||
continue
|
||||
}
|
||||
|
||||
// ccCmd is "clang" or "clang++"
|
||||
ccDesc := ccCmd
|
||||
|
||||
ccCmd = "${config.ClangBin}/" + ccCmd
|
||||
|
@ -681,43 +668,30 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||
// Even with tidy, some src file could be skipped by noTidySrcsMap.
|
||||
if tidy && !noTidySrcsMap[srcFile.String()] {
|
||||
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
|
||||
tidyDepFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy.dep")
|
||||
tidyFiles = append(tidyFiles, tidyFile)
|
||||
tidyCmd := "${config.ClangBin}/clang-tidy"
|
||||
|
||||
ruleDep := clangTidyDep
|
||||
rule := clangTidy
|
||||
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
|
||||
ruleDep = clangTidyDepRE
|
||||
rule = clangTidyRE
|
||||
}
|
||||
|
||||
sharedCFlags := shareFlags("cFlags", moduleFlags)
|
||||
srcRelPath := srcFile.Rel()
|
||||
|
||||
// Add the .tidy.d rule
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: ruleDep,
|
||||
Description: "clang-tidy-dep " + srcRelPath,
|
||||
Output: tidyDepFile,
|
||||
Input: srcFile,
|
||||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"ccCmd": ccCmd,
|
||||
"cFlags": sharedCFlags,
|
||||
"tidyFile": tidyFile.String(),
|
||||
},
|
||||
})
|
||||
// Add the .tidy rule with order only dependency on the .tidy.d file
|
||||
// Add the .tidy rule
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: rule,
|
||||
Description: "clang-tidy " + srcRelPath,
|
||||
Output: tidyFile,
|
||||
Input: srcFile,
|
||||
Implicits: cFlagsDeps,
|
||||
OrderOnly: append(android.Paths{}, tidyDepFile),
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": sharedCFlags,
|
||||
"ccCmd": ccCmd,
|
||||
"clangCmd": ccDesc,
|
||||
"tidyCmd": tidyCmd,
|
||||
"tidyFlags": shareFlags("tidyFlags", config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags)),
|
||||
"tidyVars": tidyVars, // short and not shared
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue