mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 04:56:39 +00:00
refactor(build): turn add_cli_helper function into a embedder class
This commit is contained in:
@@ -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 ".."))'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user