Merge "Use ccCmd to generate clang-tidy dependent file"
This commit is contained in:
commit
935ae2c51d
1 changed files with 24 additions and 10 deletions
|
@ -199,8 +199,18 @@ var (
|
|||
// Rule for invoking clang-tidy (a clang-based linter).
|
||||
clangTidy, clangTidyRE = pctx.RemoteStaticRules("clangTidy",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f $out && $tidyVars $reTemplate${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && touch $out",
|
||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
||||
Depfile: "${out}.d",
|
||||
Deps: blueprint.DepsGCC,
|
||||
// Pick bash because some machines with old /bin/sh cannot handle arrays.
|
||||
// All $cFlags and $tidyFlags should have single quotes escaped.
|
||||
// Assume no single quotes in other parameters like $in, $out, $ccCmd.
|
||||
Command: "/bin/bash -c 'SRCF=$in; TIDYF=$out; CLANGFLAGS=($cFlags); " +
|
||||
"rm -f $$TIDYF $${TIDYF}.d && " +
|
||||
"${config.CcWrapper}$ccCmd \"$${CLANGFLAGS[@]}\" -E -o /dev/null $$SRCF " +
|
||||
"-MQ $$TIDYF -MD -MF $${TIDYF}.d && " +
|
||||
"$tidyVars $reTemplate${config.ClangBin}/clang-tidy $tidyFlags $$SRCF " +
|
||||
"-- \"$${CLANGFLAGS[@]}\" && touch $$TIDYF'",
|
||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy", "$ccCmd"},
|
||||
},
|
||||
&remoteexec.REParams{
|
||||
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
||||
|
@ -214,7 +224,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{"ccCmd", "cFlags", "tidyFlags", "tidyVars"}, []string{})
|
||||
|
||||
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
||||
|
||||
|
@ -437,6 +447,12 @@ func (a Objects) Append(b Objects) Objects {
|
|||
}
|
||||
}
|
||||
|
||||
func escapeSingleQuotes(s string) string {
|
||||
// Replace single quotes to work when embedded in a single quoted string for bash.
|
||||
// Relying on string concatenation of bash to get A'B from quoted 'A'\''B'.
|
||||
return strings.Replace(s, `'`, `'\''`, -1)
|
||||
}
|
||||
|
||||
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
|
||||
func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths,
|
||||
flags builderFlags, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
|
||||
|
@ -672,14 +688,12 @@ func transformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
Description: "clang-tidy " + srcFile.Rel(),
|
||||
Output: tidyFile,
|
||||
Input: srcFile,
|
||||
// We must depend on objFile, since clang-tidy doesn't
|
||||
// support exporting dependencies.
|
||||
Implicit: objFile,
|
||||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Implicits: cFlagsDeps,
|
||||
OrderOnly: pathDeps,
|
||||
Args: map[string]string{
|
||||
"cFlags": shareFlags("cFlags", moduleToolingFlags),
|
||||
"tidyFlags": shareFlags("tidyFlags", config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags)),
|
||||
"ccCmd": ccCmd,
|
||||
"cFlags": shareFlags("cFlags", escapeSingleQuotes(moduleToolingFlags)),
|
||||
"tidyFlags": shareFlags("tidyFlags", escapeSingleQuotes(config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags))),
|
||||
"tidyVars": tidyVars, // short and not shared
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue