diff --git a/cc/builder.go b/cc/builder.go index 8e6f7cd52..525b1a14f 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -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 diff --git a/cc/compiler.go b/cc/compiler.go index d9a6bcd1e..7645cbbd8 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -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. diff --git a/cc/library.go b/cc/library.go index 6aac7aeb0..5fa3471f0 100644 --- a/cc/library.go +++ b/cc/library.go @@ -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)) } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 7efe134d2..fc682ff70 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -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 { diff --git a/docs/tidy.md b/docs/tidy.md index 3140198c3..890c3a036 100644 --- a/docs/tidy.md +++ b/docs/tidy.md @@ -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