ruslo / polly

:wrench: Collection of CMake toolchain files and scripts for cross-platform build and CI testing (GCC, Visual Studio, iOS, Android, Clang analyzer, sanitizers etc.)
BSD 2-Clause "Simplified" License
862 stars 191 forks source link

How to reduce Xcodebuild log size? #311

Closed tony84727 closed 5 years ago

tony84727 commented 5 years ago

CMake use xcodebuild to build project, when the generator is Xcode. But xcodebuild is too verbose that build job got terminated (example) on travis-ci due to exceeding maximum log lines.

I've tried setting VERBOSE=0 environment variable, but it doesn't work. I also tried setting --verbosity to normal or silent. silent is too quiet that doesn't print out what's done in the process. It seems like xcodebuild either print all the information out or do the job silently with --quiet. Both not ideal in CI.

What is the best way to reduce the xcodebuild log size?


Potential solution:

I found this SO answer, suggesting using xcpretty.

Here's what xcpretty output looks like:

▸ Aggregate github-client-cpp/ZERO_CHECK [Debug]
▸ Check Dependencies
▸ Running script 'CMake Rules'
▸ Build Succeeded
▸ Aggregate github-client-cpp/ZERO_CHECK [Release]
▸ Check Dependencies
▸ Running script 'CMake Rules'
▸ Aggregate github-client-cpp/format-github-client-cpp [Release]
▸ Check Dependencies
▸ Running script 'CMake Rules'
▸ Building github-client-cpp/github-client-cpp [Release]
▸ Check Dependencies
▸ Aggregate github-client-cpp/format-unit_test [Release]
▸ Check Dependencies
▸ Running script 'CMake Rules'
▸ Building github-client-cpp/unit_test [Release]
▸ Check Dependencies
▸ Running script 'CMake PostBuild Rules'
▸ Building github-client-cpp/git-hub [Release]
▸ Check Dependencies
▸ Aggregate github-client-cpp/ALL_BUILD [Release]
▸ Check Dependencies
▸ Running script 'CMake Rules'
▸ Build Succeeded

But how to add it to polly?

  1. A new verbosity option?
  2. Another toolchain file?
ruslo commented 5 years ago

I've tried setting VERBOSE=0 environment variable, but it doesn't work

VERBOSE=0 is an option for jenkins.py script in Hunter CI:

polly.py will not use it.

I also tried setting --verbosity to normal or silent. silent is too quiet that doesn't print out what's done in the process.

Try to experiment with --discard and --tail options of polly.py to find the right balance.

tony84727 commented 5 years ago

Try to experiment with --discard and --tail options of polly.py to find the right balance.

Thank you. --discard does reduce the log size, and the build pass, but it makes log incomplete. Although the help message says the complete log still available on the log.txt, I am not sure if there's a convenient way to browse or download those files from travis. As for --tail, the help message says " Print last N lines if build failed", so to reduce log size and keep useful information. I need to set --verbosity silent and --tail 200.

I will go with --verbosity silent --tail 200.

Oh no, travis complains No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself. now.

I am still wondering if there's a way to pipe cmake build output to other programs. Maybe add a --tee option?

ruslo commented 5 years ago

travis complains No output has been received in the last 10m0s

That's what I mean by "find the balance". You should use --verbose --discard N --tail M to achieve simultaneously: (1) output something to avoid "No output has been received in the last 10m0s" (2) do not output too much to avoid "The job exceeded the maximum log length" (3) get max info if build failed.

--discard does reduce the log size, and the build pass, but it makes log incomplete

That is the point of losing some information :) Otherwise, you will get "The job exceeded the maximum log length", no?

tony84727 commented 5 years ago

That's what I mean by "find the balance". You should use --verbose --discard N --tail M to achieve simultaneously: (1) output something to avoid "No output has been received in the last 10m0s" (2) do not output too much to avoid "The job exceeded the maximum log length" (3) get max info if build failed.

Oh, I didn't think of that. That should do the trick. Thanks.

That is the point of losing some information :) Otherwise, you will get "The job exceeded the maximum log length", no?

Yes, but I was afraid some of the compiler error getting trimmed. Morden compilers usually print out useful information if there's some error, and I was hoping those message can remain intact. (I know --tail will output complete log if the build failed, so it shouldn't matter.)