mirror of
https://github.com/jimeh/build-emacs-for-macos.git
synced 2026-02-19 13:06:38 +00:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
bfa5bcf79b
|
|||
| 02d85f899f | |||
|
aeb3a75e5c
|
|||
|
|
e0fd2b16eb
|
||
|
d24ac084b7
|
|||
| 159a7333de | |||
|
b582523642
|
|||
|
4f1e748df2
|
|||
|
d984633991
|
|||
|
616f74d624
|
|||
|
d7963b7664
|
|||
|
a20a8456ab
|
|||
|
8ad3ff4f53
|
|||
|
e31f5aaf93
|
|||
|
c2fb07fdb8
|
|||
|
07e0e3dacd
|
|||
|
efddb9ef92
|
|||
| f7f4c0433a | |||
|
cbd8cb27b6
|
|||
|
656b96510a
|
|||
|
084776db6b
|
|||
|
1e6d6cc6cf
|
|||
|
68ef4c066c
|
|||
|
d476fd33ec
|
|||
| baa5930467 | |||
|
743b10c751
|
|||
|
59f1bcd3e8
|
|||
| e767e284b7 | |||
|
8129a2e93b
|
|||
|
4ae288cae3
|
|||
|
3bd78d130a
|
|||
|
fb5362ce18
|
|||
|
1a34a9504a
|
|||
| 8513521d29 | |||
|
88bbefadc6
|
|||
|
f1bf1d93b8
|
|||
|
8a467b0d43
|
|||
|
9c29f721b4
|
|||
|
4ac71ddf39
|
|||
|
d338c136db
|
|||
|
d054a17fc7
|
|||
|
4030ceb9ca
|
|||
|
ad1a7dd62c
|
|||
| 665e6addec | |||
|
7f2aba0e4e
|
|||
|
be326b22aa
|
|||
|
ef4f2ad930
|
|||
|
2293c87fc9
|
|||
|
97178bf77a
|
|||
|
591c39e629
|
2
Brewfile
2
Brewfile
@@ -3,6 +3,7 @@
|
|||||||
brew 'autoconf'
|
brew 'autoconf'
|
||||||
brew 'coreutils'
|
brew 'coreutils'
|
||||||
brew 'curl'
|
brew 'curl'
|
||||||
|
brew 'dbus'
|
||||||
brew 'expat'
|
brew 'expat'
|
||||||
brew 'gcc'
|
brew 'gcc'
|
||||||
brew 'gmp'
|
brew 'gmp'
|
||||||
@@ -22,5 +23,6 @@ brew 'make'
|
|||||||
brew 'ncurses'
|
brew 'ncurses'
|
||||||
brew 'nettle'
|
brew 'nettle'
|
||||||
brew 'pkg-config'
|
brew 'pkg-config'
|
||||||
|
brew 'sqlite'
|
||||||
brew 'texinfo'
|
brew 'texinfo'
|
||||||
brew 'zlib'
|
brew 'zlib'
|
||||||
|
|||||||
109
CHANGELOG.md
109
CHANGELOG.md
@@ -2,6 +2,115 @@
|
|||||||
|
|
||||||
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.35](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.34...v0.6.35) (2022-08-10)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native-comp:** compatibility with libgccjit 12 homebrew formula ([e0fd2b1](https://github.com/jimeh/build-emacs-for-macos/commit/e0fd2b16eb91ac5a98ed4ec31f4773ab22cbd470))
|
||||||
|
|
||||||
|
### [0.6.34](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.33...v0.6.34) (2022-07-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **emacs-28:** patch configure.ac to support latest libgccjit ([b582523](https://github.com/jimeh/build-emacs-for-macos/commit/b582523642ad4c5298f5a7890edd9b48c0433684)), closes [#72](https://github.com/jimeh/build-emacs-for-macos/issues/72)
|
||||||
|
|
||||||
|
### [0.6.33](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.32...v0.6.33) (2022-04-30)
|
||||||
|
|
||||||
|
### [0.6.32](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.31...v0.6.32) (2022-04-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **dbus:** add flag to explicitly disable dbus support ([8ad3ff4](https://github.com/jimeh/build-emacs-for-macos/commit/8ad3ff4f53505408aa097527177032a1fd6008e0)), closes [#69](https://github.com/jimeh/build-emacs-for-macos/issues/69)
|
||||||
|
* **deps:** add sqlite brew dependency for Emacs 29.x ([a20a845](https://github.com/jimeh/build-emacs-for-macos/commit/a20a8456ab1e8de6357d5d121b9565ba65a6dd71))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **native-comp:** support libgccjit 11.3.0 ([e31f5aa](https://github.com/jimeh/build-emacs-for-macos/commit/e31f5aaf9355b674c2a86b8eda35f6513f344b72)), closes [#71](https://github.com/jimeh/build-emacs-for-macos/issues/71)
|
||||||
|
|
||||||
|
### [0.6.31](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.30...v0.6.31) (2022-02-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* set source-directory correctly ([07e0e3d](https://github.com/jimeh/build-emacs-for-macos/commit/07e0e3dacddfbdb7a59aceaa2dc9cdf503ac2bcc)), closes [#68](https://github.com/jimeh/build-emacs-for-macos/issues/68)
|
||||||
|
|
||||||
|
### [0.6.30](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.29...v0.6.30) (2022-02-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **site-lisp:** add Homebrew's site-lisp directory to locallisppath ([cbd8cb2](https://github.com/jimeh/build-emacs-for-macos/commit/cbd8cb27b6ceff2e128c38cd1cc8f8380b9b4bfb))
|
||||||
|
|
||||||
|
### [0.6.29](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.28...v0.6.29) (2022-02-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **cask:** add support for pretest builds ([084776d](https://github.com/jimeh/build-emacs-for-macos/commit/084776db6b7e61958088d7b2a2588e9889e60c21))
|
||||||
|
|
||||||
|
### [0.6.28](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.27...v0.6.28) (2022-01-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **build:** add dbus dependency to enable support in Emacs builds ([68ef4c0](https://github.com/jimeh/build-emacs-for-macos/commit/68ef4c066c3fd1a7337198e8f773866088b4f481))
|
||||||
|
|
||||||
|
### [0.6.27](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.26...v0.6.27) (2021-12-05)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **plan:** add support for pretest and release candidate builds ([743b10c](https://github.com/jimeh/build-emacs-for-macos/commit/743b10c751e146ec7569f39a475c20a0489955f4))
|
||||||
|
|
||||||
|
### [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)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **patch:** add support for posix-spawn patch from emacs-plus ([4030ceb](https://github.com/jimeh/build-emacs-for-macos/commit/4030ceb9cab6749af3c28161ac97caec90a8aed0))
|
||||||
|
|
||||||
|
### [0.6.21](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.20...v0.6.21) (2021-10-27)
|
||||||
|
|
||||||
|
### [0.6.20](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.19...v0.6.20) (2021-10-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **notarization:** explicitly only copy *.c and *.h C source files ([591c39e](https://github.com/jimeh/build-emacs-for-macos/commit/591c39e629c9556adcf296cd5c15dd0b17c4d986))
|
||||||
|
|
||||||
### [0.6.19](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.18...v0.6.19) (2021-10-23)
|
### [0.6.19](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.18...v0.6.19) (2021-10-23)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
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'
|
||||||
@@ -105,8 +119,8 @@ class Build
|
|||||||
build_dir, app = create_build_dir(app)
|
build_dir, app = create_build_dir(app)
|
||||||
|
|
||||||
handle_native_lisp(app)
|
handle_native_lisp(app)
|
||||||
add_cli_helper(app)
|
|
||||||
|
|
||||||
|
CLIHelperEmbedder.new(app).embed
|
||||||
CSourcesEmbedder.new(app, @source_dir).embed
|
CSourcesEmbedder.new(app, @source_dir).embed
|
||||||
LibEmbedder.new(app, brew_dir, extra_libs, options[:relink_eln]).embed
|
LibEmbedder.new(app, brew_dir, extra_libs, options[:relink_eln]).embed
|
||||||
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
GccLibEmbedder.new(app, gcc_info).embed if options[:native_comp]
|
||||||
@@ -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
|
||||||
@@ -286,8 +300,6 @@ class Build
|
|||||||
verify_native_comp
|
verify_native_comp
|
||||||
gcc_info.verify_libgccjit
|
gcc_info.verify_libgccjit
|
||||||
|
|
||||||
apply_native_comp_env_setup_patch(source)
|
|
||||||
|
|
||||||
ENV['CFLAGS'] = [
|
ENV['CFLAGS'] = [
|
||||||
"-I#{File.join(gcc_info.root_dir, 'include')}",
|
"-I#{File.join(gcc_info.root_dir, 'include')}",
|
||||||
"-I#{File.join(gcc_info.libgccjit_root_dir, 'include')}",
|
"-I#{File.join(gcc_info.libgccjit_root_dir, 'include')}",
|
||||||
@@ -347,13 +359,15 @@ class Build
|
|||||||
'--with-modules',
|
'--with-modules',
|
||||||
'--enable-locallisppath=' \
|
'--enable-locallisppath=' \
|
||||||
'/Library/Application Support/Emacs/${version}/site-lisp:' \
|
'/Library/Application Support/Emacs/${version}/site-lisp:' \
|
||||||
'/Library/Application Support/Emacs/site-lisp'
|
'/Library/Application Support/Emacs/site-lisp:' \
|
||||||
|
'/usr/local/share/emacs/site-lisp'
|
||||||
]
|
]
|
||||||
if options[:xwidgets] && supports_xwidgets?
|
if options[:xwidgets] && supports_xwidgets?
|
||||||
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' if options[:rsvg] == false
|
configure_flags << '--without-rsvg' if options[:rsvg] == false
|
||||||
|
configure_flags << '--without-dbus' if options[:dbus] == false
|
||||||
|
|
||||||
run_cmd './configure', *configure_flags
|
run_cmd './configure', *configure_flags
|
||||||
|
|
||||||
@@ -402,13 +416,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
|
||||||
@@ -433,7 +447,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
|
||||||
@@ -455,7 +469,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)
|
||||||
@@ -479,7 +493,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
|
||||||
|
|
||||||
@@ -506,18 +520,6 @@ 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 build_name
|
def build_name
|
||||||
return @build_name if @build_name
|
return @build_name if @build_name
|
||||||
return @build_name = options[:build_name] if options[:build_name]
|
return @build_name = options[:build_name] if options[:build_name]
|
||||||
@@ -549,7 +551,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}"
|
||||||
@@ -614,26 +616,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 apply_native_comp_env_setup_patch(source)
|
|
||||||
term = 'native-compile-setup-environment-variables'
|
|
||||||
file = 'lisp/emacs-lisp/comp.el'
|
|
||||||
return if `grep '#{term}' '#{file}'`.strip.size.positive?
|
|
||||||
|
|
||||||
template = File.read(
|
|
||||||
File.join(__dir__, 'patches/native-comp-env-setup.diff.erb')
|
|
||||||
)
|
|
||||||
patch = ERB.new(template).result(gcc_info.get_binding)
|
|
||||||
patch_file = File.join(source, 'macos_patches/native-comp-env-setup.diff')
|
|
||||||
|
|
||||||
File.write(patch_file, patch)
|
|
||||||
apply_patch({ file: patch_file }, source)
|
|
||||||
end
|
|
||||||
|
|
||||||
def effective_version
|
def effective_version
|
||||||
@effective_version ||= begin
|
@effective_version ||= begin
|
||||||
case ref
|
case ref
|
||||||
@@ -680,6 +662,37 @@ class Build
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if %w[emacs-28 emacs-29].include?(effective_version)
|
||||||
|
if options[:posix_spawn]
|
||||||
|
p << {
|
||||||
|
url: 'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
|
||||||
|
"patches/#{effective_version}/posix-spawn.patch"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if effective_version == 'emacs-28'
|
||||||
|
p << {
|
||||||
|
replace: [
|
||||||
|
'configure.ac',
|
||||||
|
'grep libgccjit.so\$',
|
||||||
|
'grep -E \'libgccjit\.(so|dylib)$\''
|
||||||
|
],
|
||||||
|
allow_failure: true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
if %w[emacs-28 emacs-29].include?(effective_version)
|
||||||
|
p << {
|
||||||
|
replace: [
|
||||||
|
'configure.ac',
|
||||||
|
'grep -E \'libgccjit\.(so|dylib)$\'',
|
||||||
|
'grep -E \'libgccjit\.(so|dylib)$\' | tail -1'
|
||||||
|
],
|
||||||
|
allow_failure: true
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
if effective_version == 'emacs-27'
|
if effective_version == 'emacs-27'
|
||||||
p << {
|
p << {
|
||||||
url: 'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
|
url: 'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
|
||||||
@@ -729,17 +742,34 @@ class Build
|
|||||||
err 'Patch replace input error' unless patch[:replace].size == 3
|
err 'Patch replace input error' unless patch[:replace].size == 3
|
||||||
|
|
||||||
file, before, after = patch[:replace]
|
file, before, after = patch[:replace]
|
||||||
|
info "Applying patch to #{file}..."
|
||||||
filepath = File.join(target, file)
|
filepath = File.join(target, file)
|
||||||
|
|
||||||
err "\"#{file}\" does not exist in #{target}" unless File.exist?(filepath)
|
unless File.exist?(filepath)
|
||||||
|
if patch[:allow_failure]
|
||||||
|
info "File #{filepath} does not exist, skipping patch."
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
err "\"#{file}\" does not exist in #{target}"
|
||||||
|
end
|
||||||
|
|
||||||
f = File.open(filepath, 'rb')
|
f = File.open(filepath, 'rb')
|
||||||
s = f.read
|
s = f.read
|
||||||
sub = s.gsub!(before, after)
|
sub = s.gsub!(before, after)
|
||||||
err "Replacement filed in #{file}" if sub.nil?
|
|
||||||
|
if sub.nil?
|
||||||
|
if patch[:allow_failure]
|
||||||
|
info 'Patch did not apply, skipping.'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
err "Replacement failed in #{file}"
|
||||||
|
end
|
||||||
|
|
||||||
f.reopen(filepath, 'wb').write(s)
|
f.reopen(filepath, 'wb').write(s)
|
||||||
f.close
|
f.close
|
||||||
|
info "#{file} patched."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -770,6 +800,7 @@ end
|
|||||||
|
|
||||||
class AbstractEmbedder
|
class AbstractEmbedder
|
||||||
include Output
|
include Output
|
||||||
|
include System
|
||||||
|
|
||||||
attr_reader :app
|
attr_reader :app
|
||||||
|
|
||||||
@@ -780,24 +811,53 @@ 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
|
||||||
|
|
||||||
|
def bin_dir
|
||||||
|
@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
|
||||||
|
|
||||||
|
class CLIHelperEmbedder < AbstractEmbedder
|
||||||
|
def embed
|
||||||
|
source = File.join(__dir__, 'helper', 'emacs-cli.bash')
|
||||||
|
target = File.join(bin_dir, 'emacs')
|
||||||
|
dir = File.dirname(target)
|
||||||
|
|
||||||
|
info 'Adding "emacs" CLI helper to Emacs.app'
|
||||||
|
|
||||||
|
FileUtils.mkdir_p(dir)
|
||||||
|
run_cmd('cp', '-pRL', source, target)
|
||||||
|
run_cmd('chmod', '+w', target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class CSourcesEmbedder < AbstractEmbedder
|
class CSourcesEmbedder < AbstractEmbedder
|
||||||
|
PATH_PATCH = <<~ELISP
|
||||||
|
;; Allow Emacs to find bundled C sources.
|
||||||
|
(setq source-directory
|
||||||
|
(expand-file-name ".." (file-name-directory load-file-name)))
|
||||||
|
ELISP
|
||||||
|
|
||||||
attr_reader :source_dir
|
attr_reader :source_dir
|
||||||
|
|
||||||
def initialize(app, source_dir)
|
def initialize(app, source_dir)
|
||||||
super(app)
|
super(app)
|
||||||
|
|
||||||
@@ -807,34 +867,40 @@ class CSourcesEmbedder < AbstractEmbedder
|
|||||||
def embed
|
def embed
|
||||||
info 'Embedding C source files into Emacs.app for documentation purposes'
|
info 'Embedding C source files into Emacs.app for documentation purposes'
|
||||||
|
|
||||||
FileUtils.cp_r(
|
src_dir = File.join(source_dir, 'src')
|
||||||
File.join(source_dir, 'src'),
|
Dir[File.join(src_dir, '**', '*.{c,h}')].each do |f|
|
||||||
File.join(resources_dir, 'src')
|
rel = f[src_dir.size + 1..-1]
|
||||||
)
|
target = File.join(resources_dir, 'src', rel)
|
||||||
|
FileUtils.mkdir_p(File.dirname(target))
|
||||||
|
cmd('cp', '-pRL', f, target)
|
||||||
|
end
|
||||||
|
|
||||||
File.open(subdirs_el_file, 'a') do |f|
|
return if File.exist?(site_start_el_file) &&
|
||||||
f.puts("(setq source-directory (expand-file-name \"..\"))\n")
|
File.read(site_start_el_file).include?(PATH_PATCH)
|
||||||
|
|
||||||
|
File.open(site_start_el_file, 'a') do |f|
|
||||||
|
f.puts("\n#{PATH_PATCH}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def subdirs_el_file
|
def site_start_el_file
|
||||||
@subdirs_el_file ||= File.join(resources_dir, 'lisp', 'subdirs.el')
|
@site_start_el_file ||= File.join(resources_dir, 'lisp', 'site-start.el')
|
||||||
end
|
end
|
||||||
end
|
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
|
||||||
@@ -844,15 +910,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
|
||||||
@@ -863,21 +934,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})
|
||||||
@@ -885,41 +954,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
|
||||||
|
|
||||||
@@ -928,7 +993,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
|
||||||
|
|
||||||
@@ -953,14 +1018,51 @@ 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)
|
||||||
|
return if File.exist?(site_start_el_file) &&
|
||||||
|
File.read(site_start_el_file).include?(env_setup)
|
||||||
|
|
||||||
|
File.open(site_start_el_file, 'a') do |f|
|
||||||
|
f.puts("\n#{env_setup}")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
NATIVE_COMP_ENV_VAR_TPL = <<~ELISP
|
||||||
|
;; Set LIBRARY_PATH to point at bundled GCC and Xcode Command Line Tools to
|
||||||
|
;; ensure native-comp works.
|
||||||
|
(when (and (eq system-type 'darwin)
|
||||||
|
(string-match-p "\\.app\\/Contents\\/MacOS\\/?$"
|
||||||
|
invocation-directory))
|
||||||
|
(let* ((library-path-env (getenv "LIBRARY_PATH"))
|
||||||
|
(devtools-dir
|
||||||
|
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
||||||
|
(gcc-dir (expand-file-name
|
||||||
|
"<%= app_bundle_relative_lib_dir %>"
|
||||||
|
invocation-directory))
|
||||||
|
(darwin-dir (expand-file-name
|
||||||
|
"<%= app_bundle_relative_darwin_lib_dir %>"
|
||||||
|
invocation-directory))
|
||||||
|
(lib-paths (list)))
|
||||||
|
|
||||||
|
(if library-path-env
|
||||||
|
(push library-path-env lib-paths))
|
||||||
|
(if (file-directory-p devtools-dir)
|
||||||
|
(push devtools-dir lib-paths))
|
||||||
|
(push darwin-dir lib-paths)
|
||||||
|
(push gcc-dir lib-paths)
|
||||||
|
|
||||||
|
(setenv "LIBRARY_PATH" (mapconcat 'identity lib-paths ":"))))
|
||||||
|
ELISP
|
||||||
|
|
||||||
def embedded?
|
def embedded?
|
||||||
Dir[File.join(target_dir, 'libgcc*')].any?
|
Dir[File.join(target_dir, 'libgcc*')].any?
|
||||||
end
|
end
|
||||||
@@ -984,6 +1086,10 @@ class GccLibEmbedder < AbstractEmbedder
|
|||||||
def relative_dir(path, root)
|
def relative_dir(path, root)
|
||||||
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def site_start_el_file
|
||||||
|
@site_start_el_file ||= File.join(resources_dir, 'lisp', 'site-start.el')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class GccInfo
|
class GccInfo
|
||||||
@@ -1005,7 +1111,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
|
||||||
@@ -1020,7 +1126,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
|
||||||
@@ -1058,7 +1166,8 @@ class GccInfo
|
|||||||
|
|
||||||
def libgccjit_lib_dir
|
def libgccjit_lib_dir
|
||||||
@libgccjit_lib_dir ||= Dir[
|
@libgccjit_lib_dir ||= Dir[
|
||||||
File.join(libgccjit_root_dir, 'lib/gcc/*/libgccjit.so*')
|
File.join(libgccjit_root_dir, 'lib/gcc/*/libgccjit*.dylib'),
|
||||||
|
File.join(libgccjit_root_dir, 'lib/gcc/*/libgccjit.so*'),
|
||||||
]
|
]
|
||||||
.map { |path| File.dirname(path) }
|
.map { |path| File.dirname(path) }
|
||||||
.select { |path| File.basename(path).match(/^\d+$/) }
|
.select { |path| File.basename(path).match(/^\d+$/) }
|
||||||
@@ -1108,6 +1217,7 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
native_march: false,
|
native_march: false,
|
||||||
parallel: Etc.nprocessors,
|
parallel: Etc.nprocessors,
|
||||||
rsvg: true,
|
rsvg: true,
|
||||||
|
dbus: true,
|
||||||
xwidgets: true,
|
xwidgets: true,
|
||||||
github_auth: true,
|
github_auth: true,
|
||||||
dist_include: ['COPYING'],
|
dist_include: ['COPYING'],
|
||||||
@@ -1174,10 +1284,19 @@ if __FILE__ == $PROGRAM_NAME
|
|||||||
cli_options[:rsvg] = v
|
cli_options[:rsvg] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('--[no-]dbus',
|
||||||
|
'Enable/disable dbus support (default: enabled)') do |v|
|
||||||
|
cli_options[:dbus] = v
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('--no-titlebar', 'Apply no-titlebar patch (default: disabled)') do
|
opts.on('--no-titlebar', 'Apply no-titlebar patch (default: disabled)') do
|
||||||
cli_options[:no_titlebar] = true
|
cli_options[:no_titlebar] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on('--posix-spawn', 'Apply posix-spawn patch (default: disabled)') do
|
||||||
|
cli_options[:posix_spawn] = true
|
||||||
|
end
|
||||||
|
|
||||||
opts.on('--no-frame-refocus',
|
opts.on('--no-frame-refocus',
|
||||||
'Apply no-frame-refocus patch (default: disabled)') do
|
'Apply no-frame-refocus patch (default: disabled)') do
|
||||||
cli_options[:no_frame_refocus] = true
|
cli_options[:no_frame_refocus] = true
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -16,7 +16,7 @@ require (
|
|||||||
github.com/hexops/gotextdiff v1.0.3
|
github.com/hexops/gotextdiff v1.0.3
|
||||||
github.com/jimeh/undent v1.1.0
|
github.com/jimeh/undent v1.1.0
|
||||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||||
github.com/mitchellh/gon v0.2.3
|
github.com/mitchellh/gon v0.2.5
|
||||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||||
github.com/stretchr/testify v1.7.0
|
github.com/stretchr/testify v1.7.0
|
||||||
github.com/urfave/cli/v2 v2.3.0
|
github.com/urfave/cli/v2 v2.3.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -160,8 +160,8 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
|
|||||||
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
|
||||||
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||||
github.com/mitchellh/gon v0.2.3 h1:fObN7hD14VacGG++t27GzTW6opP0lwI7TsgTPL55wBo=
|
github.com/mitchellh/gon v0.2.5 h1:mVWtqTzV03W0avJqmqjk9M0qls3TDUXfc9ETJaPIOWY=
|
||||||
github.com/mitchellh/gon v0.2.3/go.mod h1:Ua18ZhqjZHg8VyqZo8kNHAY331ntV6nNJ9mT3s2mIo8=
|
github.com/mitchellh/gon v0.2.5/go.mod h1:Ua18ZhqjZHg8VyqZo8kNHAY331ntV6nNJ9mT3s2mIo8=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
resolve_link() {
|
resolve_link() {
|
||||||
"$(type -p greadlink readlink | head -1)" "$1"
|
"$(command -v greadlink || command -v readlink)" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
abs_dirname() {
|
abs_dirname() {
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
|
|
||||||
index 638d4b274c..2599211936 100644
|
|
||||||
--- a/lisp/emacs-lisp/comp.el
|
|
||||||
+++ b/lisp/emacs-lisp/comp.el
|
|
||||||
@@ -4224,6 +4224,52 @@ native-compile-async
|
|
||||||
(let ((load (not (not load))))
|
|
||||||
(native--compile-async files recursively load selector)))
|
|
||||||
|
|
||||||
+;;;###autoload
|
|
||||||
+(defun native-compile-setup-environment-variables (&rest _args)
|
|
||||||
+ "Ensure LIBRARY_PATH is set correctly when libgccjit is bundled."
|
|
||||||
+ (when (and (eq system-type 'darwin)
|
|
||||||
+ (string-match-p "\.app\/Contents\/MacOS\/?$"
|
|
||||||
+ invocation-directory))
|
|
||||||
+ (let* ((library-path-env (getenv "LIBRARY_PATH"))
|
|
||||||
+ (devtools-dir
|
|
||||||
+ "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib")
|
|
||||||
+ (gcc-dir (expand-file-name
|
|
||||||
+ "<%= app_bundle_relative_lib_dir %>"
|
|
||||||
+ invocation-directory))
|
|
||||||
+ (darwin-dir (expand-file-name
|
|
||||||
+ "<%= app_bundle_relative_darwin_lib_dir %>"
|
|
||||||
+ invocation-directory))
|
|
||||||
+ (lib-paths (list)))
|
|
||||||
+
|
|
||||||
+ (if library-path-env
|
|
||||||
+ (push library-path-env lib-paths))
|
|
||||||
+ (if (file-directory-p devtools-dir)
|
|
||||||
+ (push devtools-dir lib-paths))
|
|
||||||
+ (push darwin-dir lib-paths)
|
|
||||||
+ (push gcc-dir lib-paths)
|
|
||||||
+
|
|
||||||
+ (setenv "LIBRARY_PATH" (mapconcat 'identity lib-paths ":"))))
|
|
||||||
+
|
|
||||||
+ ;; Remove advice, as it only needs to run once.
|
|
||||||
+ (advice-remove 'native-compile
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+ (advice-remove 'comp--native-compile
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+ (advice-remove 'native-compile-async
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+ (advice-remove 'native--compile-async
|
|
||||||
+ 'native-compile-setup-environment-variables))
|
|
||||||
+
|
|
||||||
+;; Ensure environment setup runs before any native compilation.
|
|
||||||
+(advice-add 'native-compile :before
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+(advice-add 'comp--native-compile :before
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+(advice-add 'native-compile-async :before
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+(advice-add 'native--compile-async :before
|
|
||||||
+ 'native-compile-setup-environment-variables)
|
|
||||||
+
|
|
||||||
(provide 'comp)
|
|
||||||
|
|
||||||
;; LocalWords: limplified limplified limplification limplify Limple LIMPLE libgccjit elc eln
|
|
||||||
@@ -393,9 +393,7 @@ func (s *Updater) renderCask(
|
|||||||
filename := asset.GetName()
|
filename := asset.GetName()
|
||||||
s.logger.Debug("processing asset", "filename", filename)
|
s.logger.Debug("processing asset", "filename", filename)
|
||||||
|
|
||||||
if strings.HasSuffix(filename, ".sha256") {
|
filename = strings.TrimSuffix(filename, ".sha256")
|
||||||
filename = strings.TrimSuffix(filename, ".sha256")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := info.Assets[filename]; !ok {
|
if _, ok := info.Assets[filename]; !ok {
|
||||||
info.Assets[filename] = &ReleaseAsset{
|
info.Assets[filename] = &ReleaseAsset{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ func New(version, commit, date string) *CLI {
|
|||||||
Commands: []*cli2.Command{
|
Commands: []*cli2.Command{
|
||||||
planCmd(),
|
planCmd(),
|
||||||
signCmd(),
|
signCmd(),
|
||||||
|
signFilesCmd(),
|
||||||
notarizeCmd(),
|
notarizeCmd(),
|
||||||
packageCmd(),
|
packageCmd(),
|
||||||
releaseCmd(),
|
releaseCmd(),
|
||||||
|
|||||||
@@ -112,3 +112,49 @@ func signAction(c *cli2.Context, opts *Options) error {
|
|||||||
|
|
||||||
return sign.Emacs(c.Context, app, signOpts)
|
return sign.Emacs(c.Context, app, signOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func signFilesCmd() *cli2.Command {
|
||||||
|
signCmd := signCmd()
|
||||||
|
|
||||||
|
var flags []cli2.Flag
|
||||||
|
for _, f := range signCmd.Flags {
|
||||||
|
n := f.Names()
|
||||||
|
if len(n) > 0 && n[0] == "plan" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
flags = append(flags, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &cli2.Command{
|
||||||
|
Name: "sign-files",
|
||||||
|
Usage: "sign files with codesign",
|
||||||
|
ArgsUsage: "<file> [<file>...]",
|
||||||
|
Hidden: true,
|
||||||
|
Flags: flags,
|
||||||
|
Action: actionWrapper(signFilesAction),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func signFilesAction(c *cli2.Context, opts *Options) error {
|
||||||
|
signOpts := &sign.Options{
|
||||||
|
Identity: c.String("sign"),
|
||||||
|
Options: c.StringSlice("options"),
|
||||||
|
Deep: c.Bool("deep"),
|
||||||
|
Timestamp: c.Bool("timestamp"),
|
||||||
|
Force: c.Bool("force"),
|
||||||
|
Verbose: c.Bool("verbose"),
|
||||||
|
CodeSignCmd: c.String("codesign"),
|
||||||
|
}
|
||||||
|
|
||||||
|
if v := c.StringSlice("entitlements"); len(v) > 0 {
|
||||||
|
e := sign.Entitlements(v)
|
||||||
|
signOpts.Entitlements = &e
|
||||||
|
}
|
||||||
|
|
||||||
|
if !opts.quiet {
|
||||||
|
signOpts.Output = os.Stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
return sign.Files(c.Context, c.Args().Slice(), signOpts)
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/hashicorp/go-hclog"
|
"github.com/hashicorp/go-hclog"
|
||||||
@@ -13,10 +14,13 @@ import (
|
|||||||
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
"github.com/jimeh/build-emacs-for-macos/pkg/repository"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/sanitize"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
||||||
)
|
)
|
||||||
|
|
||||||
var nonAlphaNum = regexp.MustCompile(`[^\w_-]+`)
|
var gitTagMatcher = regexp.MustCompile(
|
||||||
|
`^emacs(-.*)?-((\d+\.\d+)(?:\.(\d+))?(-rc\d+)?(.+)?)$`,
|
||||||
|
)
|
||||||
|
|
||||||
type TestBuildType string
|
type TestBuildType string
|
||||||
|
|
||||||
@@ -37,7 +41,7 @@ type Options struct {
|
|||||||
Output io.Writer
|
Output io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
func Create(ctx context.Context, opts *Options) (*Plan, error) { //nolint:funlen
|
||||||
logger := hclog.FromContext(ctx).Named("plan")
|
logger := hclog.FromContext(ctx).Named("plan")
|
||||||
|
|
||||||
repo, err := repository.NewGitHub(opts.EmacsRepo)
|
repo, err := repository.NewGitHub(opts.EmacsRepo)
|
||||||
@@ -66,19 +70,36 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
version := fmt.Sprintf(
|
absoluteVersion := fmt.Sprintf(
|
||||||
"%s.%s.%s",
|
"%s.%s.%s",
|
||||||
commitInfo.DateString(),
|
commitInfo.DateString(),
|
||||||
commitInfo.ShortSHA(),
|
commitInfo.ShortSHA(),
|
||||||
sanitizeString(opts.Ref),
|
sanitize.String(opts.Ref),
|
||||||
)
|
)
|
||||||
|
|
||||||
releaseName := fmt.Sprintf("Emacs.%s", version)
|
version, channel, err := parseGitRef(opts.Ref)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var releaseName string
|
||||||
|
switch channel {
|
||||||
|
case release.Stable, release.RC:
|
||||||
|
releaseName = "Emacs-" + version
|
||||||
|
case release.Pretest:
|
||||||
|
version += "-pretest"
|
||||||
|
absoluteVersion += "-pretest"
|
||||||
|
releaseName = "Emacs-" + version
|
||||||
|
default:
|
||||||
|
version = absoluteVersion
|
||||||
|
releaseName = "Emacs." + version
|
||||||
|
}
|
||||||
|
|
||||||
buildName := fmt.Sprintf(
|
buildName := fmt.Sprintf(
|
||||||
"Emacs.%s.%s.%s",
|
"Emacs.%s.%s.%s",
|
||||||
version,
|
absoluteVersion,
|
||||||
sanitizeString(osInfo.Name+"-"+osInfo.DistinctVersion()),
|
sanitize.String(osInfo.Name+"-"+osInfo.DistinctVersion()),
|
||||||
sanitizeString(osInfo.Arch),
|
sanitize.String(osInfo.Arch),
|
||||||
)
|
)
|
||||||
diskImage := buildName + ".dmg"
|
diskImage := buildName + ".dmg"
|
||||||
|
|
||||||
@@ -97,7 +118,8 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
OS: osInfo,
|
OS: osInfo,
|
||||||
Release: &Release{
|
Release: &Release{
|
||||||
Name: releaseName,
|
Name: releaseName,
|
||||||
Prerelease: true,
|
Prerelease: channel != release.Stable,
|
||||||
|
Channel: channel,
|
||||||
},
|
},
|
||||||
Output: &Output{
|
Output: &Output{
|
||||||
Directory: opts.OutputDir,
|
Directory: opts.OutputDir,
|
||||||
@@ -105,28 +127,18 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// If given git ref is a stable release tag (emacs-23.2b, emacs-27.2, etc.)
|
|
||||||
// we modify release properties accordingly.
|
|
||||||
if v, err := release.GitRefToStableVersion(opts.Ref); err == nil {
|
|
||||||
plan.Release.Prerelease = false
|
|
||||||
plan.Release.Name, err = release.VersionToName(v)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.TestBuild != "" {
|
if opts.TestBuild != "" {
|
||||||
testName := sanitizeString(opts.TestBuild)
|
testName := sanitize.String(opts.TestBuild)
|
||||||
|
|
||||||
plan.Build.Name += ".test." + testName
|
plan.Build.Name += ".test." + testName
|
||||||
plan.Release.Title = "Test Builds"
|
plan.Release.Title = "Test Builds (" + testName + ")"
|
||||||
plan.Release.Name = "test-builds"
|
plan.Release.Name = "test-builds"
|
||||||
|
|
||||||
plan.Release.Prerelease = true
|
plan.Release.Prerelease = false
|
||||||
plan.Release.Draft = false
|
plan.Release.Draft = true
|
||||||
if opts.TestBuildType == Draft {
|
if opts.TestBuildType == Prerelease {
|
||||||
plan.Release.Prerelease = false
|
plan.Release.Prerelease = true
|
||||||
plan.Release.Draft = true
|
plan.Release.Draft = false
|
||||||
}
|
}
|
||||||
|
|
||||||
index := strings.LastIndex(diskImage, ".")
|
index := strings.LastIndex(diskImage, ".")
|
||||||
@@ -137,6 +149,35 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
|
|||||||
return plan, nil
|
return plan, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func sanitizeString(s string) string {
|
func parseGitRef(ref string) (string, release.Channel, error) {
|
||||||
return nonAlphaNum.ReplaceAllString(s, "-")
|
m := gitTagMatcher.FindStringSubmatch(ref)
|
||||||
|
|
||||||
|
if len(m) == 0 {
|
||||||
|
return "", release.Nightly, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.Contains(m[1], "pretest") {
|
||||||
|
return m[2], release.Pretest, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if m[4] != "" {
|
||||||
|
n, err := strconv.Atoi(m[4])
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if n >= 90 {
|
||||||
|
return m[2], release.Pretest, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(m[5], "-rc") {
|
||||||
|
return m[2], release.RC, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if m[2] == m[3] {
|
||||||
|
return m[2], release.Stable, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", "", nil
|
||||||
}
|
}
|
||||||
|
|||||||
421
pkg/plan/create_test.go
Normal file
421
pkg/plan/create_test.go
Normal file
@@ -0,0 +1,421 @@
|
|||||||
|
package plan
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_parseGitRef(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
type args struct {
|
||||||
|
ref string
|
||||||
|
}
|
||||||
|
type want struct {
|
||||||
|
version string
|
||||||
|
channel release.Channel
|
||||||
|
err string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want want
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "master",
|
||||||
|
args: args{ref: "master"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-28",
|
||||||
|
args: args{ref: "emacs-28"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27",
|
||||||
|
args: args{ref: "emacs-27"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26",
|
||||||
|
args: args{ref: "emacs-26"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24",
|
||||||
|
args: args{ref: "emacs-24"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "feature/native-comp",
|
||||||
|
args: args{ref: "feature/native-comp"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "feature/pgtk",
|
||||||
|
args: args{ref: "feature/pgtk"},
|
||||||
|
want: want{version: "", channel: release.Nightly, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-19.34",
|
||||||
|
args: args{ref: "emacs-19.34"},
|
||||||
|
want: want{version: "19.34", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-20.4",
|
||||||
|
args: args{ref: "emacs-20.4"},
|
||||||
|
want: want{version: "20.4", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-22.3",
|
||||||
|
args: args{ref: "emacs-22.3"},
|
||||||
|
want: want{version: "22.3", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-23.4",
|
||||||
|
args: args{ref: "emacs-23.4"},
|
||||||
|
want: want{version: "23.4", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.0.97",
|
||||||
|
args: args{ref: "emacs-24.0.97"},
|
||||||
|
want: want{version: "24.0.97", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.2",
|
||||||
|
args: args{ref: "emacs-24.2"},
|
||||||
|
want: want{version: "24.2", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.2.90",
|
||||||
|
args: args{ref: "emacs-24.2.90"},
|
||||||
|
want: want{version: "24.2.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.2.93",
|
||||||
|
args: args{ref: "emacs-24.2.93"},
|
||||||
|
want: want{version: "24.2.93", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.3",
|
||||||
|
args: args{ref: "emacs-24.3"},
|
||||||
|
want: want{version: "24.3", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.3-rc1",
|
||||||
|
args: args{ref: "emacs-24.3-rc1"},
|
||||||
|
want: want{version: "24.3-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.3.90",
|
||||||
|
args: args{ref: "emacs-24.3.90"},
|
||||||
|
want: want{version: "24.3.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.3.94",
|
||||||
|
args: args{ref: "emacs-24.3.94"},
|
||||||
|
want: want{version: "24.3.94", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.4",
|
||||||
|
args: args{ref: "emacs-24.4"},
|
||||||
|
want: want{version: "24.4", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.4-rc1",
|
||||||
|
args: args{ref: "emacs-24.4-rc1"},
|
||||||
|
want: want{version: "24.4-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.4.90",
|
||||||
|
args: args{ref: "emacs-24.4.90"},
|
||||||
|
want: want{version: "24.4.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.4.91",
|
||||||
|
args: args{ref: "emacs-24.4.91"},
|
||||||
|
want: want{version: "24.4.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.5",
|
||||||
|
args: args{ref: "emacs-24.5"},
|
||||||
|
want: want{version: "24.5", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.5-rc1",
|
||||||
|
args: args{ref: "emacs-24.5-rc1"},
|
||||||
|
want: want{version: "24.5-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.5-rc3",
|
||||||
|
args: args{ref: "emacs-24.5-rc3"},
|
||||||
|
want: want{version: "24.5-rc3", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-24.5-rc3-fixed",
|
||||||
|
args: args{ref: "emacs-24.5-rc3-fixed"},
|
||||||
|
want: want{version: "24.5-rc3-fixed", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.0.90",
|
||||||
|
args: args{ref: "emacs-25.0.90"},
|
||||||
|
want: want{version: "25.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.0.95",
|
||||||
|
args: args{ref: "emacs-25.0.95"},
|
||||||
|
want: want{version: "25.0.95", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.1",
|
||||||
|
args: args{ref: "emacs-25.1"},
|
||||||
|
want: want{version: "25.1", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.1-rc1",
|
||||||
|
args: args{ref: "emacs-25.1-rc1"},
|
||||||
|
want: want{version: "25.1-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.1-rc2",
|
||||||
|
args: args{ref: "emacs-25.1-rc2"},
|
||||||
|
want: want{version: "25.1-rc2", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.1.90",
|
||||||
|
args: args{ref: "emacs-25.1.90"},
|
||||||
|
want: want{version: "25.1.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.1.91",
|
||||||
|
args: args{ref: "emacs-25.1.91"},
|
||||||
|
want: want{version: "25.1.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.2",
|
||||||
|
args: args{ref: "emacs-25.2"},
|
||||||
|
want: want{version: "25.2", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.2-rc1",
|
||||||
|
args: args{ref: "emacs-25.2-rc1"},
|
||||||
|
want: want{version: "25.2-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-25.2-rc2",
|
||||||
|
args: args{ref: "emacs-25.2-rc2"},
|
||||||
|
want: want{version: "25.2-rc2", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.0.90",
|
||||||
|
args: args{ref: "emacs-26.0.90"},
|
||||||
|
want: want{version: "26.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.0.91",
|
||||||
|
args: args{ref: "emacs-26.0.91"},
|
||||||
|
want: want{version: "26.0.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.1",
|
||||||
|
args: args{ref: "emacs-26.1"},
|
||||||
|
want: want{version: "26.1", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.1-rc1",
|
||||||
|
args: args{ref: "emacs-26.1-rc1"},
|
||||||
|
want: want{version: "26.1-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.1.90",
|
||||||
|
args: args{ref: "emacs-26.1.90"},
|
||||||
|
want: want{version: "26.1.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.1.92",
|
||||||
|
args: args{ref: "emacs-26.1.92"},
|
||||||
|
want: want{version: "26.1.92", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.2",
|
||||||
|
args: args{ref: "emacs-26.2"},
|
||||||
|
want: want{version: "26.2", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.2.90",
|
||||||
|
args: args{ref: "emacs-26.2.90"},
|
||||||
|
want: want{version: "26.2.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.3",
|
||||||
|
args: args{ref: "emacs-26.3"},
|
||||||
|
want: want{version: "26.3", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-26.3-rc1",
|
||||||
|
args: args{ref: "emacs-26.3-rc1"},
|
||||||
|
want: want{version: "26.3-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.0.90",
|
||||||
|
args: args{ref: "emacs-27.0.90"},
|
||||||
|
want: want{version: "27.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.0.91",
|
||||||
|
args: args{ref: "emacs-27.0.91"},
|
||||||
|
want: want{version: "27.0.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.1",
|
||||||
|
args: args{ref: "emacs-27.1"},
|
||||||
|
want: want{version: "27.1", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.1-rc1",
|
||||||
|
args: args{ref: "emacs-27.1-rc1"},
|
||||||
|
want: want{version: "27.1-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.1-rc2",
|
||||||
|
args: args{ref: "emacs-27.1-rc2"},
|
||||||
|
want: want{version: "27.1-rc2", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.1.90",
|
||||||
|
args: args{ref: "emacs-27.1.90"},
|
||||||
|
want: want{version: "27.1.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.1.91",
|
||||||
|
args: args{ref: "emacs-27.1.91"},
|
||||||
|
want: want{version: "27.1.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.2",
|
||||||
|
args: args{ref: "emacs-27.2"},
|
||||||
|
want: want{version: "27.2", channel: release.Stable, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.2-rc1",
|
||||||
|
args: args{ref: "emacs-27.2-rc1"},
|
||||||
|
want: want{version: "27.2-rc1", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-27.2-rc2",
|
||||||
|
args: args{ref: "emacs-27.2-rc2"},
|
||||||
|
want: want{version: "27.2-rc2", channel: release.RC, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-28.0.90",
|
||||||
|
args: args{ref: "emacs-28.0.90"},
|
||||||
|
want: want{version: "28.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-21.0.100",
|
||||||
|
args: args{ref: "emacs-pretest-21.0.100"},
|
||||||
|
want: want{version: "21.0.100", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-21.0.106",
|
||||||
|
args: args{ref: "emacs-pretest-21.0.106"},
|
||||||
|
want: want{version: "21.0.106", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-21.0.90",
|
||||||
|
args: args{ref: "emacs-pretest-21.0.90"},
|
||||||
|
want: want{version: "21.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-21.0.99",
|
||||||
|
args: args{ref: "emacs-pretest-21.0.99"},
|
||||||
|
want: want{version: "21.0.99", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-22.0.90",
|
||||||
|
args: args{ref: "emacs-pretest-22.0.90"},
|
||||||
|
want: want{version: "22.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-22.0.99",
|
||||||
|
args: args{ref: "emacs-pretest-22.0.99"},
|
||||||
|
want: want{version: "22.0.99", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-22.0.990",
|
||||||
|
args: args{ref: "emacs-pretest-22.0.990"},
|
||||||
|
want: want{version: "22.0.990", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-22.1.90",
|
||||||
|
args: args{ref: "emacs-pretest-22.1.90"},
|
||||||
|
want: want{version: "22.1.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-22.2.90",
|
||||||
|
args: args{ref: "emacs-pretest-22.2.90"},
|
||||||
|
want: want{version: "22.2.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.0.90",
|
||||||
|
args: args{ref: "emacs-pretest-23.0.90"},
|
||||||
|
want: want{version: "23.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.1.90",
|
||||||
|
args: args{ref: "emacs-pretest-23.1.90"},
|
||||||
|
want: want{version: "23.1.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.2.90",
|
||||||
|
args: args{ref: "emacs-pretest-23.2.90"},
|
||||||
|
want: want{version: "23.2.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.2.91",
|
||||||
|
args: args{ref: "emacs-pretest-23.2.91"},
|
||||||
|
want: want{version: "23.2.91", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.2.93",
|
||||||
|
args: args{ref: "emacs-pretest-23.2.93"},
|
||||||
|
want: want{version: "23.2.93", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.2.93.1",
|
||||||
|
args: args{ref: "emacs-pretest-23.2.93.1"},
|
||||||
|
want: want{version: "23.2.93.1", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-23.3.90",
|
||||||
|
args: args{ref: "emacs-pretest-23.3.90"},
|
||||||
|
want: want{version: "23.3.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-24.0.05",
|
||||||
|
args: args{ref: "emacs-pretest-24.0.05"},
|
||||||
|
want: want{version: "24.0.05", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "emacs-pretest-24.0.90",
|
||||||
|
args: args{ref: "emacs-pretest-24.0.90"},
|
||||||
|
want: want{version: "24.0.90", channel: release.Pretest, err: ""},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
got, gotChannel, err := parseGitRef(tt.args.ref)
|
||||||
|
|
||||||
|
assert.Equal(t, tt.want.version, got)
|
||||||
|
assert.Equal(t, tt.want.channel, gotChannel)
|
||||||
|
|
||||||
|
if tt.want.err == "" {
|
||||||
|
assert.NoError(t, err)
|
||||||
|
} else {
|
||||||
|
assert.EqualError(t, err, tt.want.err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
"github.com/jimeh/build-emacs-for-macos/pkg/osinfo"
|
||||||
|
"github.com/jimeh/build-emacs-for-macos/pkg/release"
|
||||||
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
"github.com/jimeh/build-emacs-for-macos/pkg/source"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -78,10 +79,11 @@ type Build struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Release struct {
|
type Release struct {
|
||||||
Name string `yaml:"name" json:"name"`
|
Name string `yaml:"name" json:"name"`
|
||||||
Title string `yaml:"title,omitempty" json:"title,omitempty"`
|
Title string `yaml:"title,omitempty" json:"title,omitempty"`
|
||||||
Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"`
|
Draft bool `yaml:"draft,omitempty" json:"draft,omitempty"`
|
||||||
Prerelease bool `yaml:"prerelease,omitempty" json:"prerelease,omitempty"`
|
Prerelease bool `yaml:"prerelease,omitempty" json:"prerelease,omitempty"`
|
||||||
|
Channel release.Channel `yaml:"channel,omitempty" json:"channel,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Output struct {
|
type Output struct {
|
||||||
|
|||||||
11
pkg/release/channel.go
Normal file
11
pkg/release/channel.go
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package release
|
||||||
|
|
||||||
|
type Channel string
|
||||||
|
|
||||||
|
// Release channels
|
||||||
|
const (
|
||||||
|
Stable Channel = "stable"
|
||||||
|
RC Channel = "release-candidate"
|
||||||
|
Pretest Channel = "pretest"
|
||||||
|
Nightly Channel = "nightly"
|
||||||
|
)
|
||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Errors
|
// Errors
|
||||||
@@ -18,7 +19,7 @@ var (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
|
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
|
||||||
stableGetRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
|
stableGitRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func VersionToName(version string) (string, error) {
|
func VersionToName(version string) (string, error) {
|
||||||
@@ -26,7 +27,8 @@ func VersionToName(version string) (string, error) {
|
|||||||
return "", ErrEmptyVersion
|
return "", ErrEmptyVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
if stableVersion.MatchString(version) {
|
if stableVersion.MatchString(version) ||
|
||||||
|
strings.HasSuffix(version, "-pretest") {
|
||||||
return "Emacs-" + version, nil
|
return "Emacs-" + version, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +36,7 @@ func VersionToName(version string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GitRefToStableVersion(ref string) (string, error) {
|
func GitRefToStableVersion(ref string) (string, error) {
|
||||||
if m := stableGetRef.FindStringSubmatch(ref); len(m) > 1 {
|
if m := stableGitRef.FindStringSubmatch(ref); len(m) > 1 {
|
||||||
return m[1], nil
|
return m[1], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,3 +128,15 @@ func (s *Repository) ActionRunURL(runID string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Repository) ReleaseURL(releaseName string) string {
|
||||||
|
if releaseName == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
switch s.Type {
|
||||||
|
case GitHub:
|
||||||
|
return GitHubBaseURL + s.Source + "/releases/tag/" + releaseName
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
54
pkg/repository/repository_test.go
Normal file
54
pkg/repository/repository_test.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package repository
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRepository_ReleaseURL(t *testing.T) {
|
||||||
|
type fields struct {
|
||||||
|
Type Type
|
||||||
|
Source string
|
||||||
|
}
|
||||||
|
type args struct {
|
||||||
|
releaseName string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
fields fields
|
||||||
|
args args
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "empty name",
|
||||||
|
fields: fields{Type: GitHub, Source: "foo/bar"},
|
||||||
|
args: args{releaseName: ""},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "GitHub, foo/bar, v1.0.0",
|
||||||
|
fields: fields{Type: GitHub, Source: "foo/bar"},
|
||||||
|
args: args{releaseName: "v1.0.0"},
|
||||||
|
want: "https://github.com/foo/bar/releases/tag/v1.0.0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Not GitHub, foo/bar, v1.0.0",
|
||||||
|
fields: fields{Type: Type("oops"), Source: "foo/bar"},
|
||||||
|
args: args{releaseName: "v1.0.0"},
|
||||||
|
want: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
repo := &Repository{
|
||||||
|
Type: tt.fields.Type,
|
||||||
|
Source: tt.fields.Source,
|
||||||
|
}
|
||||||
|
|
||||||
|
got := repo.ReleaseURL(tt.args.releaseName)
|
||||||
|
|
||||||
|
assert.Equal(t, tt.want, got)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
9
pkg/sanitize/string.go
Normal file
9
pkg/sanitize/string.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package sanitize
|
||||||
|
|
||||||
|
import "regexp"
|
||||||
|
|
||||||
|
var nonAlphaNum = regexp.MustCompile(`[^\w_-]+`)
|
||||||
|
|
||||||
|
func String(s string) string {
|
||||||
|
return nonAlphaNum.ReplaceAllString(s, "-")
|
||||||
|
}
|
||||||
@@ -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