Skip to content

Commit

Permalink
feat(package): produce and include configure output log (#118)
Browse files Browse the repository at this point in the history
Useful for debugging build issues, and for people who simply want more
details about the build environment and process for Emacs.
  • Loading branch information
jimeh authored Nov 25, 2024
1 parent 6e2b9aa commit 5c513ce
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
45 changes: 39 additions & 6 deletions build-emacs-for-macos
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require 'fileutils'
require 'json'
require 'logger'
require 'net/http'
require 'open3'
require 'optparse'
require 'pathname'
require 'time'
Expand Down Expand Up @@ -81,13 +82,42 @@ end
module System
include Output

def run_cmd(*args)
def run_cmd(*args, output_file: nil)
debug "executing: #{args.join(' ')}"
cmd(*args)
cmd(*args, output_file: output_file)
end

def cmd(*args)
system(*args) || fatal("Exit code: #{$CHILD_STATUS.exitstatus}")
def cmd(*args, output_file: nil)
if output_file.nil?
return system(*args) || fatal("Exit code: #{$CHILD_STATUS.exitstatus}")
end

# Handle output to both terminal and file
File.open(output_file, 'w') do |file|
Open3.popen3(*args) do |_stdin, stdout, stderr, wait_thread|
stdout_thread = Thread.new do
while (line = stdout.gets)
puts line
file.puts line
file.flush
end
end

stderr_thread = Thread.new do
while (line = stderr.gets)
$stderr.puts line # rubocop:disable Style/StderrPuts
file.puts line
file.flush
end
end

[stdout_thread, stderr_thread, wait_thread].map(&:join)
status = wait_thread.value
return true if status.success?

fatal("Exit code: #{status.exitstatus}")
end
end
end
end

Expand Down Expand Up @@ -629,7 +659,10 @@ class Build
configure_flags << '--without-rsvg' if options[:rsvg] == false
configure_flags << '--without-dbus' if options[:dbus] == false

run_cmd './configure', *configure_flags.compact
run_cmd(
'./configure', *configure_flags.compact,
output_file: 'configure_output.txt'
)

# Disable aligned_alloc on Mojave and below. See issue:
# https://github.com/daviderestivo/homebrew-emacs-head/issues/15
Expand Down Expand Up @@ -1748,7 +1781,7 @@ if __FILE__ == $PROGRAM_NAME
fd_setsize: 10_000,
github_src_repo: nil,
github_auth: true,
dist_include: ['COPYING'],
dist_include: ['COPYING', 'configure_output.txt'],
self_sign: true,
archive: true,
archive_keep: false,
Expand Down
12 changes: 12 additions & 0 deletions pkg/dmg/dmg.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ func Create(ctx context.Context, opts *Options) (string, error) {
})
}

configureOutputFile := filepath.Join(sourceDir, "configure_output.txt")
fi, err = os.Stat(configureOutputFile)
if err != nil && !os.IsNotExist(err) {
return "", err
} else if err == nil && fi.Mode().IsRegular() {
settings.Files = append(settings.Files, &dmgbuild.File{
Path: configureOutputFile,
PosX: 340,
PosY: 756,
})
}

if opts.Output != nil {
settings.Stdout = opts.Output
settings.Stderr = opts.Output
Expand Down

0 comments on commit 5c513ce

Please sign in to comment.