mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
9f6ec5954f
|
|||
| 9ea79670d8 | |||
|
72e40248e1
|
|||
|
7259111478
|
|||
|
bb45cda023
|
|||
|
ab872202df
|
|||
|
2d1c5d47d9
|
|||
| 30a71c423e | |||
|
5c48445397
|
|||
|
bf7c4d5deb
|
|||
|
3ffeb4854c
|
|||
|
0a22d8393c
|
|||
|
ac8348323d
|
|||
| 59f52b65ee | |||
|
81a96f4d60
|
|||
|
1df39fafe6
|
|||
|
14a8d1aaaf
|
|||
|
272a3000a1
|
|||
|
d684cf560f
|
|||
| ea189a6713 | |||
|
63289216d7
|
|||
|
2054c8c0aa
|
|||
|
ca09d1a95f
|
|||
|
f1e60e31d9
|
|||
|
8d197aea73
|
|||
|
844df73c8f
|
|||
|
f1fc68c8f5
|
|||
|
e19a6a7bc2
|
|||
|
1000999eb2
|
44
CHANGELOG.md
44
CHANGELOG.md
@@ -2,6 +2,50 @@
|
|||||||
|
|
||||||
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.4.13](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.12...0.4.13) (2021-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **codesign:** prevent "bundle format unrecognized" error from codesign ([7259111](https://github.com/jimeh/build-emacs-for-macos/commit/7259111478ecb838dea9c8f50ea39eafdf47ed5a))
|
||||||
|
* **embed:** avoid potential error caused by trying to set duplicate rpath ([bb45cda](https://github.com/jimeh/build-emacs-for-macos/commit/bb45cda0231e99618571dc835348cf5c3345e277))
|
||||||
|
|
||||||
|
### [0.4.12](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.11...0.4.12) (2021-05-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **shared-libraries:** stop aggressive dylib re-linking ([0a22d83](https://github.com/jimeh/build-emacs-for-macos/commit/0a22d8393c53305354c4c6d8e784e7d59caa039a)), closes [#12](https://github.com/jimeh/build-emacs-for-macos/issues/12)
|
||||||
|
* **svg:** enable SVG by default via librsvg ([bf7c4d5](https://github.com/jimeh/build-emacs-for-macos/commit/bf7c4d5debf32980dbbabc1ea99b58b266390011))
|
||||||
|
|
||||||
|
### [0.4.11](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.10...0.4.11) (2021-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **builds:** update build script for new plan.yml format ([1df39fa](https://github.com/jimeh/build-emacs-for-macos/commit/1df39fafe62ada385aa1d92e6b7f591c16c0a80c))
|
||||||
|
* **release:** initial attempt at providing automatic builds ([6328921](https://github.com/jimeh/build-emacs-for-macos/commit/63289216d70e496d664a7e3078dea5a82eb8f65d))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **release:** attempt to fix issue with talking to GitHub API ([272a300](https://github.com/jimeh/build-emacs-for-macos/commit/272a3000a1f96d8f131e684736127b923513a205))
|
||||||
|
|
||||||
|
### [0.4.10](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.9...0.4.10) (2021-04-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **cli:** correctly default to master branch if no git ref is given ([844df73](https://github.com/jimeh/build-emacs-for-macos/commit/844df73c8fa8440e657f7900ec89cdedb7c4c312))
|
||||||
|
|
||||||
|
### [0.4.9](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.8...0.4.9) (2021-04-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **cli:** default to "master" if no git ref is given ([e19a6a7](https://github.com/jimeh/build-emacs-for-macos/commit/e19a6a7bc24379292ee06ae4c805b8c5365f2d97)), closes [#35](https://github.com/jimeh/build-emacs-for-macos/issues/35)
|
||||||
|
* **native_comp:** skip symlink creation for recent builds which do not need symlinks ([1000999](https://github.com/jimeh/build-emacs-for-macos/commit/1000999eb2673dc207a390ff3f902b9987b99173))
|
||||||
|
|
||||||
### [0.4.8](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.7...0.4.8) (2021-02-27)
|
### [0.4.8](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.7...0.4.8) (2021-02-27)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
Makefile
17
Makefile
@@ -1,9 +1,12 @@
|
|||||||
.PHONY: new-version
|
.PHONY: new-version
|
||||||
new-version:
|
new-version: check-npx
|
||||||
$(if $(shell which npx),,\
|
|
||||||
$(error No npx found in PATH, please install NodeJS))
|
|
||||||
$(if $(shell which standard-version),,\
|
|
||||||
$(error No standard-version found in PATH, install with: \
|
|
||||||
npm install -g standard-version))
|
|
||||||
|
|
||||||
npx standard-version
|
npx standard-version
|
||||||
|
|
||||||
|
.PHONY: next-version
|
||||||
|
next-version: check-npx
|
||||||
|
npx standard-version --dry-run
|
||||||
|
|
||||||
|
.PHONY: check-npx
|
||||||
|
check-npx:
|
||||||
|
$(if $(shell which npx),,\
|
||||||
|
$(error No npx execuable found in PATH, please install NodeJS))
|
||||||
|
|||||||
49
README.md
49
README.md
@@ -1,7 +1,8 @@
|
|||||||
# build-emacs-for-macos
|
# build-emacs-for-macos
|
||||||
|
|
||||||
My personal hacked together script for building a completely self-contained
|
My personal hacked together script for building a completely self-contained
|
||||||
Emacs.app application on macOS, from any git branch, tag, or ref.
|
Emacs.app application on macOS, from any git branch, tag, or ref. With support
|
||||||
|
for native-compilation.
|
||||||
|
|
||||||
Use this script at your own risk.
|
Use this script at your own risk.
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ Use this script at your own risk.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
As of writing (2021-01-15) it works for me on my machine. Your luck may vary.
|
As of writing (2021-04-25) it works for me on my machine. Your luck may vary.
|
||||||
|
|
||||||
I have successfully built:
|
I have successfully built:
|
||||||
|
|
||||||
@@ -29,8 +30,8 @@ I have successfully built:
|
|||||||
For reference, my machine is:
|
For reference, my machine is:
|
||||||
|
|
||||||
- 13-inch MacBook Pro (2020), 10th-gen 2.3 GHz Quad-Core Intel Core i7 (4c/8t)
|
- 13-inch MacBook Pro (2020), 10th-gen 2.3 GHz Quad-Core Intel Core i7 (4c/8t)
|
||||||
- macOS Big Sur 11.1 (20C69)
|
- macOS Big Sur 11.2.3 (20D91)
|
||||||
- Xcode 12.3 (12C33)
|
- Xcode 12.4 (12D4e)
|
||||||
|
|
||||||
## Limitations
|
## Limitations
|
||||||
|
|
||||||
@@ -71,14 +72,14 @@ available here: https://github.com/emacs-mirror/emacs
|
|||||||
Options:
|
Options:
|
||||||
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 8)
|
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 8)
|
||||||
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
|
||||||
--[no-]xwidgets Enable/disable XWidgets (default: enabled if supported)
|
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
|
||||||
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)
|
||||||
--[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)
|
||||||
--rsvg Enable SVG image support via librsvg, can yield a unstable build (default: disabled)
|
--[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)
|
||||||
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
|
||||||
--[no-]native-fast-boot DEPRECATED: use --[no-]native-full-aot instead
|
--work-dir DIR Specify a working directory where tarballs, sources, and builds will be stored and worked with
|
||||||
--[no-]launcher DEPRECATED: Launcher script is no longer used.
|
--plan FILE Follow given plan file, instead of using given git ref/sha
|
||||||
```
|
```
|
||||||
|
|
||||||
Resulting applications are saved to the `builds` directory in a bzip2 compressed
|
Resulting applications are saved to the `builds` directory in a bzip2 compressed
|
||||||
@@ -92,8 +93,8 @@ trash the corresponding directory from the `sources` directory.
|
|||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
||||||
To download a tarball of the `master` branch (Emacs 28.x as of writing) and
|
To download a tarball of the `master` branch (Emacs 28.x with native-compilation
|
||||||
build Emacs.app from it:
|
as of writing) and build Emacs.app from it:
|
||||||
|
|
||||||
```
|
```
|
||||||
./build-emacs-for-macos
|
./build-emacs-for-macos
|
||||||
@@ -136,24 +137,24 @@ tools seems to use it to figure out the path to Emacs' executable, including
|
|||||||
|
|
||||||
## Native-Comp
|
## Native-Comp
|
||||||
|
|
||||||
Building a Emacs.app with native-comp support
|
_Note: On 2021-04-25 the `feature/native-comp` branch was
|
||||||
([gccemacs](https://akrl.sdf.org/gccemacs.html)) from the `feature/native-comp`
|
[merged](http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=289000eee729689b0cf362a21baa40ac7f9506f6)
|
||||||
branch is now supported without much hassle thanks to the newly released
|
into `master`._
|
||||||
`libgccjit` Homebrew formula.
|
|
||||||
|
|
||||||
To build a Emacs.app with native compilation enabled, simply run:
|
The build script will automatically detect if the source tree being built
|
||||||
|
supports native-compilation, and enable it if available. You can override this
|
||||||
```
|
to force it on/off by passing `--native-comp` or `--no-native-comp`
|
||||||
./build-emacs-for-macos feature/native-comp
|
respectfully.
|
||||||
```
|
|
||||||
|
|
||||||
By default `NATIVE_FULL_AOT` is disabled which ensures a fast build by native
|
By default `NATIVE_FULL_AOT` is disabled which ensures a fast build by native
|
||||||
compiling as few lisp source files as possible to build the app. Any remaining
|
compiling as few elisp source files as possible to build Emacs itself. Any
|
||||||
lisp files will be dynamically compiled in the background the first time you use
|
remaining elisp files will be dynamically compiled in the background the first
|
||||||
them. To enable native full AoT, pass in the `--native-full-aot` option.
|
time they are used.
|
||||||
|
|
||||||
On my machine it takes around 10 minutes to build Emacs.app with
|
To enable native full Ahead-of-Time compilation, pass in the `--native-full-aot`
|
||||||
`NATIVE_FULL_AOT` disabled. With it enabled it takes around 20-25 minutes.
|
option, which will native-compile all of Emacs' elisp as built-time. On my
|
||||||
|
machine it takes around 10 minutes to build Emacs.app with `NATIVE_FULL_AOT`
|
||||||
|
disabled, and around 20-25 minutes with it enabled.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,9 @@ require 'json'
|
|||||||
require 'net/http'
|
require 'net/http'
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require 'pathname'
|
require 'pathname'
|
||||||
|
require 'time'
|
||||||
require 'uri'
|
require 'uri'
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
class Error < StandardError; end
|
class Error < StandardError; end
|
||||||
|
|
||||||
@@ -21,9 +23,9 @@ module Output
|
|||||||
|
|
||||||
def out(msg, newline: true)
|
def out(msg, newline: true)
|
||||||
if newline
|
if newline
|
||||||
puts "==> #{msg}"
|
warn "==> #{msg}"
|
||||||
else
|
else
|
||||||
print "==> #{msg}"
|
STDERR.print "==> #{msg}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -81,14 +83,16 @@ class Build
|
|||||||
|
|
||||||
def initialize(root_dir, ref = nil, options = {})
|
def initialize(root_dir, ref = nil, options = {})
|
||||||
@root_dir = root_dir
|
@root_dir = root_dir
|
||||||
@ref = ref
|
@ref = ref || 'master'
|
||||||
@options = options
|
@options = options
|
||||||
@gcc_info = GccInfo.new
|
@gcc_info = GccInfo.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def build
|
def build
|
||||||
|
load_plan(options[:plan]) if options[:plan]
|
||||||
|
|
||||||
unless meta[:sha] && meta[:date]
|
unless meta[:sha] && meta[:date]
|
||||||
err 'Failed to get commit info from GitHub API.'
|
err 'Failed to get commit info from GitHub.'
|
||||||
end
|
end
|
||||||
|
|
||||||
tarball = download_tarball(meta[:sha])
|
tarball = download_tarball(meta[:sha])
|
||||||
@@ -108,6 +112,17 @@ class Build
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def load_plan(filename)
|
||||||
|
plan = YAML.safe_load(File.read(filename), [:Time])
|
||||||
|
|
||||||
|
@meta = {
|
||||||
|
sha: plan.dig('commit', 'sha'),
|
||||||
|
ref: plan.dig('commit', 'ref'),
|
||||||
|
date: plan.dig('commit', 'date')
|
||||||
|
}
|
||||||
|
@archive_filename = plan['archive']
|
||||||
|
end
|
||||||
|
|
||||||
def tarballs_dir
|
def tarballs_dir
|
||||||
@tarballs_dir ||= File.join(root_dir, 'tarballs')
|
@tarballs_dir ||= File.join(root_dir, 'tarballs')
|
||||||
end
|
end
|
||||||
@@ -299,7 +314,7 @@ class Build
|
|||||||
configure_flags << '--with-xwidgets'
|
configure_flags << '--with-xwidgets'
|
||||||
end
|
end
|
||||||
configure_flags << native_comp_configure_flag if options[:native_comp]
|
configure_flags << native_comp_configure_flag if options[:native_comp]
|
||||||
configure_flags << '--without-rsvg' unless options[:rsvg]
|
configure_flags << '--without-rsvg' if options[:rsvg] == false
|
||||||
|
|
||||||
run_cmd './configure', *configure_flags
|
run_cmd './configure', *configure_flags
|
||||||
|
|
||||||
@@ -339,41 +354,58 @@ class Build
|
|||||||
def symlink_internals(app)
|
def symlink_internals(app)
|
||||||
return unless options[:native_comp]
|
return unless options[:native_comp]
|
||||||
|
|
||||||
info 'Creating symlinks within Emacs.app needed for native-comp'
|
|
||||||
|
|
||||||
FileUtils.cd(File.join(app, 'Contents')) do
|
FileUtils.cd(File.join(app, 'Contents')) do
|
||||||
|
# Skip creation of symlinks if *.eln files are located under
|
||||||
|
# Resources/native-lisp. Emacs is capable of finding lisp sources and
|
||||||
|
# *.eln cache files without symlinks.
|
||||||
|
return if Dir['Resources/native-lisp/**/*.eln'].any?
|
||||||
|
|
||||||
|
info 'Creating symlinks within Emacs.app needed for native-comp'
|
||||||
|
|
||||||
FileUtils.ln_s('Resources/lisp', 'lisp') unless File.exist?('lisp')
|
FileUtils.ln_s('Resources/lisp', 'lisp') unless File.exist?('lisp')
|
||||||
|
|
||||||
source = Dir['MacOS/libexec/emacs/**/eln-cache',
|
source = Dir['MacOS/libexec/emacs/**/eln-cache',
|
||||||
'MacOS/lib/emacs/**/native-lisp'].first
|
'MacOS/lib/emacs/**/native-lisp'].first
|
||||||
|
err 'Failed to find native-lisp cache directory for symlink creation.'
|
||||||
|
|
||||||
target = File.basename(source)
|
target = File.basename(source)
|
||||||
FileUtils.ln_s(source, target) unless File.exist?(target)
|
FileUtils.ln_s(source, target) unless File.exist?(target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def archive_app(app)
|
def archive_filename
|
||||||
FileUtils.mkdir_p(builds_dir)
|
return @archive_filename if @archive_filename
|
||||||
|
|
||||||
metadata = [
|
metadata = [
|
||||||
meta[:ref]&.gsub(/\W/, '-'),
|
meta[:ref]&.gsub(/\W/, '-'),
|
||||||
meta[:date],
|
meta[:date]&.strftime('%Y-%m-%d'),
|
||||||
meta[:sha][0..6],
|
meta[:sha][0..6],
|
||||||
"macOS-#{OS.version}",
|
"macOS-#{OS.version}",
|
||||||
OS.arch
|
OS.arch
|
||||||
].compact
|
].compact
|
||||||
|
|
||||||
filename = "Emacs.app-[#{metadata.join('][')}].tbz"
|
filename = "Emacs.app-[#{metadata.join('][')}].tbz"
|
||||||
target = "#{builds_dir}/#{filename}"
|
@archive_filename = File.join(builds_dir, filename)
|
||||||
|
end
|
||||||
|
|
||||||
|
def archive_app(app)
|
||||||
|
filename = File.basename(archive_filename)
|
||||||
|
target_dir = File.dirname(archive_filename)
|
||||||
|
relative_target_dir = target_dir.gsub(root_dir + '/', '')
|
||||||
|
|
||||||
|
FileUtils.mkdir_p(target_dir)
|
||||||
|
|
||||||
app_base = File.basename(app)
|
app_base = File.basename(app)
|
||||||
app_dir = File.dirname(app)
|
app_dir = File.dirname(app)
|
||||||
|
|
||||||
if !File.exist?(target)
|
if !File.exist?(archive_filename)
|
||||||
info "Creating #{filename} archive in \"#{builds_dir}\"..."
|
info "Creating #{filename} archive in \"#{relative_target_dir}\"..."
|
||||||
FileUtils.cd(app_dir) { system('tar', '-cjf', target, app_base) }
|
FileUtils.cd(app_dir) do
|
||||||
|
system('tar', '-cjf', archive_filename, app_base)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
info "#{filename} archive exists in " \
|
info "#{filename} archive exists in " \
|
||||||
"#{builds_dir.gsub(root_dir + '/', '')}, skipping archving."
|
"#{relative_target_dir}, skipping archving."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -396,6 +428,7 @@ class Build
|
|||||||
return @meta if @meta
|
return @meta if @meta
|
||||||
|
|
||||||
ref_sha = options[:git_sha] || ref
|
ref_sha = options[:git_sha] || ref
|
||||||
|
info "Fetching info for git ref: #{ref_sha}"
|
||||||
url = format(LATEST_URL, ref_sha)
|
url = format(LATEST_URL, ref_sha)
|
||||||
commit_json = http_get(url)
|
commit_json = http_get(url)
|
||||||
err "Failed to get commit info about: #{ref_sha}" if commit_json.nil?
|
err "Failed to get commit info about: #{ref_sha}" if commit_json.nil?
|
||||||
@@ -403,7 +436,7 @@ class Build
|
|||||||
commit = JSON.parse(commit_json)
|
commit = JSON.parse(commit_json)
|
||||||
meta = {
|
meta = {
|
||||||
sha: commit['sha'],
|
sha: commit['sha'],
|
||||||
date: Date.parse(commit['commit']['committer']['date'])
|
date: Time.parse(commit['commit']['committer']['date'])
|
||||||
}
|
}
|
||||||
meta[:ref] = ref if ref && ref[0..6] != meta[:sha][0..6]
|
meta[:ref] = ref if ref && ref[0..6] != meta[:sha][0..6]
|
||||||
|
|
||||||
@@ -552,7 +585,7 @@ class AbstractEmbedder
|
|||||||
private
|
private
|
||||||
|
|
||||||
def invocation_dir
|
def invocation_dir
|
||||||
File.join(app, 'Contents/MacOS')
|
File.join(app, 'Contents', 'MacOS')
|
||||||
end
|
end
|
||||||
|
|
||||||
def bin
|
def bin
|
||||||
@@ -584,7 +617,6 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
FileUtils.cd(File.dirname(app)) do
|
FileUtils.cd(File.dirname(app)) do
|
||||||
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?
|
||||||
self_ref_libs(binary)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -596,6 +628,16 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
Pathname.new(File.dirname(exe))
|
Pathname.new(File.dirname(exe))
|
||||||
).to_s
|
).to_s
|
||||||
|
|
||||||
|
rpath = File.join('@executable_path', rel_path)
|
||||||
|
rpaths = `otool -l "#{exe}" | grep -A 2 'cmd LC_RPATH' | grep 'path'`
|
||||||
|
|
||||||
|
unless rpaths.include?(rpath)
|
||||||
|
while_writable(exe) do
|
||||||
|
system('install_name_tool', '-add_rpath',
|
||||||
|
File.join('@executable_path', rel_path), exe)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
`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})
|
||||||
next unless match && match[1].start_with?(lib_source)
|
next unless match && match[1].start_with?(lib_source)
|
||||||
@@ -640,35 +682,11 @@ class LibEmbedder < AbstractEmbedder
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self_ref_libs(exe)
|
|
||||||
rel_path = Pathname.new(lib_dir).relative_path_from(
|
|
||||||
Pathname.new(File.dirname(exe))
|
|
||||||
).to_s
|
|
||||||
lib_paths ||= Dir.glob("#{lib_dir}/*").select { |f| File.file?(f) }
|
|
||||||
libs = lib_paths.map { |f| File.basename(f) }
|
|
||||||
|
|
||||||
([exe] + lib_paths).each do |bin_path|
|
|
||||||
`otool -L "#{bin_path}"`.split("\n")[1..-1].each do |line|
|
|
||||||
match = line.match(%r{^\s+(.+/(lib[^/ ]+))\s})
|
|
||||||
next unless match
|
|
||||||
next if match[1].start_with?('@executable_path/')
|
|
||||||
next unless libs.include?(match[2])
|
|
||||||
|
|
||||||
while_writable(bin_path) do
|
|
||||||
system(
|
|
||||||
'install_name_tool', '-change', match[1],
|
|
||||||
File.join('@executable_path', rel_path, match[2].to_s),
|
|
||||||
bin_path
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def while_writable(file)
|
def while_writable(file)
|
||||||
mode = File.stat(file).mode
|
mode = File.stat(file).mode
|
||||||
File.chmod(0o775, file)
|
File.chmod(0o775, file)
|
||||||
yield
|
yield
|
||||||
|
ensure
|
||||||
File.chmod(mode, file)
|
File.chmod(mode, file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -695,7 +713,9 @@ class GccLibEmbedder < AbstractEmbedder
|
|||||||
|
|
||||||
FileUtils.mkdir_p(File.dirname(target_dir))
|
FileUtils.mkdir_p(File.dirname(target_dir))
|
||||||
FileUtils.cp_r(source_dir, target_dir)
|
FileUtils.cp_r(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)
|
||||||
|
FileUtils.mv(source_darwin_dir, target_darwin_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@@ -708,9 +728,21 @@ class GccLibEmbedder < AbstractEmbedder
|
|||||||
File.join(invocation_dir, gcc_info.relative_lib_dir)
|
File.join(invocation_dir, gcc_info.relative_lib_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def source_darwin_dir
|
||||||
|
File.join(invocation_dir, gcc_info.relative_darwin_lib_dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
def target_darwin_dir
|
||||||
|
File.join(invocation_dir, gcc_info.sanitized_relative_darwin_lib_dir)
|
||||||
|
end
|
||||||
|
|
||||||
def source_dir
|
def source_dir
|
||||||
gcc_info.lib_dir
|
gcc_info.lib_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def relative_dir(path, root)
|
||||||
|
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class GccInfo
|
class GccInfo
|
||||||
@@ -750,6 +782,17 @@ class GccInfo
|
|||||||
@relative_darwin_lib_dir ||= relative_dir(darwin_lib_dir, root_dir)
|
@relative_darwin_lib_dir ||= relative_dir(darwin_lib_dir, root_dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sanitize folder name with full "MAJOR.MINOR.PATCH" version number to just
|
||||||
|
# the MAJOR version. Apple's codesign CLI tool throws a "bundle format
|
||||||
|
# unrecognized" error if there are any folders with two dots in their name
|
||||||
|
# within the Emacs.app application bundle.
|
||||||
|
def sanitized_relative_darwin_lib_dir
|
||||||
|
@sanitized_relative_darwin_lib_dir ||= File.join(
|
||||||
|
File.dirname(relative_darwin_lib_dir),
|
||||||
|
File.basename(relative_darwin_lib_dir).split('.').first
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def libgccjit_root_dir
|
def libgccjit_root_dir
|
||||||
@libgccjit_root_dir ||= `brew --prefix libgccjit`.chomp
|
@libgccjit_root_dir ||= `brew --prefix libgccjit`.chomp
|
||||||
end
|
end
|
||||||
@@ -794,18 +837,16 @@ class GccInfo
|
|||||||
private
|
private
|
||||||
|
|
||||||
def relative_dir(path, root)
|
def relative_dir(path, root)
|
||||||
root += '/' unless root[-1] == '/'
|
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
||||||
return if path[0..root.size - 1] != root
|
|
||||||
|
|
||||||
path[root.size..-1]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if __FILE__ == $PROGRAM_NAME
|
if __FILE__ == $PROGRAM_NAME
|
||||||
cli_options = {
|
cli_options = {
|
||||||
|
work_dir: File.expand_path(__dir__),
|
||||||
native_full_aot: false,
|
native_full_aot: false,
|
||||||
parallel: Etc.nprocessors,
|
parallel: Etc.nprocessors,
|
||||||
rsvg: false,
|
rsvg: true,
|
||||||
xwidgets: true
|
xwidgets: true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,14 +867,15 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
cli_options[:parallel] = v
|
cli_options[:parallel] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--git-sha SHA', 'Override detected git SHA of specified ' \
|
opts.on('--git-sha SHA',
|
||||||
'branch allowing builds of old commits') do |v|
|
'Override detected git SHA of specified ' \
|
||||||
|
'branch allowing builds of old commits') do |v|
|
||||||
cli_options[:git_sha] = v
|
cli_options[:git_sha] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--[no-]xwidgets',
|
opts.on('--[no-]xwidgets',
|
||||||
'Enable/disable XWidgets ' \
|
'Enable/disable XWidgets if supported ' \
|
||||||
'(default: enabled if supported)') do |v|
|
'(default: enabled)') do |v|
|
||||||
cli_options[:xwidgets] = v
|
cli_options[:xwidgets] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -849,9 +891,10 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
cli_options[:native_full_aot] = v
|
cli_options[:native_full_aot] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--rsvg', 'Enable SVG image support via librsvg, ' \
|
opts.on('--[no-]rsvg',
|
||||||
'can yield a unstable build (default: disabled)') do
|
'Enable/disable SVG image support via librsvg ' \
|
||||||
cli_options[:rsvg] = true
|
'(default: enabled)') do |v|
|
||||||
|
cli_options[:rsvg] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--no-titlebar', 'Apply no-titlebar patch (default: disabled)') do
|
opts.on('--no-titlebar', 'Apply no-titlebar patch (default: disabled)') do
|
||||||
@@ -863,25 +906,22 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
cli_options[:no_frame_refocus] = true
|
cli_options[:no_frame_refocus] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--[no-]native-fast-boot',
|
opts.on('--work-dir DIR',
|
||||||
'DEPRECATED: use --[no-]native-full-aot instead') do |v|
|
'Specify a working directory where tarballs, sources, and ' \
|
||||||
if v
|
'builds will be stored and worked with') do |v|
|
||||||
raise Error, '--native-fast-boot option is deprecated, ' \
|
cli_options[:work_dir] = v
|
||||||
'use --no-native-full-aot instead'
|
|
||||||
else
|
|
||||||
raise Error, '--no-native-fast-boot option is deprecated, ' \
|
|
||||||
'use --native-full-aot instead'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on('--[no-]launcher',
|
opts.on(
|
||||||
'DEPRECATED: Launcher script is no longer used.') do |_|
|
'--plan FILE',
|
||||||
raise Error, '--[no-]launcher option is deprecated, launcher ' \
|
'Follow given plan file, instead of using given git ref/sha'
|
||||||
'script is no longer used.'
|
) do |v|
|
||||||
|
cli_options[:plan] = v
|
||||||
end
|
end
|
||||||
end.parse!
|
end.parse!
|
||||||
|
|
||||||
Build.new(File.expand_path(__dir__), ARGV.shift, cli_options).build
|
work_dir = cli_options.delete(:work_dir)
|
||||||
|
Build.new(work_dir, ARGV.shift, cli_options).build
|
||||||
rescue Error => e
|
rescue Error => e
|
||||||
warn "ERROR: #{e.message}"
|
warn "ERROR: #{e.message}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
||||||
index 4036080976..2ff8dbd74c 100644
|
index 8c638312b0..87af889ef4 100644
|
||||||
--- a/lisp/emacs-lisp/comp.el
|
--- a/lisp/emacs-lisp/comp.el
|
||||||
+++ b/lisp/emacs-lisp/comp.el
|
+++ b/lisp/emacs-lisp/comp.el
|
||||||
@@ -4079,6 +4079,52 @@ of (commands) to run simultaneously."
|
@@ -4215,6 +4215,52 @@ native-compile-async
|
||||||
(let ((load (not (not load))))
|
(let ((load (not (not load))))
|
||||||
(native--compile-async paths recursively load selector)))
|
(native--compile-async files recursively load selector)))
|
||||||
|
|
||||||
+;;;###autoload
|
+;;;###autoload
|
||||||
+(defun native-compile-setup-environment-variables (&rest _args)
|
+(defun native-compile-setup-environment-variables (&rest _args)
|
||||||
@@ -19,7 +19,7 @@ index 4036080976..2ff8dbd74c 100644
|
|||||||
+ "<%= relative_lib_dir %>"
|
+ "<%= relative_lib_dir %>"
|
||||||
+ invocation-directory))
|
+ invocation-directory))
|
||||||
+ (darwin-dir (expand-file-name
|
+ (darwin-dir (expand-file-name
|
||||||
+ "<%= relative_darwin_lib_dir %>"
|
+ "<%= sanitized_relative_darwin_lib_dir %>"
|
||||||
+ invocation-directory))
|
+ invocation-directory))
|
||||||
+ (lib-paths (list)))
|
+ (lib-paths (list)))
|
||||||
+
|
+
|
||||||
@@ -54,4 +54,4 @@ index 4036080976..2ff8dbd74c 100644
|
|||||||
+
|
+
|
||||||
(provide 'comp)
|
(provide 'comp)
|
||||||
|
|
||||||
;;; comp.el ends here
|
;; LocalWords: limplified limplified limplification limplify Limple LIMPLE libgccjit elc eln
|
||||||
|
|||||||
Reference in New Issue
Block a user