mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 06:06:40 +00:00
fix(native_comp): patch Emacs.pdmp for customized native-lisp paths
In my initial testing without full native-comp AoT, Emacs seemed to somehow launch fine. But with a AoT build it complains that it can't find *.eln files in the original paths that contained dots. But since we have to customize those folder names removing the dots to make Apple's codesign happy, we also need to update Emacs.pdmp too.
This commit is contained in:
@@ -454,6 +454,13 @@ class Build
|
||||
parent = File.dirname(parent)
|
||||
end
|
||||
|
||||
eln_parts = eln_dir.match(
|
||||
%r{/(\d+\.\d+\.\d+)/native-lisp/(\d+\.\d+\.\d+-\w+)(?:/.+)?$}i
|
||||
)
|
||||
if eln_parts
|
||||
patch_dump_native_lisp_paths(app, eln_parts[1], eln_parts[2])
|
||||
end
|
||||
|
||||
# Find native-lisp directory again after it has been renamed.
|
||||
source = Dir['MacOS/libexec/emacs/**/eln-cache',
|
||||
'MacOS/lib/emacs/**/native-lisp'].first
|
||||
@@ -468,6 +475,29 @@ class Build
|
||||
end
|
||||
end
|
||||
|
||||
def patch_dump_native_lisp_paths(app, emacs_version, eln_version)
|
||||
sanitized_emacs_version = emacs_version.gsub('.', '-')
|
||||
sanitized_eln_version = eln_version.gsub('.', '-')
|
||||
|
||||
contents_dir = File.join(app, 'Contents')
|
||||
FileUtils.cd(contents_dir) do
|
||||
filename = Dir['MacOS/Emacs.pdmp', 'MacOS/libexec/Emacs.pdmp'].first
|
||||
err "no Emacs.pdmp file found in #{app}" unless filename
|
||||
info 'patching Emacs.pdmp to point at new native-lisp paths'
|
||||
|
||||
content = File.read(filename, mode: 'rb').gsub(
|
||||
"lib/emacs/#{emacs_version}/native-lisp/#{eln_version}/",
|
||||
"lib/emacs/#{sanitized_emacs_version}/" \
|
||||
"native-lisp/#{sanitized_eln_version}/"
|
||||
).gsub(
|
||||
"../native-lisp/#{eln_version}/",
|
||||
"../native-lisp/#{sanitized_eln_version}/"
|
||||
)
|
||||
|
||||
File.open(filename, 'w') { |f| f.write(content) }
|
||||
end
|
||||
end
|
||||
|
||||
def add_cli_helper(app)
|
||||
source = File.join(__dir__, 'helper', 'emacs-cli.bash')
|
||||
target = File.join(app, 'Contents', 'MacOS', 'bin', 'emacs')
|
||||
|
||||
Reference in New Issue
Block a user