diff options
author | Chih-Hung Hsieh <chh@google.com> | 2021-10-05 23:14:04 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-10-05 23:14:04 +0000 |
commit | f103b9f78baa21b4edf25d5dd5a1226b6c0ff159 (patch) | |
tree | 0cbf6f6e50bf2d7f1d6021a09db50dc7e6dd9ff6 /compiler_wrapper | |
parent | 75d0ad1e93dfec40618bcec58797c8cb896b8198 (diff) | |
parent | 929241978e4eedb4accab7e83ab383d06c3b4621 (diff) | |
download | toolchain-utils-f103b9f78baa21b4edf25d5dd5a1226b6c0ff159.tar.gz |
Merging 9 commit(s) from Chromium's toolchain-utils am: 3134544d54 am: e0c2630c64 am: 929241978e
Original change: https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/1845270
Change-Id: I497d318091cd0bb5742068f99bd7d3998962e1f0
Diffstat (limited to 'compiler_wrapper')
-rw-r--r-- | compiler_wrapper/compiler_wrapper.go | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/compiler_wrapper/compiler_wrapper.go b/compiler_wrapper/compiler_wrapper.go index 7d949d34..986eabab 100644 --- a/compiler_wrapper/compiler_wrapper.go +++ b/compiler_wrapper/compiler_wrapper.go @@ -74,25 +74,36 @@ func runAndroidClangTidy(env env, cmd *command) error { if err != nil || seconds == 0 { return env.exec(cmd) } + getSourceFile := func() string { + // Note: This depends on Android build system's clang-tidy command line format. + // Last non-flag before "--" in cmd.Args is used as the source file name. + sourceFile := "unknown_file" + for _, arg := range cmd.Args { + if arg == "--" { + break + } + if strings.HasPrefix(arg, "-") { + continue + } + sourceFile = arg + } + return sourceFile + } + startTime := time.Now() err = env.runWithTimeout(cmd, time.Duration(seconds)*time.Second) if !errors.Is(err, context.DeadlineExceeded) { + // When used time is over half of TIDY_TIMEOUT, give a warning. + // These warnings allow users to fix slow jobs before they get worse. + usedSeconds := int(time.Now().Sub(startTime) / time.Second) + if usedSeconds > seconds/2 { + warning := "%s:1:1: warning: clang-tidy used %d seconds.\n" + fmt.Fprintf(env.stdout(), warning, getSourceFile(), usedSeconds) + } return err } // When DeadllineExceeded, print warning messages. - // Note: This depends on Android build system's clang-tidy command line format. - // Last non-flag before "--" in cmd.Args is used as the source file name. - sourceFile := "unknown_file" - for _, arg := range cmd.Args { - if arg == "--" { - break - } - if strings.HasPrefix(arg, "-") { - continue - } - sourceFile = arg - } warning := "%s:1:1: warning: clang-tidy aborted after %d seconds.\n" - fmt.Fprintf(env.stdout(), warning, sourceFile, seconds) + fmt.Fprintf(env.stdout(), warning, getSourceFile(), seconds) fmt.Fprintf(env.stdout(), "TIMEOUT: %s %s\n", cmd.Path, strings.Join(cmd.Args, " ")) // Do not stop Android build. Just give a warning and return no error. return nil |