Module: Datadog::LibdatadogExtconfHelpers::DumpMkmfLogOnFailure

Defined in:
ext/libdatadog_extconf_helpers.rb

Overview

rubocop:disable Style/GlobalVars,Style/StderrPuts See dump_mkmf_log_on_failure! for details.

Instance Method Summary collapse

Instance Method Details

#mkmf_failed(path) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'ext/libdatadog_extconf_helpers.rb', line 186

def mkmf_failed(path)
  unless $makefile_created || File.exist?("Makefile")
    log_path = File.expand_path("mkmf.log")
    if File.exist?(log_path)
      # The full log is very verbose so let's grab only the last check which should be the one that failed
      entries = File.read(log_path).split(/^-{20}$\n?/)
      last_entry = entries.reverse.find { |e| !e.strip.empty? } || ""

      $stderr.puts(
        "+------------------------------------------------------------------------------+\n" \
        "| There was an issue setting up extension build:                               |\n" \
        "+------------------------------------------------------------------------------+" \
        "#{last_entry.chomp}" \
        "+------------------------------------------------------------------------------+\n" \
        "| Full failure log is at #{log_path}\n" \
        "+------------------------------------------------------------------------------+\n" \
      )
    end
  end
  super
end