mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
3d6caac962
|
|||
| 11de27358d | |||
|
8237aa9272
|
|||
|
3ffe83c94e
|
@@ -2,6 +2,13 @@
|
|||||||
|
|
||||||
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.14](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.13...0.4.14) (2021-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **cli:** add "emacs" CLI launcher script to Emacs.app/Conents/MacOS/bin ([8237aa9](https://github.com/jimeh/build-emacs-for-macos/commit/8237aa9272ce1d13a412b2495cbaa90df38d928b)), closes [#41](https://github.com/jimeh/build-emacs-for-macos/issues/41)
|
||||||
|
|
||||||
### [0.4.13](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.12...0.4.13) (2021-05-22)
|
### [0.4.13](https://github.com/jimeh/build-emacs-for-macos/compare/0.4.12...0.4.13) (2021-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
63
README.md
63
README.md
@@ -111,29 +111,25 @@ 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
|
## Use Emacs.app as `emacs` CLI Tool
|
||||||
|
|
||||||
As the application bundle is self-contained, the main executable needs to be run
|
Builds come with a custom `emacs` shell script launcher for use from the command
|
||||||
from within the application bundle. This means a simple symlink to
|
line. It makes sure to use the main `Emacs.app/Contents/MacOS/Emacs` executable
|
||||||
`Emacs.app/Contents/MacOS/Emacs` will not work. Instead the best approach is to
|
from the correct path, ensuring it finds all the relevant dependencies within
|
||||||
create a shell alias called `emacs` pointing to the right place.
|
the Emacs.app bundle.
|
||||||
|
|
||||||
Personally I use something similar to this:
|
To use it, simply add `Emacs.app/Contents/MacOS/bin` to your `PATH`. For
|
||||||
|
example, if you place Emacs.app in `/Applications`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then
|
if [ -d "/Applications/Emacs.app/Contents/MacOS/bin" ]; then
|
||||||
export EMACS="/Applications/Emacs.app/Contents/MacOS/Emacs"
|
export PATH="/Applications/Emacs.app/Contents/MacOS/bin:$PATH"
|
||||||
alias emacs="$EMACS -nw"
|
alias emacs="emacs -nw" # Always launch "emacs" in terminal mode.
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
|
|
||||||
alias emacsclient="/Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
|
|
||||||
fi
|
fi
|
||||||
```
|
```
|
||||||
|
|
||||||
Setting the `EMACS` variable to the binary path seems to be a good idea, as some
|
If you want `emacs` in your terminal to launch a GUI instance of Emacs, don't
|
||||||
tools seems to use it to figure out the path to Emacs' executable, including
|
use the alias from the above example.
|
||||||
[doom-emacs](https://github.com/hlissner/doom-emacs)' `doom` CLI tool.
|
|
||||||
|
|
||||||
## Native-Comp
|
## Native-Comp
|
||||||
|
|
||||||
@@ -142,9 +138,9 @@ _Note: On 2021-04-25 the `feature/native-comp` branch was
|
|||||||
into `master`._
|
into `master`._
|
||||||
|
|
||||||
The build script will automatically detect if the source tree being built
|
The build script will automatically detect if the source tree being built
|
||||||
supports native-compilation, and enable it if available. You can override this
|
supports native-compilation, and enable it if available. You can override the
|
||||||
to force it on/off by passing `--native-comp` or `--no-native-comp`
|
auto-detection logic to force enable or force disable native-compilation by
|
||||||
respectfully.
|
passing `--native-comp` or `--no-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 elisp source files as possible to build Emacs itself. Any
|
compiling as few elisp source files as possible to build Emacs itself. Any
|
||||||
@@ -152,32 +148,39 @@ remaining elisp files will be dynamically compiled in the background the first
|
|||||||
time they are used.
|
time they are used.
|
||||||
|
|
||||||
To enable native full Ahead-of-Time compilation, pass in the `--native-full-aot`
|
To enable native full Ahead-of-Time compilation, pass in the `--native-full-aot`
|
||||||
option, which will native-compile all of Emacs' elisp as built-time. On my
|
option, which will native-compile all of Emacs' elisp at built-time. On my
|
||||||
machine it takes around 10 minutes to build Emacs.app with `NATIVE_FULL_AOT`
|
machine it takes around 10 minutes to build Emacs.app with `NATIVE_FULL_AOT`
|
||||||
disabled, and around 20-25 minutes with it enabled.
|
disabled, and around 20-25 minutes with it enabled.
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
Add the following near the top of your `early-init.el` or `init.el`:
|
#### Native-Lisp Cache Directory
|
||||||
|
|
||||||
```elisp
|
|
||||||
(setq comp-speed 2)
|
|
||||||
```
|
|
||||||
|
|
||||||
By default natively compiled `*.eln` files will be cached in
|
By default natively compiled `*.eln` files will be cached in
|
||||||
`~/.emacs.d/eln-cache/`. If you want to customize that, simply set a new path as
|
`~/.emacs.d/eln-cache/`. If you want to customize that, simply set a new path as
|
||||||
the first element of the `comp-eln-load-path` variable. The path string must end
|
the first element of the `native-comp-eln-load-path` variable. The path string
|
||||||
with a `/`.
|
must end with a `/`.
|
||||||
|
|
||||||
Below is an example which stores all compiled `*.eln` files in `cache/eln-cache`
|
Below is an example which stores all compiled `*.eln` files in `cache/eln-cache`
|
||||||
within your Emacs configuration directory:
|
within your Emacs configuration directory:
|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(when (boundp 'comp-eln-load-path)
|
(when (boundp 'native-comp-eln-load-path)
|
||||||
(setcar comp-eln-load-path
|
(setcar native-comp-eln-load-path
|
||||||
(expand-file-name "cache/eln-cache/" user-emacs-directory)))
|
(expand-file-name "cache/eln-cache/" user-emacs-directory)))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Compilation Warnings
|
||||||
|
|
||||||
|
By default any warnings encountered during async native compilation will pop up
|
||||||
|
a warnings buffer. As this tends to happen rather frequently with a lot of
|
||||||
|
packages, it can get annoying. You can disable showing these warnings by setting
|
||||||
|
`native-comp-async-report-warnings-errors` to `nil`:
|
||||||
|
|
||||||
|
```elisp
|
||||||
|
(setq native-comp-async-report-warnings-errors nil)
|
||||||
|
```
|
||||||
|
|
||||||
### Issues
|
### Issues
|
||||||
|
|
||||||
Please see all issues with the
|
Please see all issues with the
|
||||||
@@ -188,7 +191,7 @@ types of issues and or behavior you can expect.
|
|||||||
### Known Good Commits/Builds
|
### Known Good Commits/Builds
|
||||||
|
|
||||||
A list of known "good" commits which produce working builds is tracked in:
|
A list of known "good" commits which produce working builds is tracked in:
|
||||||
[#6 Known good commits of feature/native-comp branch](https://github.com/jimeh/build-emacs-for-macos/issues/6)
|
[#6 Known good commits for native-comp](https://github.com/jimeh/build-emacs-for-macos/issues/6)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ class Build
|
|||||||
|
|
||||||
app = compile_source(@source_dir)
|
app = compile_source(@source_dir)
|
||||||
symlink_internals(app)
|
symlink_internals(app)
|
||||||
|
add_cli_helper(app)
|
||||||
|
|
||||||
LibEmbedder.new(app, brew_dir, extra_libs).embed
|
LibEmbedder.new(app, brew_dir, extra_libs).embed
|
||||||
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
||||||
@@ -373,6 +374,18 @@ class Build
|
|||||||
end
|
end
|
||||||
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 archive_filename
|
def archive_filename
|
||||||
return @archive_filename if @archive_filename
|
return @archive_filename if @archive_filename
|
||||||
|
|
||||||
|
|||||||
23
helper/emacs-cli.bash
Executable file
23
helper/emacs-cli.bash
Executable file
@@ -0,0 +1,23 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
resolve_link() {
|
||||||
|
"$(type -p greadlink readlink | head -1)" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
abs_dirname() {
|
||||||
|
local path="$1"
|
||||||
|
local name
|
||||||
|
local cwd
|
||||||
|
cwd="$(pwd)"
|
||||||
|
|
||||||
|
while [ -n "$path" ]; do
|
||||||
|
cd "${path%/*}" || exit 1
|
||||||
|
name="${path##*/}"
|
||||||
|
path="$(resolve_link "$name" || true)"
|
||||||
|
done
|
||||||
|
|
||||||
|
pwd
|
||||||
|
cd "$cwd" || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
exec "$(dirname "$(abs_dirname "$0")")/Emacs" "$@"
|
||||||
Reference in New Issue
Block a user