Merge "Add tidy_timeout_srcs property" am: 72518f45e9 am: 01ec0a21d2 am: 730f0b61c9

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1991252

Change-Id: I37fb415d2fcea042c45ea1b722cf0b6c596a2409
This commit is contained in:
Treehugger Robot 2022-02-18 22:09:14 +00:00 committed by Automerger Merge Worker
commit a7a2b3046b
5 changed files with 26 additions and 4 deletions

View file

@ -459,7 +459,7 @@ func (a Objects) Append(b Objects) Objects {
}
// Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files
func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs android.Paths,
func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs, timeoutTidySrcs android.Paths,
flags builderFlags, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
// Source files are one-to-one with tidy, coverage, or kythe files, if enabled.
objFiles := make(android.Paths, len(srcFiles))
@ -474,6 +474,10 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
tidyTimeout := ctx.Config().Getenv("TIDY_TIMEOUT")
if len(tidyTimeout) > 0 {
tidyVars += "TIDY_TIMEOUT=" + tidyTimeout + " "
// add timeoutTidySrcs into noTidySrcsMap if TIDY_TIMEOUT is set
for _, path := range timeoutTidySrcs {
noTidySrcsMap[path.String()] = true
}
}
}
var coverageFiles android.Paths

View file

@ -42,6 +42,9 @@ type BaseCompilerProperties struct {
// list of source files that should not be compiled with clang-tidy.
Tidy_disabled_srcs []string `android:"path,arch_variant"`
// list of source files that should not be compiled by clang-tidy when TIDY_TIMEOUT is set.
Tidy_timeout_srcs []string `android:"path,arch_variant"`
// list of source files that should not be used to build the C/C++ module.
// This is most useful in the arch/multilib variants to remove non-common files
Exclude_srcs []string `android:"path,arch_variant"`
@ -663,6 +666,7 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
// Compile files listed in c.Properties.Srcs into objects
objs := compileObjs(ctx, buildFlags, "", srcs,
android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_disabled_srcs),
android.PathsForModuleSrc(ctx, compiler.Properties.Tidy_timeout_srcs),
pathDeps, compiler.cFlagsDeps)
if ctx.Failed() {
@ -674,9 +678,9 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
// Compile a list of source files into objects a specified subdirectory
func compileObjs(ctx ModuleContext, flags builderFlags, subdir string,
srcFiles, noTidySrcs, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
srcFiles, noTidySrcs, timeoutTidySrcs, pathDeps android.Paths, cFlagsDeps android.Paths) Objects {
return transformSourceToObj(ctx, subdir, srcFiles, noTidySrcs, flags, pathDeps, cFlagsDeps)
return transformSourceToObj(ctx, subdir, srcFiles, noTidySrcs, timeoutTidySrcs, flags, pathDeps, cFlagsDeps)
}
// Properties for rust_bindgen related to generating rust bindings.

View file

@ -145,6 +145,8 @@ type StaticOrSharedProperties struct {
Tidy_disabled_srcs []string `android:"path,arch_variant"`
Tidy_timeout_srcs []string `android:"path,arch_variant"`
Sanitized Sanitized `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
@ -1079,11 +1081,13 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
srcs := android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, srcs,
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_disabled_srcs),
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_timeout_srcs),
library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
} else if library.shared() {
srcs := android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Srcs)
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, srcs,
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_disabled_srcs),
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_timeout_srcs),
library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
}

View file

@ -279,7 +279,7 @@ func parseNativeAbiDefinition(ctx ModuleContext, symbolFile string,
func compileStubLibrary(ctx ModuleContext, flags Flags, src android.Path) Objects {
return compileObjs(ctx, flagsToBuilderFlags(flags), "",
android.Paths{src}, nil, nil, nil)
android.Paths{src}, nil, nil, nil, nil)
}
func (this *stubDecorator) findImplementationLibrary(ctx ModuleContext) android.Path {

View file

@ -225,6 +225,16 @@ This 90-second limit is actually the default time limit
in several Android continuous builds where `WITH_TIDY=1` and
`CLANG_ANALYZER_CHECKS=1` are set.
Similar to `tidy_disabled_srcs` a `tidy_timeout_srcs` list
can be used to include all source files that took too much time to compile
with clang-tidy. Files listed in `tidy_timeout_srcs` will not
be compiled by clang-tidy when `TIDY_TIMEOUT` is defined.
This can save global build time, when it is necessary to set some
time limit globally to finish in an acceptable time.
For developers who want to find all clang-tidy warnings and
are willing to spend more time on all files in a project,
they should not define `TIDY_TIMEOUT` and build only the wanted project directories.
## Capabilities for Android.bp and Android.mk
Some of the previously mentioned features are defined only