Compare commits

...

8 Commits

Author SHA1 Message Date
github-actions[bot]
509d8bf0b8 chore(master): release 0.6.52 (#122)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-30 22:11:44 +00:00
d7723ee766 fix(nix/flake): rename flake-package-versions.txt to flake.pkgs 2024-11-30 22:10:50 +00:00
github-actions[bot]
9c99da14b3 chore(master): release 0.6.51 (#121)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-28 10:49:30 +00:00
ccb4f3f438 fix(build/embed): include all Emacs C sources and related files in the Emacs.app bundle (#120)
Changelog files from the `src` directory are however excluded. They're
6.7MB, span 1985 to 2015, and are not very relevant for inclusion within
the Emacs.app bundle.

Resolves https://github.com/jimeh/emacs-builds/issues/40
2024-11-28 10:34:49 +00:00
github-actions[bot]
4c997758f8 chore(master): release 0.6.50 (#117)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-25 02:47:00 +00:00
8267ac1662 feat(build/options): add --optimize and related flags (#119)
Allow setting -march=native -mtune=native and -fomit-frame-pointer all
in one go, but also control each individually with new flags for each.
2024-11-25 02:45:06 +00:00
5c513ce2e7 feat(package): produce and include configure output log (#118)
Useful for debugging build issues, and for people who simply want more
details about the build environment and process for Emacs.
2024-11-25 02:40:02 +00:00
6e2b9aa44a feat(deps): add support for Nix package manager (#116)
This serves as an alternative to Homebrew. It should be much more stable
and cause less headaches over time for automated builds.

There should be no change to the end user experience of using the build
script, as it should still work with and use Homebrew by default.

Additionally, Nix provides older Apple SDKs, allowing us to run against
macOS 11.x SDKs. This allows the resulting Emacs.app builds to be
compatible with macOS 11.x and later versions.

In testing, this seems to be the case on macOS 11.x (x86_64) and macOS
12.x (arm64).
2024-11-25 02:31:47 +00:00
20 changed files with 977 additions and 224 deletions

View File

@@ -1,3 +1,3 @@
{
".": "0.6.49"
".": "0.6.52"
}

View File

@@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.23"
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.55
version: v1.61
env:
VERBOSE: "true"
@@ -23,9 +23,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.23"
- name: Check if mods are tidy
run: make check-tidy
@@ -34,9 +34,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: "1.20"
go-version: "1.23"
- name: Run tests
run: make test
env:

1
.gitignore vendored
View File

@@ -1,7 +1,6 @@
.DS_Store
.envrc
Formula/*
Gemfile.lock
bin
builds
sources

View File

@@ -7,7 +7,6 @@ linters-settings:
gocyclo:
min-complexity: 20
govet:
check-shadowing: true
enable-all: true
disable:
- fieldalignment
@@ -23,9 +22,9 @@ linters:
disable-all: true
enable:
- bodyclose
- copyloopvar
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
@@ -72,12 +71,12 @@ issues:
- source: "`yaml:"
linters:
- lll
run:
skip-dirs:
exclude-dirs:
- builds
- sources
- tarballs
run:
timeout: 2m
allow-parallel-runners: true
modules-download-mode: readonly

View File

@@ -1,5 +1,28 @@
# Changelog
## [0.6.52](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.51...v0.6.52) (2024-11-30)
### Bug Fixes
* **nix/flake:** rename flake-package-versions.txt to flake.pkgs ([d7723ee](https://github.com/jimeh/build-emacs-for-macos/commit/d7723ee766574b6597997de7c54fb7ed7f37965c))
## [0.6.51](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.50...v0.6.51) (2024-11-28)
### Bug Fixes
* **build/embed:** include all Emacs C sources and related files in the Emacs.app bundle ([#120](https://github.com/jimeh/build-emacs-for-macos/issues/120)) ([ccb4f3f](https://github.com/jimeh/build-emacs-for-macos/commit/ccb4f3f438652c7ae98c202b8afed8861f40eeec))
## [0.6.50](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.49...v0.6.50) (2024-11-25)
### Features
* **build/options:** add --optimize and related flags ([#119](https://github.com/jimeh/build-emacs-for-macos/issues/119)) ([8267ac1](https://github.com/jimeh/build-emacs-for-macos/commit/8267ac166203c0c495520e6970650735702eac35))
* **deps:** add support for Nix package manager ([#116](https://github.com/jimeh/build-emacs-for-macos/issues/116)) ([6e2b9aa](https://github.com/jimeh/build-emacs-for-macos/commit/6e2b9aa44ae1cbc3eec8ec7318ce9c9968e2d673))
* **package:** produce and include configure output log ([#118](https://github.com/jimeh/build-emacs-for-macos/issues/118)) ([5c513ce](https://github.com/jimeh/build-emacs-for-macos/commit/5c513ce2e7536c57f43a49739b3f0f66d15f7b6d))
## [0.6.49](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.48...v0.6.49) (2024-11-03)

View File

@@ -5,8 +5,5 @@ source 'http://rubygems.org/'
gem 'ruby-macho'
group :development do
gem 'byebug'
gem 'rubocop'
gem 'rubocop-daemon'
gem 'solargraph', '~> 0.39.17'
end

40
Gemfile.lock Normal file
View File

@@ -0,0 +1,40 @@
GEM
remote: http://rubygems.org/
specs:
ast (2.4.2)
json (2.8.2)
language_server-protocol (3.17.0.3)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
racc (1.8.1)
rainbow (3.1.1)
regexp_parser (2.9.2)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
ruby-macho (4.1.0)
ruby-progressbar (1.13.0)
unicode-display_width (2.6.0)
PLATFORMS
arm64-darwin
ruby
x86_64-darwin
DEPENDENCIES
rubocop
ruby-macho
BUNDLED WITH
2.5.23

View File

@@ -48,10 +48,12 @@ SHELL := env \
bootstrap: bootstrap-brew bootstrap-ruby
bootstrap-ruby:
bundle install
env BUNDLE_WITHOUT=development bundle install
bootstrap-brew:
ifndef IN_NIX_SHELL
brew bundle --verbose
endif
bootstrap-pip:
$(PIP) install -r requirements-ci.txt
@@ -69,7 +71,7 @@ $(TOOLDIR)/$(1): Makefile
endef
$(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest))
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55))
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61))
$(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest))
.PHONY: tools
@@ -132,6 +134,21 @@ format: $(TOOLDIR)/gofumpt
gen:
go generate $$(go list ./... | grep -v 'sources/' | grep -v 'builds/')
.PHONY: nix-flake-update
nix-flake-update:
nix flake update \
&& $(MAKE) flake.pkgs
.SILENT: flake-package-versions
flake-package-versions:
nix develop --command -- bash -c \
'nix derivation show \
$$(echo $$PATH | tr ":" "\n" | grep "/nix/store" | sort -u) \
| jq -r ".[].name" | sort -u'
flake.pkgs: flake.nix flake.lock
$(MAKE) flake-package-versions > "$@"
#
# Dependencies
#

View File

@@ -36,18 +36,40 @@ The build produced does have some limitations:
## Requirements
Required with both Nix and Homebrew approaches:
- [Xcode](https://apps.apple.com/gb/app/xcode/id497799835?mt=12)
- [Homebrew](https://brew.sh/)
- Ruby 2.3.0 or later is needed to execute the build script itself. macOS comes
with Ruby, check your version with `ruby --version`. If it's too old, you can
install a newer version with:
```
brew install ruby
```
- All dependencies can all easily be installed by running:
```
make bootstrap
```
### Nix
The [Nix](https://nixos.org/) package manager is the preferred and most reliable
way to install all dependencies required to build Emacs, by way of a Nix flake
included in the project root.
To install all required dependencies within the nix shell, run:
```
nix develop --command make bootstrap
```
### Homebrew
If you do not have Nix installed, then the alternative way to manage and install
build-time dependencies is via [Homebrew](https://brew.sh/).
Ruby 3.3.x or later is also needed to execute the build script. Earlier versions
may work, but are untested. Simplest way to install a recent Ruby version is via
Homebrew:
```
brew install ruby
```
And finally, to install all built-time dependencies, run:
```
make bootstrap
```
## Status
@@ -71,6 +93,24 @@ Nightly builds are built with GitHub Actions on GitHub-hosted runners, using
## Usage
### Nix
Ensure [Flakes](https://nixos.wiki/wiki/Flakes) are enabled, and enter the flake
development environment with `nix develop`. Within this environment, you can
execute the `./build-emacs-for-macos --help` to get started.
Or you can run the build script via `nix develop`:
```
nix develop --command ./build-emacs-for-macos --help
```
### Homebrew
Run `make boostrap` to ensure all Ruby and Homebrew dependencies are installed.
### Build Script
```
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
@@ -78,8 +118,11 @@ Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
available here: https://github.com/emacs-mirror/emacs
Options:
--info Print environment info and detected library paths, then exit
--preview Print preview details about build and exit.
-j, --parallel COUNT Compile using COUNT parallel processes (detected: 16)
--git-sha SHA Override detected git SHA of specified branch allowing builds of old commits
--[no-]use-nix Use Nix instead of Homebrew to find dependencies (default: enabled if IN_NIX_SHELL is set)
--[no-]xwidgets Enable/disable XWidgets if supported (default: enabled)
--[no-]tree-sitter Enable/disable tree-sitter if supported (default: enabled)
--[no-]native-comp Enable/disable native-comp (default: enabled if supported)

File diff suppressed because it is too large Load Diff

61
flake.lock generated Normal file
View File

@@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1731603435,
"narHash": "sha256-CqCX4JG7UiHvkrBTpYC3wcEurvbtTADLbo3Ns2CEoL8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8b27c1239e5c421a2bbc2c65d52e4a6fbf2ff296",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "24.11-beta",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

102
flake.nix Normal file
View File

@@ -0,0 +1,102 @@
{
description = "Development environment flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.11-beta";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# List of supported macOS SDK versions.
sdk_versions = [ "11" "12" "13" "14" "15" ];
default_sdk_version = "11";
mkDevShell = { macos_version ? default_sdk_version }:
let
apple_sdk = pkgs.${"apple-sdk_${macos_version}"};
in
pkgs.mkShell {
# Package list specifically excludes ncurses, so that we link
# against the system version of ncurses. This ensures emacs' TUI
# works out of the box without the user having to manually set
# TERMINFO in the shell before launching emacs.
packages = with pkgs; [
apple_sdk
autoconf
bash
cairo
clang
coreutils
curl
darwin.DarwinTools # sw_vers
dbus
expat
findutils
gcc
gettext
giflib
git
gmp
gnumake
gnupatch
gnused
gnutar
gnutls
harfbuzz
jansson
jq
lcms2
libffi
libgccjit
libiconv
libjpeg
libpng
librsvg
libtasn1
libunistring
libwebp
libxml2
mailutils
nettle
pkg-config
python3
rsync
ruby_3_3
sqlite
texinfo
time
tree-sitter
which
xcbuild
zlib
];
shellHook = ''
export CC=clang
export MACOSX_DEPLOYMENT_TARGET="${macos_version}.0"
export DEVELOPER_DIR="${apple_sdk}"
export NIX_LIBGCCJIT_VERSION="${pkgs.libgccjit.version}"
export NIX_LIBGCCJIT_ROOT="${pkgs.libgccjit.outPath}"
export BUNDLE_WITHOUT=development
'';
};
# Generate an attrset of shells for each macOS SDK version.
versionShells = builtins.listToAttrs (
map (version: {
name = "macos${version}";
value = mkDevShell { macos_version = version; };
}) sdk_versions
);
in
{
devShells = versionShells // {
default = mkDevShell {};
};
}
);
}

67
flake.pkgs Normal file
View File

@@ -0,0 +1,67 @@
DarwinTools-1
autoconf-2.72
bash-5.2p37
brotli-1.1.0
bzip2-1.0.8
cairo-1.18.2
cctools-binutils-darwin-1010.6
cctools-binutils-darwin-wrapper-1010.6
clang-16.0.6
clang-wrapper-16.0.6
coreutils-9.5
curl-8.11.0
dbus-1.14.10
diffutils-3.10
expat-2.6.4
file-5.45
findutils-4.10.0
fontconfig-2.15.0
freetype-2.13.3
gawk-5.3.1
gcc-13.3.0
gcc-wrapper-13.3.0
gdk-pixbuf-2.42.12
gettext-0.21.1
giflib-5.2.2
git-2.47.0
glib-2.82.1
gnugrep-3.11
gnumake-4.4.1
gnused-4.9
gnutar-1.35
gnutls-3.8.6
graphite2-1.3.14
gzip-1.13
harfbuzz-10.0.1
jq-1.7.1
krb5-1.21.3
lcms2-2.16
libdeflate-1.22
libgccjit-13.3.0
libiconv-107
libidn2-2.3.7
libjpeg-turbo-3.0.4
libpng-apng-1.6.43
libpsl-0.21.5
librsvg-2.58.3
libtasn1-4.19.0
libtiff-4.7.0
libwebp-1.4.0
libxml2-2.13.4
mailutils-3.17
nettle-3.10
nghttp2-1.64.0
openssl-3.3.2
patch-2.7.6
pkg-config-wrapper-0.29.2
python3-3.12.7
rsync-3.3.0
ruby-3.3.5
sqlite-3.46.1
texinfo-7.1.1
time-1.9
tree-sitter-0.24.3
which-2.21
xcbuild-0.1.1-unstable-2019-11-20
xz-5.6.3
zstd-1.5.6

2
go.mod
View File

@@ -1,6 +1,6 @@
module github.com/jimeh/build-emacs-for-macos
go 1.20
go 1.23
require (
github.com/bearer/gon v0.0.36

1
go.sum
View File

@@ -24,6 +24,7 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-github/v35 v35.3.0 h1:fU+WBzuukn0VssbayTT+Zo3/ESKX9JYWjbZTLOTEyho=
github.com/google/go-github/v35 v35.3.0/go.mod h1:yWB7uCcVWaUbUP74Aq3whuMySRMatyRmq5U9FTNlbio=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=

View File

@@ -110,6 +110,18 @@ func Create(ctx context.Context, opts *Options) (string, error) {
})
}
configureOutputFile := filepath.Join(sourceDir, "configure_output.txt")
fi, err = os.Stat(configureOutputFile)
if err != nil && !os.IsNotExist(err) {
return "", err
} else if err == nil && fi.Mode().IsRegular() {
settings.Files = append(settings.Files, &dmgbuild.File{
Path: configureOutputFile,
PosX: 340,
PosY: 756,
})
}
if opts.Output != nil {
settings.Stdout = opts.Output
settings.Stderr = opts.Output

View File

@@ -116,7 +116,6 @@ func NewLicense() License {
return License{}
}
//nolint:goconst
func (s *License) Render() []string {
var l []string

View File

@@ -1,41 +1,65 @@
package osinfo
import (
"os"
"os/exec"
"strconv"
"strings"
)
type OSInfo struct {
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
Arch string `yaml:"arch" json:"arch"`
Name string `yaml:"name" json:"name"`
Version string `yaml:"version" json:"version"`
SDKVersion string `yaml:"sdk_version" json:"sdk_version"`
Arch string `yaml:"arch" json:"arch"`
}
func New() (*OSInfo, error) {
version, err := exec.Command("sw_vers", "-productVersion").CombinedOutput()
version, err := exec.Command("sw_vers", "-productVersion").Output()
if err != nil {
return nil, err
}
sdkVersion := os.Getenv("MACOSX_DEPLOYMENT_TARGET")
if sdkVersion == "" {
var ver []byte
ver, err = exec.Command("xcrun", "--show-sdk-version").Output()
if err != nil {
return nil, err
}
sdkVersion = string(ver)
}
arch, err := exec.Command("uname", "-m").CombinedOutput()
if err != nil {
return nil, err
}
return &OSInfo{
Name: "macOS",
Version: strings.TrimSpace(string(version)),
Arch: strings.TrimSpace(string(arch)),
Name: "macOS",
Version: strings.TrimSpace(string(version)),
SDKVersion: strings.TrimSpace(sdkVersion),
Arch: strings.TrimSpace(string(arch)),
}, nil
}
// DistinctVersion returns macOS version down to a distinct "major"
// version. For macOS 10.x, this will include the first two numeric parts of the
// version (10.15), while for 11.x and later, the first numeric part is enough
// (11).
// DistinctVersion returns macOS version down to a distinct "major" version. For
// macOS 10.x, this will include the first two numeric parts of the version
// (10.15), while for 11.x and later, the first numeric part is enough (11).
func (s *OSInfo) DistinctVersion() string {
parts := strings.Split(s.Version, ".")
return s.distinctVersion(s.Version)
}
// DistinctSDKVersion returns macOS version down to a distinct "major" version.
// For macOS 10.x, this will include the first two numeric parts of the version
// (10.15), while for 11.x and later, the first numeric part is enough (11).
func (s *OSInfo) DistinctSDKVersion() string {
return s.distinctVersion(s.SDKVersion)
}
func (s *OSInfo) distinctVersion(version string) string {
parts := strings.Split(version, ".")
if n, _ := strconv.Atoi(parts[0]); n >= 11 {
return parts[0]

View File

@@ -95,10 +95,17 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) { //nolint:funlen
releaseName = "Emacs." + version
}
// Attempt to get the macOS SDK version from the environment, if it's not
// available, use the version from the system.
targetMacOSVersion := osInfo.DistinctSDKVersion()
if targetMacOSVersion == "" {
targetMacOSVersion = osInfo.DistinctVersion()
}
buildName := fmt.Sprintf(
"Emacs.%s.%s.%s",
absoluteVersion,
sanitize.String(osInfo.Name+"-"+osInfo.DistinctVersion()),
sanitize.String(osInfo.Name+"-"+targetMacOSVersion),
sanitize.String(osInfo.Arch),
)
diskImage := buildName + ".dmg"

View File

@@ -123,7 +123,7 @@ func signCLIHelper(ctx context.Context, appBundle string, opts *Options) error {
// app bundle itself.
func elnFiles(emacsApp string) ([]string, error) {
var files []string
walkDirFunc := func(path string, d fs.DirEntry, _err error) error {
walkDirFunc := func(path string, d fs.DirEntry, _ error) error {
if d.Type().IsRegular() && strings.HasSuffix(path, ".eln") &&
!strings.Contains(path, ".app/Contents/Frameworks/") {
files = append(files, path)