mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
59f1bcd3e8
|
|||
| e767e284b7 | |||
|
8129a2e93b
|
|||
|
4ae288cae3
|
|||
|
3bd78d130a
|
|||
|
fb5362ce18
|
|||
|
1a34a9504a
|
|||
| 8513521d29 | |||
|
88bbefadc6
|
|||
|
f1bf1d93b8
|
|||
|
8a467b0d43
|
|||
|
9c29f721b4
|
|||
|
4ac71ddf39
|
|||
|
d338c136db
|
29
CHANGELOG.md
29
CHANGELOG.md
@@ -2,6 +2,35 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.6.26](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.25...v0.6.26) (2021-11-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **build:** re-link eln files by default again ([4ae288c](https://github.com/jimeh/build-emacs-for-macos/commit/4ae288cae34c5e1d291dad7b6b654fe37c4a221f))
|
||||||
|
* **native-comp:** no longer require gcc homebrew formula ([3bd78d1](https://github.com/jimeh/build-emacs-for-macos/commit/3bd78d130a5419a6530a7d30e271569e501870fb)), closes [#53](https://github.com/jimeh/build-emacs-for-macos/issues/53)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **embed:** relink shared libraries with [@rpath](https://github.com/rpath) instead of [@executable](https://github.com/executable)_path ([fb5362c](https://github.com/jimeh/build-emacs-for-macos/commit/fb5362ce183ce43e52afcc0fc721cf2145f9c85b))
|
||||||
|
|
||||||
|
### [0.6.25](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.24...v0.6.25) (2021-11-25)
|
||||||
|
|
||||||
|
### [0.6.24](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.23...v0.6.24) (2021-11-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **embedding:** embedding GCC fails when paths do not require sanitizing ([8a467b0](https://github.com/jimeh/build-emacs-for-macos/commit/8a467b0d43140f6956d53c27e2319ae1b572868c))
|
||||||
|
|
||||||
|
### [0.6.23](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.22...v0.6.23) (2021-11-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **build:** do not re-link eln files by default ([d338c13](https://github.com/jimeh/build-emacs-for-macos/commit/d338c136db8acc4378154cf66ed7db5462787602)), closes [#60](https://github.com/jimeh/build-emacs-for-macos/issues/60)
|
||||||
|
|
||||||
### [0.6.22](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.21...v0.6.22) (2021-11-10)
|
### [0.6.22](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.21...v0.6.22) (2021-11-10)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
53
README.md
53
README.md
@@ -17,21 +17,10 @@ Use this script at your own risk.
|
|||||||
built from the `master` branch. This script allows you to choose any branch,
|
built from the `master` branch. This script allows you to choose any branch,
|
||||||
tag, or git ref you want.
|
tag, or git ref you want.
|
||||||
|
|
||||||
## Status
|
## Binary Builds
|
||||||
|
|
||||||
As of writing (2021-04-25) it works for me on my machine. Your luck may vary.
|
Nightly and stable binary builds produced with this build script are available
|
||||||
|
from [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds).
|
||||||
I have successfully built:
|
|
||||||
|
|
||||||
- `emacs-27.1` release git tag
|
|
||||||
- `master` branch (Emacs 28.x)
|
|
||||||
- `feature/native-comp` branch (Emacs 28.x)
|
|
||||||
|
|
||||||
For reference, my machine is:
|
|
||||||
|
|
||||||
- 13-inch MacBook Pro (2020), 10th-gen 2.3 GHz Quad-Core Intel Core i7 (4c/8t)
|
|
||||||
- macOS Big Sur 11.2.3 (20D91)
|
|
||||||
- Xcode 12.4 (12D4e)
|
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
@@ -41,14 +30,9 @@ The build produced does have some limitations:
|
|||||||
application will be that of the machine it was built on.
|
application will be that of the machine it was built on.
|
||||||
- The minimum required macOS version of the built application will be the same
|
- The minimum required macOS version of the built application will be the same
|
||||||
as that of the machine it was built on.
|
as that of the machine it was built on.
|
||||||
- The application is not signed, so running it on machines other than the one
|
- The application is not signed automatically, but the CLI tool used to sign the
|
||||||
that built the application will yield warnings. If you want to make a signed
|
nightly builds is available. Run `go run ./cmd/emacs-builder package --help`
|
||||||
Emacs.app, google is you friend for finding signing instructions.
|
for details. More detailed instructions will come soon.
|
||||||
|
|
||||||
## Binary Builds
|
|
||||||
|
|
||||||
Nightly and stable binary builds produced with this build script are available
|
|
||||||
from [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds).
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@@ -66,6 +50,26 @@ from [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds).
|
|||||||
brew install ruby
|
brew install ruby
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Status
|
||||||
|
|
||||||
|
As of writing (2021-11-27) it works for me on my machine and for the nightly
|
||||||
|
builds in [jimeh/emacs-builds](https://github.com/jimeh/emacs-builds). Your luck
|
||||||
|
may vary.
|
||||||
|
|
||||||
|
I have successfully built:
|
||||||
|
|
||||||
|
- `emacs-28` release branch
|
||||||
|
- `master` branch (Emacs 29.x)
|
||||||
|
|
||||||
|
For reference, my machine is:
|
||||||
|
|
||||||
|
- 13-inch MacBook Pro (2020), 10th-gen 2.3 GHz Quad-Core Intel Core i7 (4c/8t)
|
||||||
|
- macOS Monterey 12.0.1 (21A559)
|
||||||
|
- Xcode 13.1 (13A1030d)
|
||||||
|
|
||||||
|
Nightly builds are built with GitHub Actions on GitHub-hosted runners, using
|
||||||
|
`macos-10.15`.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -81,8 +85,10 @@ Options:
|
|||||||
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
||||||
--[no-]native-march Enable/disable -march=native CFLAG(default: disabled)
|
--[no-]native-march Enable/disable -march=native CFLAG(default: disabled)
|
||||||
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
|
--[no-]native-full-aot Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation (default: disabled)
|
||||||
|
--[no-]relink-eln-files Enable/disable re-linking shared libraries in bundled *.eln files (default: enabled)
|
||||||
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
--[no-]rsvg Enable/disable SVG image support via librsvg (default: enabled)
|
||||||
--no-titlebar Apply no-titlebar patch (default: disabled)
|
--no-titlebar Apply no-titlebar patch (default: disabled)
|
||||||
|
--posix-spawn Apply posix-spawn patch (default: disabled)
|
||||||
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
||||||
--[no-]github-auth Make authenticated GitHub API requests if GITHUB_TOKEN environment variable is set.(default: enabled)
|
--[no-]github-auth Make authenticated GitHub API requests if GITHUB_TOKEN environment variable is set.(default: enabled)
|
||||||
--work-dir DIR Specify a working directory where tarballs, sources, and builds will be stored and worked with
|
--work-dir DIR Specify a working directory where tarballs, sources, and builds will be stored and worked with
|
||||||
@@ -90,7 +96,8 @@ Options:
|
|||||||
--build-name NAME Override generated build name
|
--build-name NAME Override generated build name
|
||||||
--dist-include x,y,z List of extra files to copy from Emacs source into build folder/archive (default: COPYING)
|
--dist-include x,y,z List of extra files to copy from Emacs source into build folder/archive (default: COPYING)
|
||||||
--[no-]archive Enable/disable creating *.tbz archive (default: enabled)
|
--[no-]archive Enable/disable creating *.tbz archive (default: enabled)
|
||||||
--[no-]archive-keep Enable/disable keeping source folder for archive (default: disabled)
|
--[no-]archive-keep-build-dir
|
||||||
|
Enable/disable keeping source folder for archive (default: disabled)
|
||||||
--plan FILE Follow given plan file, instead of using given git ref/sha
|
--plan FILE Follow given plan file, instead of using given git ref/sha
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ module Output
|
|||||||
if newline
|
if newline
|
||||||
warn "==> #{msg}"
|
warn "==> #{msg}"
|
||||||
else
|
else
|
||||||
STDERR.print "==> #{msg}"
|
$stderr.print "==> #{msg}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -35,6 +35,19 @@ module Output
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module System
|
||||||
|
include Output
|
||||||
|
|
||||||
|
def run_cmd(*args)
|
||||||
|
out("CMD: #{args.join(' ')}")
|
||||||
|
cmd(*args)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cmd(*args)
|
||||||
|
system(*args) || err("Exit code: #{$CHILD_STATUS.exitstatus}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class OS
|
class OS
|
||||||
def self.version
|
def self.version
|
||||||
@version ||= OSVersion.new
|
@version ||= OSVersion.new
|
||||||
@@ -71,6 +84,7 @@ end
|
|||||||
|
|
||||||
class Build
|
class Build
|
||||||
include Output
|
include Output
|
||||||
|
include System
|
||||||
|
|
||||||
EMACS_MIRROR_REPO = 'emacs-mirror/emacs'
|
EMACS_MIRROR_REPO = 'emacs-mirror/emacs'
|
||||||
DOWNLOAD_URL = 'https://github.com/emacs-mirror/emacs/tarball/%s'
|
DOWNLOAD_URL = 'https://github.com/emacs-mirror/emacs/tarball/%s'
|
||||||
@@ -199,7 +213,7 @@ class Build
|
|||||||
end
|
end
|
||||||
|
|
||||||
out "CMD: #{log_args.join(' ')}"
|
out "CMD: #{log_args.join(' ')}"
|
||||||
system(*args) || err("Exit code: #{$CHILD_STATUS.exitstatus}")
|
cmd(*args)
|
||||||
|
|
||||||
target
|
target
|
||||||
end
|
end
|
||||||
@@ -400,13 +414,13 @@ class Build
|
|||||||
info "Copying \"#{app_name}\" to: #{target_dir}"
|
info "Copying \"#{app_name}\" to: #{target_dir}"
|
||||||
|
|
||||||
FileUtils.mkdir_p(target_dir)
|
FileUtils.mkdir_p(target_dir)
|
||||||
FileUtils.cp_r(app, target_dir)
|
cmd('cp', '-a', app, target_dir)
|
||||||
|
|
||||||
options[:dist_include]&.each do |filename|
|
options[:dist_include]&.each do |filename|
|
||||||
src = File.join(source_dir, filename)
|
src = File.join(source_dir, filename)
|
||||||
if File.exist?(src)
|
if File.exist?(src)
|
||||||
info "Copying \"#{filename}\" to: #{target_dir}"
|
info "Copying \"#{filename}\" to: #{target_dir}"
|
||||||
FileUtils.cp_r(src, target_dir)
|
cmd('cp', '-pRL', src, target_dir)
|
||||||
else
|
else
|
||||||
info "Warning: #{filename} does not exist in #{source_dir}"
|
info "Warning: #{filename} does not exist in #{source_dir}"
|
||||||
end
|
end
|
||||||
@@ -431,7 +445,7 @@ class Build
|
|||||||
info 'Creating symlinks within Emacs.app needed for native-comp'
|
info 'Creating symlinks within Emacs.app needed for native-comp'
|
||||||
|
|
||||||
if !File.exist?('lisp') && File.exist?('Resources/lisp')
|
if !File.exist?('lisp') && File.exist?('Resources/lisp')
|
||||||
FileUtils.ln_s('Resources/lisp', 'lisp')
|
run_cmd('ln', '-s', 'Resources/lisp', 'lisp')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Check for folder name containing two dots (.), as this causes Apple's
|
# Check for folder name containing two dots (.), as this causes Apple's
|
||||||
@@ -453,7 +467,7 @@ class Build
|
|||||||
new_name = File.join(parent, base.gsub(/\.(.+)\./, '-\\1-'))
|
new_name = File.join(parent, base.gsub(/\.(.+)\./, '-\\1-'))
|
||||||
|
|
||||||
info "Renaming: #{old_name} --> #{new_name}"
|
info "Renaming: #{old_name} --> #{new_name}"
|
||||||
FileUtils.mv(old_name, new_name)
|
cmd('mv', old_name, new_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
base = File.basename(parent)
|
base = File.basename(parent)
|
||||||
@@ -477,7 +491,7 @@ class Build
|
|||||||
end
|
end
|
||||||
|
|
||||||
target = File.basename(source)
|
target = File.basename(source)
|
||||||
FileUtils.ln_s(source, target) unless File.exist?(target)
|
run_cmd('ln', '-s', source, target) unless File.exist?(target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -535,7 +549,7 @@ class Build
|
|||||||
if !File.exist?(archive_filename)
|
if !File.exist?(archive_filename)
|
||||||
info "Creating #{filename} archive in \"#{target_dir}\"..."
|
info "Creating #{filename} archive in \"#{target_dir}\"..."
|
||||||
FileUtils.cd(parent_dir) do
|
FileUtils.cd(parent_dir) do
|
||||||
system('tar', '-cjf', archive_filename, build)
|
cmd('tar', '-cjf', archive_filename, build)
|
||||||
|
|
||||||
if options[:archive_keep] == false
|
if options[:archive_keep] == false
|
||||||
info "Removing \"#{build}\" directory from #{parent_dir}"
|
info "Removing \"#{build}\" directory from #{parent_dir}"
|
||||||
@@ -600,11 +614,6 @@ class Build
|
|||||||
response.body
|
response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_cmd(*args)
|
|
||||||
out "CMD: #{args.join(' ')}"
|
|
||||||
system(*args) || err("Exit code: #{$CHILD_STATUS.exitstatus}")
|
|
||||||
end
|
|
||||||
|
|
||||||
def effective_version
|
def effective_version
|
||||||
@effective_version ||= begin
|
@effective_version ||= begin
|
||||||
case ref
|
case ref
|
||||||
@@ -750,6 +759,7 @@ end
|
|||||||
|
|
||||||
class AbstractEmbedder
|
class AbstractEmbedder
|
||||||
include Output
|
include Output
|
||||||
|
include System
|
||||||
|
|
||||||
attr_reader :app
|
attr_reader :app
|
||||||
|
|
||||||
@@ -760,23 +770,27 @@ class AbstractEmbedder
|
|||||||
end
|
end
|
||||||
|
|
||||||
def invocation_dir
|
def invocation_dir
|
||||||
File.join(app, 'Contents', 'MacOS')
|
@invocation_dir ||= File.join(app, 'Contents', 'MacOS')
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin
|
def bin
|
||||||
File.join(invocation_dir, 'Emacs')
|
@bin ||= File.join(invocation_dir, 'Emacs')
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin_dir
|
def bin_dir
|
||||||
File.join(invocation_dir, 'bin')
|
@bin_dir ||= File.join(invocation_dir, 'bin')
|
||||||
end
|
end
|
||||||
|
|
||||||
def lib_dir
|
def lib_dir
|
||||||
File.join(invocation_dir, 'lib')
|
@lib_dir ||= frameworks_dir
|
||||||
|
end
|
||||||
|
|
||||||
|
def frameworks_dir
|
||||||
|
@frameworks_dir ||= File.join(app, 'Contents', 'Frameworks')
|
||||||
end
|
end
|
||||||
|
|
||||||
def resources_dir
|
def resources_dir
|
||||||
File.join(app, 'Contents', 'Resources')
|
@resources_dir ||= File.join(app, 'Contents', 'Resources')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -786,11 +800,11 @@ class CLIHelperEmbedder < AbstractEmbedder
|
|||||||
target = File.join(bin_dir, 'emacs')
|
target = File.join(bin_dir, 'emacs')
|
||||||
dir = File.dirname(target)
|
dir = File.dirname(target)
|
||||||
|
|
||||||
info "Adding \"emacs\" CLI helper to #{dir}"
|
info 'Adding "emacs" CLI helper to Emacs.app'
|
||||||
|
|
||||||
FileUtils.mkdir_p(dir)
|
FileUtils.mkdir_p(dir)
|
||||||
FileUtils.cp(source, target)
|
run_cmd('cp', '-pRL', source, target)
|
||||||
FileUtils.chmod('+w', target)
|
run_cmd('chmod', '+w', target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -816,7 +830,7 @@ class CSourcesEmbedder < AbstractEmbedder
|
|||||||
rel = f[src_dir.size + 1..-1]
|
rel = f[src_dir.size + 1..-1]
|
||||||
target = File.join(resources_dir, 'src', rel)
|
target = File.join(resources_dir, 'src', rel)
|
||||||
FileUtils.mkdir_p(File.dirname(target))
|
FileUtils.mkdir_p(File.dirname(target))
|
||||||
FileUtils.cp(f, target)
|
cmd('cp', '-pRL', f, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
return if File.exist?(site_start_el_file) &&
|
return if File.exist?(site_start_el_file) &&
|
||||||
@@ -837,14 +851,14 @@ end
|
|||||||
class LibEmbedder < AbstractEmbedder
|
class LibEmbedder < AbstractEmbedder
|
||||||
attr_reader :lib_source
|
attr_reader :lib_source
|
||||||
attr_reader :extra_libs
|
attr_reader :extra_libs
|
||||||
attr_reader :embed_eln_files
|
attr_reader :relink_eln_files
|
||||||
|
|
||||||
def initialize(app, lib_source, extra_libs = [], embed_eln_files = true)
|
def initialize(app, lib_source, extra_libs = [], relink_eln_files = true)
|
||||||
super(app)
|
super(app)
|
||||||
|
|
||||||
@lib_source = lib_source
|
@lib_source = lib_source
|
||||||
@extra_libs = extra_libs
|
@extra_libs = extra_libs
|
||||||
@embed_eln_files = embed_eln_files
|
@relink_eln_files = relink_eln_files
|
||||||
end
|
end
|
||||||
|
|
||||||
def embed
|
def embed
|
||||||
@@ -854,15 +868,20 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
binary ||= bin
|
binary ||= bin
|
||||||
|
|
||||||
FileUtils.cd(File.dirname(app)) do
|
FileUtils.cd(File.dirname(app)) do
|
||||||
|
rel_path = Pathname.new(lib_dir).relative_path_from(
|
||||||
|
Pathname.new(File.dirname(binary))
|
||||||
|
).to_s
|
||||||
|
rpath = File.join('@executable_path', rel_path)
|
||||||
|
|
||||||
|
set_rpath(binary, rpath)
|
||||||
copy_libs(binary)
|
copy_libs(binary)
|
||||||
copy_extra_libs(extra_libs, binary) if extra_libs.any?
|
copy_extra_libs(extra_libs, binary) if extra_libs.any?
|
||||||
if eln_files.any?
|
|
||||||
|
if relink_eln_files && eln_files.any?
|
||||||
info "Embedding libraries for #{eln_files.size} *.eln files " \
|
info "Embedding libraries for #{eln_files.size} *.eln files " \
|
||||||
'within Emacs.app'
|
'within Emacs.app'
|
||||||
rel_path = Pathname.new(lib_dir).relative_path_from(
|
|
||||||
Pathname.new(File.dirname(binary))
|
eln_files.each { |f| copy_libs(f) }
|
||||||
).to_s
|
|
||||||
eln_files.each { |f| copy_libs(f, rel_path) } if embed_eln_files
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -873,21 +892,19 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
@eln_files ||= Dir[File.join(app, 'Contents', '**', '*.eln')]
|
@eln_files ||= Dir[File.join(app, 'Contents', '**', '*.eln')]
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_libs(exe, rel_path = nil)
|
def set_rpath(exe, rpath)
|
||||||
exe_file = File.basename(exe)
|
return if rpath.nil? || rpath == ''
|
||||||
rel_path ||= Pathname.new(lib_dir).relative_path_from(
|
|
||||||
Pathname.new(File.dirname(exe))
|
|
||||||
).to_s
|
|
||||||
|
|
||||||
rpath = File.join('@executable_path', rel_path)
|
|
||||||
rpaths = `otool -l "#{exe}" | grep -A 2 'cmd LC_RPATH' | grep 'path'`
|
rpaths = `otool -l "#{exe}" | grep -A 2 'cmd LC_RPATH' | grep 'path'`
|
||||||
|
return if rpaths.include?(rpath)
|
||||||
|
|
||||||
unless rpaths.include?(rpath)
|
while_writable(exe) do
|
||||||
while_writable(exe) do
|
cmd('install_name_tool', '-add_rpath', rpath, exe)
|
||||||
system('install_name_tool', '-add_rpath',
|
|
||||||
File.join('@executable_path', rel_path), exe)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def copy_libs(exe)
|
||||||
|
exe_file = File.basename(exe)
|
||||||
|
|
||||||
`otool -L "#{exe}"`.split("\n")[1..-1].each do |line|
|
`otool -L "#{exe}"`.split("\n")[1..-1].each do |line|
|
||||||
match = line.match(%r{^\s+(.+/(lib[^/ ]+))\s})
|
match = line.match(%r{^\s+(.+/(lib[^/ ]+))\s})
|
||||||
@@ -895,41 +912,37 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
|
|
||||||
while_writable(exe) do
|
while_writable(exe) do
|
||||||
if match[2] == exe_file
|
if match[2] == exe_file
|
||||||
system('install_name_tool', '-id',
|
cmd('install_name_tool', '-id',
|
||||||
File.join('@executable_path', rel_path, match[2].to_s), exe)
|
File.join('@rpath', match[2].to_s), exe)
|
||||||
else
|
else
|
||||||
system('install_name_tool', '-change', match[1],
|
cmd('install_name_tool', '-change', match[1],
|
||||||
File.join('@executable_path', rel_path, match[2].to_s), exe)
|
File.join('@rpath', match[2].to_s), exe)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
next if match[2] == exe_file || File.exist?(File.join(lib_dir, match[2]))
|
next if match[2] == exe_file || File.exist?(File.join(lib_dir, match[2]))
|
||||||
|
|
||||||
FileUtils.mkdir_p(lib_dir)
|
FileUtils.mkdir_p(lib_dir)
|
||||||
FileUtils.cp(match[1], lib_dir)
|
cmd('cp', '-pRL', match[1], lib_dir)
|
||||||
copy_libs(File.join(lib_dir, match[2].to_s), rel_path)
|
copy_libs(File.join(lib_dir, match[2].to_s))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy_extra_libs(extra_libs, exe, rel_path = nil)
|
def copy_extra_libs(extra_libs, exe)
|
||||||
rel_path ||= Pathname.new(lib_dir).relative_path_from(
|
|
||||||
Pathname.new(File.dirname(exe))
|
|
||||||
).to_s
|
|
||||||
|
|
||||||
extra_libs.each do |lib|
|
extra_libs.each do |lib|
|
||||||
lib_file = File.basename(lib)
|
lib_file = File.basename(lib)
|
||||||
target = "#{lib_dir}/#{lib_file}"
|
target = "#{lib_dir}/#{lib_file}"
|
||||||
unless File.exist?(target)
|
unless File.exist?(target)
|
||||||
FileUtils.mkdir_p(lib_dir)
|
FileUtils.mkdir_p(lib_dir)
|
||||||
FileUtils.cp(lib, lib_dir)
|
cmd('cp', '-pRL', lib, lib_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
while_writable(target) do
|
while_writable(target) do
|
||||||
system('install_name_tool', '-id',
|
cmd('install_name_tool', '-id',
|
||||||
File.join('@executable_path', rel_path, lib_file), target)
|
File.join('@rpath', lib_file), target)
|
||||||
end
|
end
|
||||||
|
|
||||||
copy_libs(target, rel_path)
|
copy_libs(target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -938,7 +951,7 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
File.chmod(0o775, file)
|
File.chmod(0o775, file)
|
||||||
yield
|
yield
|
||||||
ensure
|
ensure
|
||||||
File.chmod(mode, file)
|
File.chmod(mode, file) if File.exist?(file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -963,10 +976,12 @@ class GccLibEmbedder < AbstractEmbedder
|
|||||||
end
|
end
|
||||||
|
|
||||||
FileUtils.mkdir_p(File.dirname(target_dir))
|
FileUtils.mkdir_p(File.dirname(target_dir))
|
||||||
FileUtils.cp_r(source_dir, target_dir)
|
run_cmd('cp', '-pRL', source_dir, target_dir)
|
||||||
FileUtils.rm(Dir[File.join(target_dir, '**', '.DS_Store')], force: true)
|
FileUtils.rm(Dir[File.join(target_dir, '**', '.DS_Store')], force: true)
|
||||||
FileUtils.chmod_R('u+w', target_dir)
|
run_cmd('chmod', '-R', 'u+w', target_dir)
|
||||||
FileUtils.mv(source_darwin_dir, target_darwin_dir)
|
if source_darwin_dir != target_darwin_dir
|
||||||
|
run_cmd('mv', source_darwin_dir, target_darwin_dir)
|
||||||
|
end
|
||||||
|
|
||||||
env_setup = ERB.new(NATIVE_COMP_ENV_VAR_TPL).result(gcc_info.get_binding)
|
env_setup = ERB.new(NATIVE_COMP_ENV_VAR_TPL).result(gcc_info.get_binding)
|
||||||
return if File.exist?(site_start_el_file) &&
|
return if File.exist?(site_start_el_file) &&
|
||||||
@@ -1054,7 +1069,7 @@ class GccInfo
|
|||||||
end
|
end
|
||||||
|
|
||||||
def relative_lib_dir
|
def relative_lib_dir
|
||||||
@relative_lib_dir ||= relative_dir(lib_dir, root_dir)
|
@relative_lib_dir ||= relative_dir(lib_dir, File.join(root_dir, 'lib'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def darwin_lib_dir
|
def darwin_lib_dir
|
||||||
@@ -1069,7 +1084,9 @@ class GccInfo
|
|||||||
end
|
end
|
||||||
|
|
||||||
def relative_darwin_lib_dir
|
def relative_darwin_lib_dir
|
||||||
@relative_darwin_lib_dir ||= relative_dir(darwin_lib_dir, root_dir)
|
@relative_darwin_lib_dir ||= relative_dir(
|
||||||
|
darwin_lib_dir, File.join(root_dir, 'lib')
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitize folder name with full "MAJOR.MINOR.PATCH" version number to just
|
# Sanitize folder name with full "MAJOR.MINOR.PATCH" version number to just
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ var DefaultEmacsEntitlements = []string{
|
|||||||
"com.apple.security.cs.allow-jit",
|
"com.apple.security.cs.allow-jit",
|
||||||
"com.apple.security.network.client",
|
"com.apple.security.network.client",
|
||||||
"com.apple.security.cs.disable-library-validation",
|
"com.apple.security.cs.disable-library-validation",
|
||||||
|
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||||
"com.apple.security.automation.apple-events",
|
"com.apple.security.automation.apple-events",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ var entitlementsTestCases = []struct {
|
|||||||
"com.apple.security.cs.allow-jit",
|
"com.apple.security.cs.allow-jit",
|
||||||
"com.apple.security.network.client",
|
"com.apple.security.network.client",
|
||||||
"com.apple.security.cs.disable-library-validation",
|
"com.apple.security.cs.disable-library-validation",
|
||||||
|
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||||
"com.apple.security.automation.apple-events",
|
"com.apple.security.automation.apple-events",
|
||||||
},
|
},
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
@@ -64,6 +65,8 @@ var entitlementsTestCases = []struct {
|
|||||||
<true/>
|
<true/>
|
||||||
<key>com.apple.security.cs.disable-library-validation</key>
|
<key>com.apple.security.cs.disable-library-validation</key>
|
||||||
<true/>
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||||
|
<true/>
|
||||||
<key>com.apple.security.automation.apple-events</key>
|
<key>com.apple.security.automation.apple-events</key>
|
||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
@@ -78,6 +81,7 @@ func TestDefaultEmacsEntitlements(t *testing.T) {
|
|||||||
"com.apple.security.cs.allow-jit",
|
"com.apple.security.cs.allow-jit",
|
||||||
"com.apple.security.network.client",
|
"com.apple.security.network.client",
|
||||||
"com.apple.security.cs.disable-library-validation",
|
"com.apple.security.cs.disable-library-validation",
|
||||||
|
"com.apple.security.cs.allow-dyld-environment-variables",
|
||||||
"com.apple.security.automation.apple-events",
|
"com.apple.security.automation.apple-events",
|
||||||
},
|
},
|
||||||
DefaultEmacsEntitlements,
|
DefaultEmacsEntitlements,
|
||||||
|
|||||||
Reference in New Issue
Block a user