From 294afc20f80b625221b90ab05fe024392f889fbd Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Thu, 24 Jun 2021 19:12:40 +0100 Subject: [PATCH] formula: capture logs more comprehensively Currently, we copy `config.log` and `CMakeCache.txt` from the root of the source tree into the the logs generated by the build. This has three shortcomings: 1. These files are not necessarily found where we look. This is often the case with a CMake build, but can occur with an Autotools build as well (e.g. GCC, or any other out-of-tree build). 2. There may be several of these files scattered throughout the build tree. This occurs, for example, when the build itself invokes `configure` or `cmake` as part of the build process. 3. We don't copy `CMakeOutput.log` or `CMakeError.log`, which are usually more informative about what happened during the CMake invocation. It is not sufficient to add them to the array of log files that we copy because these are never found at the source root, even when building in-tree. Let's rectify this by copying all instances of these files that can be found in the source tree. Since there will inevitably be duplicate file names, we also store them in the log directory using the same relative paths from the source root. [1] This has the added benefit of providing context for these log files. [1] For example, if `CMakeOutput.log` can be found in `build/CMakeFiles` relative to the source root, then that will also be where it will be stored in the log directory. --- Library/Homebrew/formula.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7d1f18d03a..d7793cdfaf 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1269,7 +1269,18 @@ class Formula staging.retain! if interactive || debug? raise ensure - cp Dir["config.log", "CMakeCache.txt"], logs + %w[ + config.log + CMakeCache.txt + CMakeOutput.log + CMakeError.log + ].each do |logfile| + Dir["**/#{logfile}"].each do |logpath| + destdir = logs/File.dirname(logpath) + mkdir_p destdir + cp logpath, destdir + end + end end end ensure