mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
5a61a72a73
|
|||
| 9cdf67e71b | |||
|
946856e9c2
|
|||
|
|
2247158051
|
||
|
4a7c507858
|
|||
|
884f1607f6
|
|||
|
c7daa1350b
|
|||
|
9223ff8e28
|
|||
|
70bf6b05d5
|
|||
|
8936f4762a
|
23
CHANGELOG.md
23
CHANGELOG.md
@@ -2,6 +2,29 @@
|
|||||||
|
|
||||||
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.3](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.2...0.4.3) (2020-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **big-sur:** add Xcode CLI tools lib directory to runtime LIBRARY_PATH ([946856e](https://github.com/jimeh/build-emacs-for-macos/commit/946856e9c242d4a6fb5f839d8cae0acfafecdfc6))
|
||||||
|
* **big-sur:** added support for building on Big Sur ([2247158](https://github.com/jimeh/build-emacs-for-macos/commit/2247158051d0f59933569b6974b2b5269f13c79e))
|
||||||
|
|
||||||
|
### [0.4.2](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.1...0.4.2) (2020-12-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **cli:** avoid error if --git-sha is used without a branch/tag/sha argument ([884f160](https://github.com/jimeh/build-emacs-for-macos/commit/884f1607f6707ca187b1abfb0ce562757d872230)), closes [#21](https://github.com/jimeh/build-emacs-for-macos/issues/21)
|
||||||
|
* **native_comp:** update env setup patch for recent changes to comp.el ([c7daa13](https://github.com/jimeh/build-emacs-for-macos/commit/c7daa1350bd69df172ce6484c54189d2cee8d97e))
|
||||||
|
|
||||||
|
### [0.4.1](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.0...0.4.1) (2020-10-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **native_comp:** remove patch based on feature/native-comp-macos-fixes branch ([70bf6b0](https://github.com/jimeh/build-emacs-for-macos/commit/70bf6b05d584976632b2fd2947c0bf692f5b6421))
|
||||||
|
|
||||||
## [0.4.0](https://github.com/jimeh/build-emacs-for-macos/compare/0.3.0...0.4.0) (2020-10-04)
|
## [0.4.0](https://github.com/jimeh/build-emacs-for-macos/compare/0.3.0...0.4.0) (2020-10-04)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -112,6 +112,30 @@ All sources as downloaded as tarballs from the
|
|||||||
to get a list of tags/branches available to install, simply check said
|
to get a list of tags/branches available to install, simply check said
|
||||||
repository.
|
repository.
|
||||||
|
|
||||||
|
## Use Self-Contained Emacs.app as `emacs` CLI Tool
|
||||||
|
|
||||||
|
As the application bundle is self-contained, the main executable needs to be run
|
||||||
|
from within the application bundle. This means a simple symlink to
|
||||||
|
`Emacs.app/Contents/MacOS/Emacs` will not work. Instead the best approach is to
|
||||||
|
create a shell alias called `emacs` pointing to the right place.
|
||||||
|
|
||||||
|
Personally I use something similar to this:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then
|
||||||
|
export EMACS="/Applications/Emacs.app/Contents/MacOS/Emacs"
|
||||||
|
alias emacs="$EMACS -nw"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
|
||||||
|
alias emacsclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
|
||||||
|
fi
|
||||||
|
```
|
||||||
|
|
||||||
|
Setting the `EMACS` variable to the binary path seems to be a good idea, as some
|
||||||
|
tools seems to use it to figure out the path to Emacs' executable, including
|
||||||
|
[doom-emacs](https://github.com/hlissner/doom-emacs)' `doom` CLI tool.
|
||||||
|
|
||||||
## Native-Comp
|
## Native-Comp
|
||||||
|
|
||||||
Building a Emacs.app with native-comp support
|
Building a Emacs.app with native-comp support
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Build
|
|||||||
attr_reader :ref
|
attr_reader :ref
|
||||||
attr_reader :options
|
attr_reader :options
|
||||||
|
|
||||||
def initialize(root_dir, ref = 'master', options = {})
|
def initialize(root_dir, ref = nil, options = {})
|
||||||
@root_dir = root_dir
|
@root_dir = root_dir
|
||||||
@ref = ref
|
@ref = ref
|
||||||
@options = options
|
@options = options
|
||||||
@@ -258,10 +258,6 @@ class Build
|
|||||||
verify_native_comp
|
verify_native_comp
|
||||||
verify_libgccjit
|
verify_libgccjit
|
||||||
|
|
||||||
if options[:macos_fixes] && ref != 'feature/native-comp-macos-fixes'
|
|
||||||
apply_native_comp_macos_fixes
|
|
||||||
end
|
|
||||||
|
|
||||||
apply_native_comp_env_setup_patch(source)
|
apply_native_comp_env_setup_patch(source)
|
||||||
|
|
||||||
ENV['CFLAGS'] = [
|
ENV['CFLAGS'] = [
|
||||||
@@ -302,6 +298,11 @@ class Build
|
|||||||
"#{brew_dir}/opt/texinfo/bin",
|
"#{brew_dir}/opt/texinfo/bin",
|
||||||
ENV['PATH']
|
ENV['PATH']
|
||||||
].compact.join(':')
|
].compact.join(':')
|
||||||
|
|
||||||
|
ENV['LIBRARY_PATH'] = [
|
||||||
|
ENV['LIBRARY_PATH'],
|
||||||
|
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
|
||||||
|
].compact.join(':')
|
||||||
|
|
||||||
configure_flags = [
|
configure_flags = [
|
||||||
'--with-ns',
|
'--with-ns',
|
||||||
@@ -370,12 +371,12 @@ class Build
|
|||||||
FileUtils.mkdir_p(builds_dir)
|
FileUtils.mkdir_p(builds_dir)
|
||||||
|
|
||||||
metadata = [
|
metadata = [
|
||||||
ref.gsub(/\W/, '-'),
|
meta[:ref]&.gsub(/\W/, '-'),
|
||||||
meta[:date],
|
meta[:date],
|
||||||
meta[:sha][0..6],
|
meta[:sha][0..6],
|
||||||
"macOS-#{OS.version}",
|
"macOS-#{OS.version}",
|
||||||
OS.arch
|
OS.arch
|
||||||
]
|
].compact
|
||||||
|
|
||||||
filename = "Emacs.app-[#{metadata.join('][')}].tbz"
|
filename = "Emacs.app-[#{metadata.join('][')}].tbz"
|
||||||
target = "#{builds_dir}/#{filename}"
|
target = "#{builds_dir}/#{filename}"
|
||||||
@@ -416,11 +417,13 @@ class Build
|
|||||||
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?
|
||||||
|
|
||||||
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: Date.parse(commit['commit']['committer']['date'])
|
||||||
}
|
}
|
||||||
|
meta[:ref] = ref if ref && ref[0..6] != meta[:sha][0..6]
|
||||||
|
|
||||||
|
@meta = meta
|
||||||
end
|
end
|
||||||
|
|
||||||
def http_get(url)
|
def http_get(url)
|
||||||
@@ -446,37 +449,6 @@ class Build
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_native_comp_macos_fixes
|
|
||||||
filename = 'Makefile.in'
|
|
||||||
pattern = /^src: Makefile\n(.*BIN_DESTDIR.*)\nblessmail: Makefile src\n/m
|
|
||||||
content = File.read(filename).gsub(pattern) do
|
|
||||||
old_src_body = Regexp.last_match(1).strip
|
|
||||||
|
|
||||||
# check if already patched
|
|
||||||
if old_src_body.include?('BIN_DESTDIR=\'${ns_appbindir}/\'')
|
|
||||||
return old_src_body
|
|
||||||
end
|
|
||||||
|
|
||||||
self_contained = old_src_body.gsub(
|
|
||||||
'BIN_DESTDIR=\'$(DESTDIR)${bindir}/\'',
|
|
||||||
'BIN_DESTDIR=\'${ns_appbindir}/\''
|
|
||||||
)
|
|
||||||
|
|
||||||
<<~REPLACEMENT
|
|
||||||
src: Makefile
|
|
||||||
ifeq (${ns_self_contained},no)
|
|
||||||
\t#{old_src_body}
|
|
||||||
else
|
|
||||||
\t#{self_contained}
|
|
||||||
endif
|
|
||||||
|
|
||||||
blessmail: Makefile src
|
|
||||||
REPLACEMENT
|
|
||||||
end
|
|
||||||
|
|
||||||
File.open(filename, 'w') { |f| f.write(content) }
|
|
||||||
end
|
|
||||||
|
|
||||||
def effective_version
|
def effective_version
|
||||||
@effective_version ||= begin
|
@effective_version ||= begin
|
||||||
case ref
|
case ref
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
|||||||
index 25e2de9..bcedd31 100644
|
index 25e2de9..bcedd31 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
|
||||||
@@ -2801,6 +2801,45 @@ queued with LOAD %"
|
@@ -2801,6 +2801,57 @@ queued with LOAD %"
|
||||||
(comp-run-async-workers)
|
(comp-run-async-workers)
|
||||||
(message "Compilation started."))))
|
(message "Compilation started."))))
|
||||||
|
|
||||||
@@ -13,6 +13,8 @@ index 25e2de9..bcedd31 100644
|
|||||||
+ (string-match-p "\.app\/Contents\/MacOS\/?$"
|
+ (string-match-p "\.app\/Contents\/MacOS\/?$"
|
||||||
+ invocation-directory))
|
+ invocation-directory))
|
||||||
+ (let* ((library-path-env (getenv "LIBRARY_PATH"))
|
+ (let* ((library-path-env (getenv "LIBRARY_PATH"))
|
||||||
|
+ (devtools-dir
|
||||||
|
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
||||||
+ (gcc-base-dir (concat invocation-directory "lib/gcc"))
|
+ (gcc-base-dir (concat invocation-directory "lib/gcc"))
|
||||||
+ (gcc-version (car (seq-filter
|
+ (gcc-version (car (seq-filter
|
||||||
+ (lambda (dir) (string-match-p "^[0-9]+$" dir))
|
+ (lambda (dir) (string-match-p "^[0-9]+$" dir))
|
||||||
@@ -28,6 +30,8 @@ index 25e2de9..bcedd31 100644
|
|||||||
+ (darwin-dir (concat darwin-base-dir "/" darwin-version))
|
+ (darwin-dir (concat darwin-base-dir "/" darwin-version))
|
||||||
+ (lib-paths (append
|
+ (lib-paths (append
|
||||||
+ (list gcc-dir darwin-dir)
|
+ (list gcc-dir darwin-dir)
|
||||||
|
+ (if (file-directory-p devtools-dir)
|
||||||
|
+ (list devtools-dir) (list))
|
||||||
+ (if library-path-env (list library-path-env) (list)))))
|
+ (if library-path-env (list library-path-env) (list)))))
|
||||||
+
|
+
|
||||||
+ (when (and gcc-dir darwin-dir)
|
+ (when (and gcc-dir darwin-dir)
|
||||||
@@ -36,14 +40,22 @@ index 25e2de9..bcedd31 100644
|
|||||||
+ ;; Remove advice, as it only needs to run once.
|
+ ;; Remove advice, as it only needs to run once.
|
||||||
+ (advice-remove 'native-compile
|
+ (advice-remove 'native-compile
|
||||||
+ 'native-compile-setup-environment-variables)
|
+ 'native-compile-setup-environment-variables)
|
||||||
|
+ (advice-remove 'comp--native-compile
|
||||||
|
+ 'native-compile-setup-environment-variables)
|
||||||
+ (advice-remove 'native-compile-async
|
+ (advice-remove 'native-compile-async
|
||||||
|
+ 'native-compile-setup-environment-variables)
|
||||||
|
+ (advice-remove 'native--compile-async
|
||||||
+ 'native-compile-setup-environment-variables))
|
+ 'native-compile-setup-environment-variables))
|
||||||
+
|
+
|
||||||
+;; Ensure environment setup runs before any native compilation.
|
+;; Ensure environment setup runs before any native compilation.
|
||||||
+(advice-add 'native-compile :before
|
+(advice-add 'native-compile :before
|
||||||
+ 'native-compile-setup-environment-variables)
|
+ 'native-compile-setup-environment-variables)
|
||||||
|
+(advice-add 'comp--native-compile :before
|
||||||
|
+ 'native-compile-setup-environment-variables)
|
||||||
+(advice-add 'native-compile-async :before
|
+(advice-add 'native-compile-async :before
|
||||||
+ 'native-compile-setup-environment-variables)
|
+ 'native-compile-setup-environment-variables)
|
||||||
|
+(advice-add 'native--compile-async :before
|
||||||
|
+ 'native-compile-setup-environment-variables)
|
||||||
+
|
+
|
||||||
(provide 'comp)
|
(provide 'comp)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user