From 2293c87fc99ef0fb932e54912d6f2e719e7b60e9 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Wed, 27 Oct 2021 03:10:24 +0100 Subject: [PATCH] refactor(build): turn add_cli_helper function into a embedder class --- build-emacs-for-macos | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/build-emacs-for-macos b/build-emacs-for-macos index e1c5bf5..6978ee0 100755 --- a/build-emacs-for-macos +++ b/build-emacs-for-macos @@ -105,8 +105,8 @@ class Build build_dir, app = create_build_dir(app) handle_native_lisp(app) - add_cli_helper(app) + CLIHelperEmbedder.new(app).embed CSourcesEmbedder.new(app, @source_dir).embed LibEmbedder.new(app, brew_dir, extra_libs, options[:relink_eln]).embed GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp] @@ -506,18 +506,6 @@ class Build end end - def add_cli_helper(app) - source = File.join(__dir__, 'helper', 'emacs-cli.bash') - target = File.join(app, 'Contents', 'MacOS', 'bin', 'emacs') - dir = File.dirname(target) - - info "Adding \"emacs\" CLI helper to #{dir}" - - FileUtils.mkdir_p(dir) - FileUtils.cp(source, target) - FileUtils.chmod('+w', target) - end - def build_name return @build_name if @build_name return @build_name = options[:build_name] if options[:build_name] @@ -787,6 +775,10 @@ class AbstractEmbedder File.join(invocation_dir, 'Emacs') end + def bin_dir + File.join(invocation_dir, 'bin') + end + def lib_dir File.join(invocation_dir, 'lib') end @@ -796,6 +788,20 @@ class AbstractEmbedder end end +class CLIHelperEmbedder < AbstractEmbedder + def embed + source = File.join(__dir__, 'helper', 'emacs-cli.bash') + target = File.join(bin_dir, 'emacs') + dir = File.dirname(target) + + info "Adding \"emacs\" CLI helper to #{dir}" + + FileUtils.mkdir_p(dir) + FileUtils.cp(source, target) + FileUtils.chmod('+w', target) + end +end + class CSourcesEmbedder < AbstractEmbedder PATH_PATCH = '(setq source-directory (expand-file-name ".."))'