Merge "Use single clang-tidy build rule and clang-tidy.sh" am: b12ae4f2bd
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2110906 Change-Id: I1815369476f2e43e0fccf5c2993878a00d33f799 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -202,36 +202,22 @@ var (
|
|||||||
},
|
},
|
||||||
"clangBin", "format")
|
"clangBin", "format")
|
||||||
|
|
||||||
// Rule for invoking clang-tidy (a clang-based linter).
|
// Rules 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{})
|
|
||||||
|
|
||||||
clangTidy, clangTidyRE = pctx.RemoteStaticRules("clangTidy",
|
clangTidy, clangTidyRE = pctx.RemoteStaticRules("clangTidy",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Depfile: "${out}.d",
|
Depfile: "${out}.d",
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Command: "cp ${out}.dep ${out}.d && " +
|
Command: "CLANG_CMD=$clangCmd TIDY_FILE=$out " +
|
||||||
"$tidyVars$reTemplate${config.ClangBin}/clang-tidy $tidyFlags $in -- $cFlags && " +
|
"$tidyVars$reTemplate${config.ClangBin}/clang-tidy.sh $in $tidyFlags -- $cFlags",
|
||||||
"touch $out",
|
CommandDeps: []string{"${config.ClangBin}/clang-tidy.sh", "$ccCmd", "$tidyCmd"},
|
||||||
CommandDeps: []string{"${config.ClangBin}/clang-tidy"},
|
|
||||||
},
|
},
|
||||||
&remoteexec.REParams{
|
&remoteexec.REParams{
|
||||||
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
Labels: map[string]string{"type": "lint", "tool": "clang-tidy", "lang": "cpp"},
|
||||||
ExecStrategy: "${config.REClangTidyExecStrategy}",
|
ExecStrategy: "${config.REClangTidyExecStrategy}",
|
||||||
Inputs: []string{"$in", "${out}.dep"},
|
Inputs: []string{"$in"},
|
||||||
EnvironmentVariables: []string{"TIDY_TIMEOUT"},
|
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
|
// 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.
|
// under parallel compilation and RBE. So we assume no OutputFiles here.
|
||||||
// The clang-tidy fix option is best run locally in single thread.
|
// 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.
|
// (1) New timestamps trigger clang and clang-tidy compilations again.
|
||||||
// (2) Changing source files caused concurrent clang or clang-tidy jobs to crash.
|
// (2) Changing source files caused concurrent clang or clang-tidy jobs to crash.
|
||||||
Platform: map[string]string{remoteexec.PoolKey: "${config.REClangTidyPool}"},
|
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")
|
_ = pctx.SourcePathVariable("yasmCmd", "prebuilts/misc/${config.HostPrebuiltTag}/yasm/yasm")
|
||||||
|
|
||||||
@@ -636,6 +622,7 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ccCmd is "clang" or "clang++"
|
||||||
ccDesc := ccCmd
|
ccDesc := ccCmd
|
||||||
|
|
||||||
ccCmd = "${config.ClangBin}/" + 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.
|
// Even with tidy, some src file could be skipped by noTidySrcsMap.
|
||||||
if tidy && !noTidySrcsMap[srcFile.String()] {
|
if tidy && !noTidySrcsMap[srcFile.String()] {
|
||||||
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
|
tidyFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy")
|
||||||
tidyDepFile := android.ObjPathWithExt(ctx, subdir, srcFile, "tidy.dep")
|
|
||||||
tidyFiles = append(tidyFiles, tidyFile)
|
tidyFiles = append(tidyFiles, tidyFile)
|
||||||
|
tidyCmd := "${config.ClangBin}/clang-tidy"
|
||||||
|
|
||||||
ruleDep := clangTidyDep
|
|
||||||
rule := clangTidy
|
rule := clangTidy
|
||||||
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
|
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CLANG_TIDY") {
|
||||||
ruleDep = clangTidyDepRE
|
|
||||||
rule = clangTidyRE
|
rule = clangTidyRE
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedCFlags := shareFlags("cFlags", moduleFlags)
|
sharedCFlags := shareFlags("cFlags", moduleFlags)
|
||||||
srcRelPath := srcFile.Rel()
|
srcRelPath := srcFile.Rel()
|
||||||
|
|
||||||
// Add the .tidy.d rule
|
// Add the .tidy 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
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: rule,
|
Rule: rule,
|
||||||
Description: "clang-tidy " + srcRelPath,
|
Description: "clang-tidy " + srcRelPath,
|
||||||
Output: tidyFile,
|
Output: tidyFile,
|
||||||
Input: srcFile,
|
Input: srcFile,
|
||||||
Implicits: cFlagsDeps,
|
Implicits: cFlagsDeps,
|
||||||
OrderOnly: append(android.Paths{}, tidyDepFile),
|
OrderOnly: pathDeps,
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"cFlags": sharedCFlags,
|
"cFlags": sharedCFlags,
|
||||||
|
"ccCmd": ccCmd,
|
||||||
|
"clangCmd": ccDesc,
|
||||||
|
"tidyCmd": tidyCmd,
|
||||||
"tidyFlags": shareFlags("tidyFlags", config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags)),
|
"tidyFlags": shareFlags("tidyFlags", config.TidyFlagsForSrcFile(srcFile, flags.tidyFlags)),
|
||||||
"tidyVars": tidyVars, // short and not shared
|
"tidyVars": tidyVars, // short and not shared
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user