Compare commits

..

14 Commits

Author SHA1 Message Date
github-actions[bot]
00015d861f chore(master): release 0.6.58 (#135)
Co-authored-by: jimehbot[bot] <132453784+jimehbot[bot]@users.noreply.github.com>
2025-06-27 11:41:15 +01:00
ca8b874be2 feat(builder/plan): add build variant flag (#137) 2025-06-27 11:39:52 +01:00
5d36f02cca ci(release-please): use custom bot account to publish release PRs 2025-06-27 11:32:25 +01:00
5c37e8b0a2 ci(permissions): set correct permissions for release-please job 2025-06-27 11:27:56 +01:00
28ff28b29a chore(ci/deps): upgrade CI dependencies and fix linting issues (#136) 2025-06-27 11:25:16 +01:00
3cf1977def fix(deps): work around duplicate RPATHs in libgccjit from Nix (#134) 2025-06-27 11:05:46 +01:00
bc2a45767e chore(deps): use HTTPS for Gemfile source directive 2025-06-26 20:02:08 +01:00
github-actions[bot]
2320030121 chore(master): release 0.6.57 (#130) 2024-12-07 22:19:36 +00:00
c53c398cac feat(patches/alpha-background): add experimental alpha-background patch (#129)
Resolves #111
2024-12-07 21:00:41 +00:00
github-actions[bot]
f7b2baa363 chore(master): release 0.6.56 (#128)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-12-03 03:23:24 +00:00
d396165808 fix(patches): improve chance of successful patch application by using -l
This causes patch to ignore whitespace changes, which should make it
more likely to apply patches which may not be an exact match.
2024-12-03 03:21:31 +00:00
66ccd9c6fd feat(options): add --patch option which accepts file path or URL (#127)
This allows users to easily apply custom patches from a file on disk, or
from a URL. It's particularly hady to quickly test out a changeset from
a GitHub commit/diff or elsewhere.
2024-12-03 03:14:14 +00:00
github-actions[bot]
907f7babbc chore(master): release 0.6.55 (#126)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-12-03 00:19:59 +00:00
e030fee670 feat(nix/deps): update nixpkgs from 24.11-beta to 24.11 2024-12-03 00:18:35 +00:00
18 changed files with 1233 additions and 362 deletions

View File

@@ -1,3 +1,3 @@
{
".": "0.6.54"
".": "0.6.58"
}

View File

@@ -1,5 +1,6 @@
{
"bootstrap-sha": "3d6c7fff64bda8ba0dbea181c9f94fb9716dd188",
"always-update": true,
"packages": {
".": {
"release-type": "simple",

View File

@@ -1,6 +1,8 @@
---
name: CI
on: [push]
permissions:
contents: read
jobs:
lint:
@@ -10,11 +12,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.61
version: v2.1
env:
VERBOSE: "true"
@@ -25,7 +27,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version-file: go.mod
- name: Check if mods are tidy
run: make check-tidy
@@ -36,14 +38,21 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23"
go-version-file: go.mod
- name: Run tests
run: make test
env:
VERBOSE: "true"
release-please:
name: Release Please
runs-on: ubuntu-latest
if: github.ref_name == 'main' || github.ref_name == 'master'
if: ${{ github.ref_name == 'main' || github.ref_name == 'master' }}
permissions:
contents: write
pull-requests: write
steps:
- uses: jimeh/release-please-manifest-action@v1
- uses: jimeh/release-please-manifest-action@v2
with:
app-id: ${{ secrets.RELEASE_BOT_APP_ID }}
private-key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }}

View File

@@ -1,25 +1,9 @@
linters-settings:
funlen:
lines: 100
statements: 150
goconst:
min-occurrences: 5
gocyclo:
min-complexity: 20
govet:
enable-all: true
disable:
- fieldalignment
lll:
line-length: 80
tab-width: 4
maligned:
suggest-new: true
misspell:
locale: US
version: "2"
run:
modules-download-mode: readonly
allow-parallel-runners: true
linters:
disable-all: true
default: none
enable:
- bodyclose
- copyloopvar
@@ -30,12 +14,8 @@ linters:
- goconst
- gocritic
- gocyclo
- gofumpt
- goimports
- goprintffuncname
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- lll
@@ -47,36 +27,69 @@ linters:
- revive
- sqlclosecheck
- staticcheck
- typecheck
- unconvert
- unused
- whitespace
issues:
exclude:
- Using the variable on range scope `tt` in function literal
- Using the variable on range scope `tc` in function literal
exclude-rules:
- path: "_test\\.go"
linters:
- funlen
- dupl
- goconst
- source: "^//go:generate "
linters:
- lll
- source: "`json:"
linters:
- lll
- source: "`yaml:"
linters:
- lll
exclude-dirs:
- builds
- sources
- tarballs
run:
timeout: 2m
allow-parallel-runners: true
modules-download-mode: readonly
settings:
funlen:
lines: 100
statements: 150
goconst:
min-occurrences: 5
gocyclo:
min-complexity: 20
govet:
disable:
- fieldalignment
enable-all: true
lll:
line-length: 80
tab-width: 4
misspell:
locale: US
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- dupl
- funlen
- goconst
path: _test\.go
- linters:
- lll
source: "^//go:generate "
- linters:
- lll
source: "`json:"
- linters:
- lll
source: "`yaml:"
- path: (.+)\.go$
text: Using the variable on range scope `tt` in function literal
- path: (.+)\.go$
text: Using the variable on range scope `tc` in function literal
paths:
- builds
- sources
- tarballs
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- builds
- sources
- tarballs
- third_party$
- builtin$
- examples$

View File

@@ -1,5 +1,43 @@
# Changelog
## [0.6.58](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.57...v0.6.58) (2025-06-27)
### Features
* **builder/plan:** add build variant flag ([#137](https://github.com/jimeh/build-emacs-for-macos/issues/137)) ([ca8b874](https://github.com/jimeh/build-emacs-for-macos/commit/ca8b874be2c8c52cd7dcb05ff1348469e16c74ba))
### Bug Fixes
* **deps:** work around duplicate RPATHs in libgccjit from Nix ([#134](https://github.com/jimeh/build-emacs-for-macos/issues/134)) ([3cf1977](https://github.com/jimeh/build-emacs-for-macos/commit/3cf1977def02d1f3732b1051bc07a923557f9edd))
## [0.6.57](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.56...v0.6.57) (2024-12-07)
### Features
* **patches/alpha-background:** add experimental alpha-background patch ([#129](https://github.com/jimeh/build-emacs-for-macos/issues/129)) ([c53c398](https://github.com/jimeh/build-emacs-for-macos/commit/c53c398cace6479a9c188e46196462791960abee)), closes [#111](https://github.com/jimeh/build-emacs-for-macos/issues/111)
## [0.6.56](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.55...v0.6.56) (2024-12-03)
### Features
* **options:** add --patch option which accepts file path or URL ([#127](https://github.com/jimeh/build-emacs-for-macos/issues/127)) ([66ccd9c](https://github.com/jimeh/build-emacs-for-macos/commit/66ccd9c6fd077d558eae484cdbab831486fbfd58))
### Bug Fixes
* **patches:** improve chance of successful patch application by using -l ([d396165](https://github.com/jimeh/build-emacs-for-macos/commit/d396165808ab5852566e7ff6bcc23d47ddfdfdee))
## [0.6.55](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.54...v0.6.55) (2024-12-03)
### Features
* **nix/deps:** update nixpkgs from 24.11-beta to 24.11 ([e030fee](https://github.com/jimeh/build-emacs-for-macos/commit/e030fee6704618b7ddefea7424dff4e94f43e84d))
## [0.6.54](https://github.com/jimeh/build-emacs-for-macos/compare/v0.6.53...v0.6.54) (2024-12-01)

View File

@@ -1,6 +1,6 @@
# frozen_string_literal: true
source 'http://rubygems.org/'
source 'https://rubygems.org/'
gem 'ruby-macho'

View File

@@ -1,5 +1,5 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
ast (2.4.2)
json (2.8.2)

View File

@@ -71,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.61))
$(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1))
$(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest))
.PHONY: tools

View File

@@ -131,7 +131,6 @@ Options:
-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)
--optimize Shorthand for --native-march --native-mtune --fomit-frame-pointer (default: disabled)
@@ -142,10 +141,13 @@ Options:
--[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-]dbus Enable/disable dbus support (default: enabled)
--no-titlebar Apply no-titlebar patch (default: disabled)
--posix-spawn Apply posix-spawn patch (deprecated)
--no-frame-refocus Apply no-frame-refocus patch (default: disabled)
--[no-]alpha-background Enable/disable experimental alpha-background patch when building Emacs 30.x - 31.x (default: disabled)
--no-frame-refocus Apply no-frame-refocus patch when building Emacs 27.x - 31.x (default: disabled)
--no-titlebar Apply no-titlebar patch when building Emacs 27.x - 28.x (default: disabled)
--[no-]xwidgets Enable/disable XWidgets when building Emacs 27.x (default: disabled)
--[no-]poll Apply poll patch (deprecated)
--posix-spawn Apply posix-spawn patch (deprecated)
-p, --patch=URL Specify a custom patch file or URL to apply to the Emacs source (can be used multiple times)
--[no-]fd-setsize SIZE Set an file descriptor (max open files) limit (default: 10000)
--github-src-repo REPO Specify a GitHub repo to download source tarballs from (default: emacs-mirror/emacs)
--[no-]github-auth Make authenticated GitHub API requests if GITHUB_TOKEN environment variable is set.(default: enabled)
@@ -159,6 +161,7 @@ Options:
Enable/disable keeping source folder for archive (default: disabled)
--log-level LEVEL Build script log level (default: info)
--plan FILE Follow given plan file, instead of using given git ref/sha
--clean-macho-binary FILE Tool to clean duplicate RPATHs from given Mach-O binary.
```
Resulting applications are saved to the `builds` directory in a bzip2 compressed

View File

@@ -12,6 +12,7 @@ require 'net/http'
require 'open3'
require 'optparse'
require 'pathname'
require 'set'
require 'time'
require 'tmpdir'
require 'uri'
@@ -79,6 +80,16 @@ module Output
end
end
module Helpers
def valid_url?(uri)
uri = URI.parse(uri)
(uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)) &&
uri.host.respond_to?(:empty?) && !uri.host.empty?
rescue URI::InvalidURIError
false
end
end
module System
include Output
@@ -183,6 +194,7 @@ end
class Build
include Output
include System
include Helpers
DEFAULT_GITHUB_REPO = 'emacs-mirror/emacs'
@@ -207,7 +219,7 @@ class Build
end
tarball = download_tarball(meta[:sha])
@source_dir = extract_tarball(tarball, patches(options))
@source_dir = extract_tarball(tarball, build_patches)
autogen
detect_native_comp if options[:native_comp].nil?
@@ -495,7 +507,7 @@ class Build
def env_CFLAGS
return @env_CFLAGS if @env_CFLAGS
env = []
env = ENV.fetch('CFLAGS', nil)&.split || []
env << '-O2'
@@ -521,13 +533,28 @@ class Build
env += ENV['NIX_CFLAGS_COMPILE'].split
end
@env_CFLAGS = env
# Group "-isystem <path>" flags together as a single flag. This allows us to
# de-duplicate CFLAGS from NIX_CFLAGS_COMPILE.
new_env = []
isystem_flag = false
env.each do |flag|
if flag.strip == '-isystem'
isystem_flag = true
elsif isystem_flag
new_env << "-isystem #{flag}"
isystem_flag = false
else
new_env << flag
end
end
@env_CFLAGS = new_env.compact.reject(&:empty?).uniq
end
def env_LDFLAGS
return @env_LDFLAGS if @env_LDFLAGS
env = []
env = ENV.fetch('LDFLAGS', nil)&.split || []
# Ensure library re-linking and code signing will work after building.
env << '-Wl,-headerpad_max_install_names'
@@ -544,13 +571,13 @@ class Build
env += ENV['NIX_LDFLAGS'].split if use_nix? && ENV['NIX_LDFLAGS']
@env_LDFLAGS = env
@env_LDFLAGS = env.compact.reject(&:empty?).uniq
end
def env_LIBRARY_PATH
return @env_LIBRARY_PATH if @env_LIBRARY_PATH
env = []
env = ENV.fetch('LIBRARY_PATH', nil)&.split || []
if options[:native_comp]
env += [
@@ -562,37 +589,45 @@ class Build
env << '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib'
@env_LIBRARY_PATH = env
@env_LIBRARY_PATH = env.compact.reject(&:empty?).uniq
end
def env_PKG_CONFIG_PATH
return [] if use_nix?
env = ENV.fetch('PKG_CONFIG_PATH', nil)&.split || []
@env_PKG_CONFIG_PATH ||= [
File.join(brew_dir, 'lib/pkgconfig'),
File.join(brew_dir, 'share/pkgconfig'),
File.join(brew_dir, 'opt/expat/lib/pkgconfig'),
File.join(brew_dir, 'opt/libxml2/lib/pkgconfig'),
File.join(brew_dir, 'opt/ncurses/lib/pkgconfig'),
File.join(brew_dir, 'opt/zlib/lib/pkgconfig'),
File.join(
brew_dir,
'Homebrew/Library/Homebrew/os/mac/pkgconfig',
OS.version.to_s
)
]
return env if use_nix?
@env_PKG_CONFIG_PATH = (
[
File.join(brew_dir, 'lib/pkgconfig'),
File.join(brew_dir, 'share/pkgconfig'),
File.join(brew_dir, 'opt/expat/lib/pkgconfig'),
File.join(brew_dir, 'opt/libxml2/lib/pkgconfig'),
File.join(brew_dir, 'opt/ncurses/lib/pkgconfig'),
File.join(brew_dir, 'opt/zlib/lib/pkgconfig'),
File.join(
brew_dir,
'Homebrew/Library/Homebrew/os/mac/pkgconfig',
OS.version.to_s
)
] + env
).compact.reject(&:empty?).uniq
end
def env_PATH
return [] if use_nix?
env = ENV.fetch('PATH', nil)&.split || []
@env_PATH ||= [
File.join(brew_dir, 'opt/make/libexec/gnubin'),
File.join(brew_dir, 'opt/coreutils/libexec/gnubin'),
File.join(brew_dir, 'opt/gnu-sed/libexec/gnubin'),
File.join(brew_dir, 'bin'),
File.join(brew_dir, 'opt/texinfo/bin')
]
return env if use_nix?
@env_PATH = (
[
File.join(brew_dir, 'opt/make/libexec/gnubin'),
File.join(brew_dir, 'opt/coreutils/libexec/gnubin'),
File.join(brew_dir, 'opt/gnu-sed/libexec/gnubin'),
File.join(brew_dir, 'bin'),
File.join(brew_dir, 'opt/texinfo/bin')
] + env
).compact.reject(&:empty?).uniq
end
# rubocop:enable Naming/MethodName,Naming/VariableName
@@ -601,22 +636,14 @@ class Build
env = {
'CC' => use_nix? ? 'clang' : '/usr/bin/clang',
'PATH' => [
env_PATH, ENV.fetch('PATH', nil)
].flatten.compact.reject(&:empty?).join(':'),
'PKG_CONFIG_PATH' => [
env_PKG_CONFIG_PATH,
ENV.fetch('PKG_CONFIG_PATH', nil)
].flatten.compact.reject(&:empty?).join(':')
'PATH' => env_PATH.join(':'),
'PKG_CONFIG_PATH' => env_PKG_CONFIG_PATH.join(':')
}
if options[:native_comp]
env['CFLAGS'] = [env_CFLAGS, ENV.fetch('CFLAGS', nil)]
.flatten.compact.reject(&:empty?).join(' ')
env['LDFLAGS'] = [env_LDFLAGS, ENV.fetch('LDFLAGS', nil)]
.flatten.compact.reject(&:empty?).join(' ')
env['LIBRARY_PATH'] = [env_LIBRARY_PATH, ENV.fetch('LIBRARY_PATH', nil)]
.flatten.compact.reject(&:empty?).join(':')
env['CFLAGS'] = env_CFLAGS.join(' ')
env['LDFLAGS'] = env_LDFLAGS.join(' ')
env['LIBRARY_PATH'] = env_LIBRARY_PATH.join(':')
end
@compile_env = env
@@ -1041,7 +1068,7 @@ class Build
end
end
def patches(opts = {})
def build_patches
p = []
# Enabled by default patches.
@@ -1118,7 +1145,7 @@ class Build
}
end
if opts[:xwidgets] && effective_version == 27
if options[:xwidgets] && effective_version == 27
p << {
url:
'https://github.com/d12frosted/homebrew-emacs-plus/raw/master/' \
@@ -1126,6 +1153,36 @@ class Build
}
end
if options[:alpha_background]
if effective_version == 29
p << {
file: File.join(
__dir__, 'patches', 'emacs-29', 'ns-alpha-background.patch'
)
}
elsif (30..31).include?(effective_version)
p << {
url:
"https://github.com/emacs-mirror/emacs/compare/#{meta[:sha]}" \
'...jonrubens:emacs:ns-alpha-background.patch'
}
end
end
# Custom patches.
options[:patches].each do |patch_str|
patch = {}
if valid_url?(patch_str)
patch[:url] = patch_str
elsif File.exist?(patch_str)
patch[:file] = patch_str
else
fatal "Patch file or URL not found: #{patch_str}"
end
p << patch
end
p.uniq
end
@@ -1134,7 +1191,9 @@ class Build
if patch[:file]
info 'Applying patch...'
FileUtils.cd(target) { run_cmd('patch', '-f', '-p1', '-i', patch[:file]) }
FileUtils.cd(target) do
run_cmd('patch', '-f', '-p1', '-l', '-i', patch[:file])
end
elsif patch[:url]
patch_dir = "#{target}/macos_patches"
run_cmd('mkdir', '-p', patch_dir)
@@ -1658,6 +1717,7 @@ end
class GccInfo
include Output
include System
def initialize(use_nix: false)
@use_nix = use_nix
@@ -1780,7 +1840,7 @@ class GccInfo
Dir[
File.join(libgccjit_root_dir, 'lib/gcc/*/libgccjit*.dylib'),
File.join(libgccjit_root_dir, 'lib/gcc/*/libgccjit.so*'),
]
]
.map { |path| File.dirname(path) }
.select { |path| File.basename(path).match(/^\d+$/) }
.max_by { |path| File.basename(path).to_i }
@@ -1797,10 +1857,15 @@ class GccInfo
'brew reinstall libgccjit'
end
# No need to verify gcc vs libgccjit for Nix, as we can pull everything we
# need from the libgccjit package. On homebrew we need to pull parts from
# gcc and parts from libgccjit, hence we need to ensure versions match.
return if use_nix?
if use_nix?
Dir[File.join(libgccjit_lib_dir, 'libgccjit*.dylib')]
.each { |path| clean_macho_binary(path) }
# No need to verify gcc vs libgccjit for Nix, as we can pull everything we
# need from the libgccjit package. On homebrew we need to pull parts from
# gcc and parts from libgccjit, hence we need to ensure versions match.
return
end
return if major_version == libgccjit_major_version
@@ -1825,230 +1890,465 @@ class GccInfo
def relative_path(base, path)
Pathname.new(path).relative_path_from(Pathname.new(base)).to_s
end
def clean_macho_binary(path)
debug "Checking for duplicate RPATHs in #{path}"
macho_cleaner = MachOCleaner.new(path)
return unless macho_cleaner.has_duplicate_rpaths?
begin
info "Removing duplicate RPATHs from #{path}"
macho_cleaner.clean!
debug 'Cleaned duplicate RPATHs successfully!'
rescue MachOCleaner::PermissionError => e
warn "Could not remove duplicate RPATHs from #{path}: #{e.message}"
if ENV['USER'] == 'root'
fatal "Could not remove duplicate RPATHs from #{path}: #{e.message}"
else
warn '================================================================='
warn "Attempting to clean duplicate RPATHs from #{path} as root"
warn '================================================================='
run_cmd('sudo', $PROGRAM_NAME, '--clean-macho-binary', path)
end
end
end
end
# MachOCleaner is a class that cleans up a Mach-O file by removing all duplicate
# RPATH load commands. This ensures compatibility with macOS 15.4 and later,
# which refuses to load binaries and shared libraries with duplicate RPATHs.
class MachOCleaner
include Output
include System
class PermissionError < StandardError
def initialize(file, message = nil)
@file = file
super(message || "Insufficient permissions to modify #{file}")
end
attr_reader :file
end
attr_reader :file
def initialize(file_path, backup: true)
@file = file_path
@backup = backup
validate_file!
end
def backup?
@backup
end
# Main cleaning method - removes duplicate RPATH commands
def clean!
duplicate_paths = find_duplicate_rpaths(macho_object)
return if duplicate_paths.empty?
backup_file! if backup?
while_writable(@file) do
duplicate_paths.each do |rpath|
remove_rpath_with_install_name_tool!(rpath)
end
end
end
# Check if file has duplicate RPATH commands
def has_duplicate_rpaths?
count_duplicate_rpaths(macho_object).positive?
end
# Return total number of RPATH commands
def rpath_count
count_rpaths(macho_object)
end
# Return number of duplicate RPATH commands
def duplicate_rpath_count
count_duplicate_rpaths(macho_object)
end
private
# Validate that the file exists and is readable
def validate_file!
fatal "File does not exist: #{@file}" unless File.exist?(@file)
return if File.readable?(@file)
fatal "File is not readable: #{@file}"
end
# Load and memoize the Mach-O object
def macho_object
return @macho_object if @macho_object
begin
@macho_object = MachO.open(@file)
rescue MachO::MachOError => e
fatal "Not a valid Mach-O file: #{@file} (#{e.message})"
end
unless @macho_object.respond_to?(:rpaths)
fatal "Unsupported Mach-O file type: #{@file}"
end
@macho_object
end
def backup_file!
backup_file = "#{@file}.bak"
if File.exist?(backup_file)
debug "Backup file already exists: #{backup_file}"
return
end
FileUtils.cp(@file, backup_file)
debug "Backed up #{@file} to #{backup_file}"
rescue Errno::EPERM, Errno::EACCES => e
raise PermissionError.new(
backup_file, "Cannot create backup file: #{e.message}"
)
end
# Temporarily make file writable, execute block, then restore permissions
def while_writable(file)
# Check if file is already writable to avoid unnecessary permission changes
if File.writable?(file)
yield
return
end
original_mode = File.stat(file).mode
begin
File.chmod(0o755, file)
rescue Errno::EPERM, Errno::EACCES => e
raise PermissionError.new(
file, "Cannot change file permissions: #{e.message}"
)
end
yield
ensure
if File.exist?(file) && original_mode
begin
File.chmod(original_mode, file)
rescue Errno::EPERM, Errno::EACCES
# Log warning but don't fail - file was already modified successfully
warn "Warning: Could not restore original permissions for #{file}"
end
end
end
# Find duplicate RPATH commands in a Mach-O file
def find_duplicate_rpaths(macho_file)
seen = Set.new
duplicates = []
macho_file.rpaths.each do |rpath|
if seen.include?(rpath)
duplicates << rpath
else
seen.add(rpath)
end
end
duplicates
end
# Remove an RPATH using install_name_tool
def remove_rpath_with_install_name_tool!(rpath)
run_cmd('install_name_tool', '-delete_rpath', rpath, @file)
end
# Count total RPATH commands in a Mach-O file
def count_rpaths(macho_file)
macho_file.rpaths.size
end
# Count duplicate RPATH commands in a Mach-O file
def count_duplicate_rpaths(macho_file)
find_duplicate_rpaths(macho_file).size
end
end
class CLIOptions
include Output
include Helpers
def self.parse(args)
inst = new
inst.parse!(args)
inst.options
end
def parse!(args)
parser.parse!(args)
rescue OptionParser::InvalidOption => e
fatal e.message
end
def options
@options ||= defaults.dup.tap do |o|
o.each { |k, v| o[k] = v.dup if v.is_a?(Array) }
end
end
def defaults
{
work_dir: File.expand_path(__dir__),
native_full_aot: false,
relink_eln: true,
native_march: false,
parallel: Etc.nprocessors,
rsvg: true,
dbus: true,
use_nix: !ENV.fetch('IN_NIX_SHELL', '').empty?,
xwidgets: true,
tree_sitter: true,
fd_setsize: 10_000,
github_src_repo: nil,
github_auth: true,
dist_include: ['COPYING', 'configure_output.txt'],
self_sign: true,
archive: true,
archive_keep: false,
patches: [],
log_level: 'info',
clean_macho_binary: nil
}
end
def parser
@parser ||= OptionParser.new do |opts|
opts.banner = <<~DOC
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
available here: https://github.com/emacs-mirror/emacs
Options:
DOC
opts.on(
'--info',
'Print environment info and detected library paths, then exit'
) { |v| options[:info] = v }
opts.on(
'--preview',
'Print preview details about build and exit.'
) { |v| options[:preview] = v }
opts.on(
'-j',
'--parallel COUNT',
'Compile using COUNT parallel processes ' \
"(detected: #{options[:parallel]})"
) { |v| options[:parallel] = v }
opts.on(
'--git-sha SHA',
'Override detected git SHA of specified ' \
'branch allowing builds of old commits'
) { |v| options[:git_sha] = v }
opts.on(
'--[no-]use-nix',
'Use Nix instead of Homebrew to find dependencies ' \
'(default: enabled if IN_NIX_SHELL is set)'
) { |v| options[:use_nix] = v }
opts.on(
'--[no-]tree-sitter',
'Enable/disable tree-sitter if supported ' \
'(default: enabled)'
) { |v| options[:tree_sitter] = v }
opts.on(
'--[no-]native-comp',
'Enable/disable native-comp ' \
'(default: enabled if supported)'
) { |v| options[:native_comp] = v }
opts.on(
'--optimize',
'Shorthand for --native-march --native-mtune --fomit-frame-pointer ' \
'(default: disabled)'
) do
options[:native_march] = true
options[:native_mtune] = true
options[:fomit_frame_pointer] = true
end
opts.on(
'--[no-]native-march',
'Enable/disable -march=native CFLAG ' \
'(default: disabled)'
) { |v| options[:native_march] = v }
opts.on(
'--[no-]native-mtune',
'Enable/disable -mtune=native CFLAG ' \
'(default: disabled)'
) { |v| options[:native_mtune] = v }
opts.on(
'--[no-]fomit-frame-pointer',
'Enable/disable -fomit-frame-pointer CFLAG ' \
'(default: disabled)'
) { |v| options[:fomit_frame_pointer] = v }
opts.on(
'--[no-]native-full-aot',
'Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation ' \
'(default: disabled)'
) { |v| options[:native_full_aot] = v }
opts.on(
'--[no-]relink-eln-files',
'Enable/disable re-linking shared libraries in bundled *.eln ' \
'files (default: enabled)'
) { |v| options[:relink_eln] = v }
opts.on(
'--[no-]rsvg',
'Enable/disable SVG image support via librsvg ' \
'(default: enabled)'
) { |v| options[:rsvg] = v }
opts.on(
'--[no-]dbus',
'Enable/disable dbus support (default: enabled)'
) { |v| options[:dbus] = v }
opts.on(
'--alpha-background',
'Apply experimental alpha-background patch when building Emacs ' \
'30.x - 31.x (default: disabled)'
) { |v| options[:alpha_background] = v }
opts.on(
'--no-frame-refocus',
'Apply no-frame-refocus patch when building Emacs 27.x - 31.x ' \
'(default: disabled)'
) { options[:no_frame_refocus] = true }
opts.on(
'--no-titlebar',
'Apply no-titlebar patch when building Emacs 27.x - 28.x ' \
'(default: disabled)'
) { options[:no_titlebar] = true }
opts.on(
'--[no-]xwidgets',
'Enable/disable XWidgets when building Emacs 27.x ' \
'(default: disabled)'
) { |v| options[:xwidgets] = v }
opts.on('--[no-]poll', 'Apply poll patch (deprecated)') do
warn '==> WARN: poll patch is deprecated and has no effect.'
end
opts.on('--posix-spawn', 'Apply posix-spawn patch (deprecated)') do
warn '==> WARN: posix-spawn patch is deprecated and has no effect.'
end
opts.on(
'-p=URL', '--patch=URL',
'Specify a custom patch file or URL to apply to the Emacs source ' \
'(can be used multiple times)'
) do |v|
if !valid_url?(v) && !File.exist?(v)
fatal "Patch is not a URL or file: #{v}"
end
options[:patches] << v
end
opts.on(
'--[no-]fd-setsize SIZE',
'Set an file descriptor (max open files) limit (default: 10000)'
) { |v| options[:fd_setsize] = v.respond_to?(:to_i) ? v.to_i : 0 }
opts.on(
'--github-src-repo REPO',
'Specify a GitHub repo to download source tarballs from ' \
'(default: emacs-mirror/emacs)'
) { |v| options[:github_src_repo] = v }
opts.on(
'--[no-]github-auth',
'Make authenticated GitHub API requests if GITHUB_TOKEN ' \
'environment variable is set.' \
'(default: enabled)'
) { |v| options[:github_auth] = v }
opts.on(
'--work-dir DIR',
'Specify a working directory where tarballs, sources, and ' \
'builds will be stored and worked with'
) { |v| options[:work_dir] = v }
opts.on(
'-o DIR',
'--output DIR',
'Output directory for finished builds ' \
'(default: <work-dir>/builds)'
) { |v| options[:output] = v }
opts.on('--build-name NAME', 'Override generated build name') do |v|
options[:build_name] = v
end
opts.on(
'--dist-include x,y,z',
'List of extra files to copy from Emacs source into build ' \
'folder/archive (default: COPYING)'
) { |v| options[:dist_include] = v }
opts.on(
'--[no-]self-sign',
'Enable/disable self-signing of Emacs.app (default: enabled)'
) { |v| options[:self_sign] = v }
opts.on(
'--[no-]archive',
'Enable/disable creating *.tbz archive (default: enabled)'
) { |v| options[:archive] = v }
opts.on(
'--[no-]archive-keep-build-dir',
'Enable/disable keeping source folder for archive ' \
'(default: disabled)'
) { |v| options[:archive_keep] = v }
opts.on(
'--log-level LEVEL',
'Build script log level (default: info)'
) { |v| options[:log_level] = v }
opts.on(
'--plan FILE',
'Follow given plan file, instead of using given git ref/sha'
) { |v| options[:plan] = v }
opts.on(
'--clean-macho-binary FILE',
'Tool to clean duplicate RPATHs from given Mach-O binary.'
) { |v| options[:clean_macho_binary] = v }
end
end
end
if __FILE__ == $PROGRAM_NAME
use_nix_default = !ENV.fetch('IN_NIX_SHELL', '').empty?
cli_options = {
work_dir: File.expand_path(__dir__),
native_full_aot: false,
relink_eln: true,
native_march: false,
parallel: Etc.nprocessors,
rsvg: true,
dbus: true,
use_nix: use_nix_default,
xwidgets: true,
tree_sitter: true,
fd_setsize: 10_000,
github_src_repo: nil,
github_auth: true,
dist_include: ['COPYING', 'configure_output.txt'],
self_sign: true,
archive: true,
archive_keep: false,
log_level: 'info'
}
parser = OptionParser.new do |opts|
opts.banner = <<~DOC
Usage: ./build-emacs-for-macos [options] <branch/tag/sha>
Branch, tag, and SHA are from the emacs-mirror/emacs/emacs Github repo,
available here: https://github.com/emacs-mirror/emacs
Options:
DOC
opts.on(
'--info',
'Print environment info and detected library paths, then exit'
) { |v| cli_options[:info] = v }
opts.on(
'--preview',
'Print preview details about build and exit.'
) { |v| cli_options[:preview] = v }
opts.on(
'-j',
'--parallel COUNT',
'Compile using COUNT parallel processes ' \
"(detected: #{cli_options[:parallel]})"
) { |v| cli_options[:parallel] = v }
opts.on(
'--git-sha SHA',
'Override detected git SHA of specified ' \
'branch allowing builds of old commits'
) { |v| cli_options[:git_sha] = v }
opts.on(
'--[no-]use-nix',
'Use Nix instead of Homebrew to find dependencies ' \
'(default: enabled if IN_NIX_SHELL is set)'
) { |v| cli_options[:use_nix] = v }
opts.on(
'--[no-]xwidgets',
'Enable/disable XWidgets if supported ' \
'(default: enabled)'
) { |v| cli_options[:xwidgets] = v }
opts.on(
'--[no-]tree-sitter',
'Enable/disable tree-sitter if supported ' \
'(default: enabled)'
) { |v| cli_options[:tree_sitter] = v }
opts.on(
'--[no-]native-comp',
'Enable/disable native-comp ' \
'(default: enabled if supported)'
) { |v| cli_options[:native_comp] = v }
opts.on(
'--optimize',
'Shorthand for --native-march --native-mtune --fomit-frame-pointer ' \
'(default: disabled)'
) do
cli_options[:native_march] = true
cli_options[:native_mtune] = true
cli_options[:fomit_frame_pointer] = true
end
opts.on(
'--[no-]native-march',
'Enable/disable -march=native CFLAG ' \
'(default: disabled)'
) { |v| cli_options[:native_march] = v }
opts.on(
'--[no-]native-mtune',
'Enable/disable -mtune=native CFLAG ' \
'(default: disabled)'
) { |v| cli_options[:native_mtune] = v }
opts.on(
'--[no-]fomit-frame-pointer',
'Enable/disable -fomit-frame-pointer CFLAG ' \
'(default: disabled)'
) { |v| cli_options[:fomit_frame_pointer] = v }
opts.on(
'--[no-]native-full-aot',
'Enable/disable NATIVE_FULL_AOT / Ahead of Time compilation ' \
'(default: disabled)'
) { |v| cli_options[:native_full_aot] = v }
opts.on(
'--[no-]relink-eln-files',
'Enable/disable re-linking shared libraries in bundled *.eln ' \
'files (default: enabled)'
) { |v| cli_options[:relink_eln] = v }
opts.on(
'--[no-]rsvg',
'Enable/disable SVG image support via librsvg ' \
'(default: enabled)'
) { |v| cli_options[:rsvg] = v }
opts.on(
'--[no-]dbus',
'Enable/disable dbus support (default: enabled)'
) { |v| cli_options[:dbus] = v }
opts.on(
'--no-titlebar',
'Apply no-titlebar patch (default: disabled)'
) { cli_options[:no_titlebar] = true }
opts.on('--posix-spawn', 'Apply posix-spawn patch (deprecated)') do
warn '==> WARN: posix-spawn patch is deprecated and has no effect.'
end
opts.on(
'--no-frame-refocus',
'Apply no-frame-refocus patch (default: disabled)'
) { cli_options[:no_frame_refocus] = true }
opts.on('--[no-]poll', 'Apply poll patch (deprecated)') do
warn '==> WARN: poll patch is deprecated and has no effect.'
end
opts.on(
'--[no-]fd-setsize SIZE',
'Set an file descriptor (max open files) limit (default: 10000)'
) { |v| cli_options[:fd_setsize] = v.respond_to?(:to_i) ? v.to_i : 0 }
opts.on(
'--github-src-repo REPO',
'Specify a GitHub repo to download source tarballs from ' \
'(default: emacs-mirror/emacs)'
) { |v| cli_options[:github_src_repo] = v }
opts.on(
'--[no-]github-auth',
'Make authenticated GitHub API requests if GITHUB_TOKEN ' \
'environment variable is set.' \
'(default: enabled)'
) { |v| cli_options[:github_auth] = v }
opts.on(
'--work-dir DIR',
'Specify a working directory where tarballs, sources, and ' \
'builds will be stored and worked with'
) { |v| cli_options[:work_dir] = v }
opts.on(
'-o DIR',
'--output DIR',
'Output directory for finished builds ' \
'(default: <work-dir>/builds)'
) { |v| cli_options[:output] = v }
opts.on('--build-name NAME', 'Override generated build name') do |v|
cli_options[:build_name] = v
end
opts.on(
'--dist-include x,y,z',
'List of extra files to copy from Emacs source into build ' \
'folder/archive (default: COPYING)'
) { |v| cli_options[:dist_include] = v }
opts.on(
'--[no-]self-sign',
'Enable/disable self-signing of Emacs.app (default: enabled)'
) { |v| cli_options[:self_sign] = v }
opts.on(
'--[no-]archive',
'Enable/disable creating *.tbz archive (default: enabled)'
) { |v| cli_options[:archive] = v }
opts.on(
'--[no-]archive-keep-build-dir',
'Enable/disable keeping source folder for archive ' \
'(default: disabled)'
) { |v| cli_options[:archive_keep] = v }
opts.on(
'--log-level LEVEL',
'Build script log level (default: info)'
) { |v| cli_options[:log_level] = v }
opts.on(
'--plan FILE',
'Follow given plan file, instead of using given git ref/sha'
) { |v| cli_options[:plan] = v }
end
begin
parser.parse!
cli_options = CLIOptions.parse(ARGV)
Output.log_level = cli_options[:log_level]
Output.log_level = cli_options.delete(:log_level)
work_dir = cli_options.delete(:work_dir)
build = Build.new(work_dir, ARGV.shift, cli_options)
@@ -2056,6 +2356,17 @@ if __FILE__ == $PROGRAM_NAME
build.print_info
elsif cli_options[:preview]
build.print_preview
elsif cli_options[:clean_macho_binary]
macho_cleaner = MachOCleaner.new(cli_options[:clean_macho_binary])
if macho_cleaner.has_duplicate_rpaths?
build.info 'Removing duplicate RPATHs from ' \
"#{cli_options[:clean_macho_binary]}..."
macho_cleaner.clean!
build.info 'Cleaned duplicate RPATHs successfully!'
else
build.info 'No duplicate RPATHs found.'
end
else
build.build
end

8
flake.lock generated
View File

@@ -20,16 +20,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1731603435,
"narHash": "sha256-CqCX4JG7UiHvkrBTpYC3wcEurvbtTADLbo3Ns2CEoL8=",
"lastModified": 1750646418,
"narHash": "sha256-4UAN+W0Lp4xnUiHYXUXAPX18t+bn6c4Btry2RqM9JHY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8b27c1239e5c421a2bbc2c65d52e4a6fbf2ff296",
"rev": "1f426f65ac4e6bf808923eb6f8b8c2bfba3d18c5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "24.11-beta",
"ref": "nixos-24.11",
"repo": "nixpkgs",
"type": "github"
}

View File

@@ -2,7 +2,7 @@
description = "Development environment flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.11-beta";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
};

View File

@@ -9,10 +9,10 @@ cctools-binutils-darwin-wrapper-1010.6
clang-16.0.6
clang-wrapper-16.0.6
coreutils-9.5
curl-8.11.0
curl-8.12.1
dbus-1.14.10
diffutils-3.10
expat-2.6.4
expat-2.7.1
file-5.45
findutils-4.10.0
fontconfig-2.15.0
@@ -23,7 +23,7 @@ gcc-wrapper-13.3.0
gdk-pixbuf-2.42.12
gettext-0.21.1
giflib-5.2.2
git-2.47.0
git-2.47.2
glib-2.82.1
gnugrep-3.11
gnumake-4.4.1
@@ -38,29 +38,29 @@ krb5-1.21.3
lcms2-2.16
libdeflate-1.22
libgccjit-13.3.0
libiconv-107
libiconv-109
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
libtasn1-4.20.0
libtiff-4.7.0
libwebp-1.4.0
libxml2-2.13.4
libxml2-2.13.8
mailutils-3.17
nettle-3.10
nghttp2-1.64.0
openssl-3.3.2
openssl-3.3.3
patch-2.7.6
pkg-config-wrapper-0.29.2
python3-3.12.7
rsync-3.3.0
ruby-3.3.5
python3-3.12.8
rsync-3.4.1
ruby-3.3.8
sqlite-3.46.1
texinfo-7.1.1
time-1.9
tree-sitter-0.24.3
tree-sitter-0.24.6
which-2.21
xcbuild-0.1.1-unstable-2019-11-20
xz-5.6.3

View File

@@ -0,0 +1,487 @@
From 9b436ccb00ea321fe778ea51cf1ad536aff7210f Mon Sep 17 00:00:00 2001
From: Jon Rubens <jonathanrubens@gmail.com>
Date: Wed, 24 Jan 2024 19:45:55 -0800
Subject: [PATCH 1/3] Enable frame parameter alpha_background for MacOS
---
src/macfont.m | 10 ++++++++--
src/nsfns.m | 42 ++++++++++++++++++++++++++++++++++--------
src/nsterm.m | 42 ++++++++++++++++++++++--------------------
3 files changed, 64 insertions(+), 30 deletions(-)
diff --git a/src/macfont.m b/src/macfont.m
index 8aba440d196e..56c1eb57024e 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2953,9 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
else
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
- }
+ CGContextSetAlpha(context, 1);
+ }
else
- CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
+ {
+ CGContextSetAlpha(context, f->alpha_background);
+ CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
+ }
+ CGContextClearRect(context, background_rect);
CGContextFillRects (context, &background_rect, 1);
}
@@ -2964,6 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
CGAffineTransform atfm;
CGContextScaleCTM (context, 1, -1);
+ CGContextSetAlpha(context, 1);
if (s->hl == DRAW_CURSOR)
{
if (face && (NS_FACE_BACKGROUND (face)
diff --git a/src/nsfns.m b/src/nsfns.m
index b0281aac2572..3e19cce89de9 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -301,7 +301,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
struct face *face;
NSColor *col;
NSView *view = FRAME_NS_VIEW (f);
- EmacsCGFloat alpha;
+ EmacsCGFloat alpha = f->alpha_background;
block_input ();
if (ns_lisp_to_color (arg, &col))
@@ -316,11 +316,10 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
f->output_data.ns->background_color = col;
FRAME_BACKGROUND_PIXEL (f) = [col unsignedLong];
- alpha = [col alphaComponent];
if (view != nil)
{
- [[view window] setBackgroundColor: col];
+ [[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]];
if (alpha != (EmacsCGFloat) 1.0)
[[view window] setOpaque: NO];
@@ -330,10 +329,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
face = FRAME_DEFAULT_FACE (f);
if (face)
{
- col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)];
- face->background = [[col colorWithAlphaComponent: alpha]
- unsignedLong];
-
+ face->background = [col unsignedLong];
update_face_from_frame_parameter (f, Qbackground_color, arg);
}
@@ -346,6 +342,36 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
unblock_input ();
}
+static void
+ns_set_alpha_background (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
+{
+ NSView *view = FRAME_NS_VIEW (f);
+ double alpha = 1.0;
+
+ if (NILP (arg))
+ alpha = 1.0;
+ else if (FLOATP (arg))
+ {
+ alpha = XFLOAT_DATA (arg);
+ if (! (0 <= alpha && alpha <= 1.0))
+ args_out_of_range (make_float (0.0), make_float (1.0));
+ }
+ else if (FIXNUMP (arg))
+ {
+ EMACS_INT ialpha = XFIXNUM (arg);
+ if (! (0 <= ialpha && ialpha <= 100))
+ args_out_of_range (make_fixnum (0), make_fixnum (100));
+ alpha = ialpha / 100.0;
+ }
+ else
+ wrong_type_argument (Qnumberp, arg);
+
+ f->alpha_background = alpha;
+ [[view window] setBackgroundColor: [f->output_data.ns->background_color
+ colorWithAlphaComponent: alpha]];
+ recompute_basic_faces (f);
+ SET_FRAME_GARBAGED (f);
+}
static void
ns_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
@@ -1065,7 +1091,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
ns_set_z_group,
0, /* x_set_override_redirect */
gui_set_no_special_glyphs,
- gui_set_alpha_background,
+ ns_set_alpha_background,
NULL,
#ifdef NS_IMPL_COCOA
ns_set_appearance,
diff --git a/src/nsterm.m b/src/nsterm.m
index 518b38658d17..bda3a12172f5 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2618,8 +2618,9 @@ Hide the window (X11 semantics)
block_input ();
ns_focus (f, &r, 1);
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
- (FACE_FROM_ID (f, DEFAULT_FACE_ID))] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))]
+ colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (r);
ns_unfocus (f);
@@ -2647,7 +2648,7 @@ Hide the window (X11 semantics)
r = NSIntersectionRect (r, [view frame]);
ns_focus (f, &r, 1);
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (r);
@@ -2751,7 +2752,7 @@ Hide the window (X11 semantics)
return;
ns_focus (f, NULL, 1);
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (NSMakeRect (0, margin, width, border));
NSRectFill (NSMakeRect (0, 0, border, height));
NSRectFill (NSMakeRect (0, margin, width, border));
@@ -2802,7 +2803,7 @@ Hide the window (X11 semantics)
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
ns_focus (f, &r, 1);
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (NSMakeRect (0, y, width, height));
NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width,
y, width, height));
@@ -2966,8 +2967,7 @@ Hide the window (X11 semantics)
if (! NSIsEmptyRect (clearRect))
{
NSTRACE_RECT ("clearRect", clearRect);
-
- [[NSColor colorWithUnsignedLong:face->background] set];
+ [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (clearRect);
}
@@ -2998,7 +2998,7 @@ Hide the window (X11 semantics)
else
bm_color = f->output_data.ns->cursor_color;
- [bm_color set];
+ [[bm_color colorWithAlphaComponent:f->alpha_background] set];
[bmp fill];
[bmp release];
@@ -3719,7 +3719,7 @@ Function modeled after x_draw_glyph_string_box ().
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
{
ns_draw_box (r, abs (hthickness), abs (vthickness),
- [NSColor colorWithUnsignedLong:face->box_color],
+ [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
left_p, right_p);
}
else
@@ -3757,8 +3757,10 @@ Function modeled after x_draw_glyph_string_box ().
{
if (s->hl != DRAW_CURSOR)
[(NS_FACE_BACKGROUND (face) != 0
- ? [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ ? [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: s->f->alpha_background]
: FRAME_BACKGROUND_COLOR (s->f)) set];
+
else if (face && (NS_FACE_BACKGROUND (face)
== [(NSColor *) FRAME_CURSOR_COLOR (s->f)
unsignedLong]))
@@ -3902,7 +3904,7 @@ Function modeled after x_draw_glyph_string_box ().
otherwise, since we composite the image under NS (instead of mucking
with its background color), we must clear just the image area. */
- [[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
@@ -3972,7 +3974,7 @@ Function modeled after x_draw_glyph_string_box ().
if (s->hl == DRAW_CURSOR)
{
[FRAME_CURSOR_COLOR (s->f) set];
- tdCol = [NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)];
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
}
else
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
@@ -4066,10 +4068,10 @@ Function modeled after x_draw_glyph_string_box ().
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
prepare_face_for_display (s->f, face);
- [[NSColor colorWithUnsignedLong: face->background] set];
+ [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
}
else
- [[NSColor colorWithUnsignedLong: s->face->background] set];
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
NSRectFill (NSMakeRect (x, y, w, h));
}
}
@@ -4095,7 +4097,7 @@ Function modeled after x_draw_glyph_string_box ().
if (s->hl == DRAW_CURSOR)
[FRAME_CURSOR_COLOR (s->f) set];
else
- [[NSColor colorWithUnsignedLong: s->face->background] set];
+ [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
}
@@ -8436,8 +8438,8 @@ - (void)toggleFullScreen: (id)sender
}
[w setContentView:[fw contentView]];
- [w setBackgroundColor: col];
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
+ [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
[w setOpaque: NO];
f->border_width = [w borderWidth];
@@ -9172,9 +9174,9 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
f->border_width = [self borderWidth];
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
- (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
- [self setBackgroundColor:col];
- if ([col alphaComponent] != (EmacsCGFloat) 1.0)
+ (FACE_FROM_ID (f, DEFAULT_FACE_ID))];
+ [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
+ if (f->alpha_background != (EmacsCGFloat) 1.0)
[self setOpaque:NO];
/* toolbar support */
From 58cf6e6da20eefca161c1ab1fd0d6ad67d1ba710 Mon Sep 17 00:00:00 2001
From: Jon Rubens <jonathanrubens@gmail.com>
Date: Fri, 26 Jan 2024 09:35:15 -0800
Subject: [PATCH 2/3] Fix code formatting
---
src/macfont.m | 8 ++++----
src/nsterm.m | 30 ++++++++++++++++++++----------
2 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/src/macfont.m b/src/macfont.m
index 56c1eb57024e..8fb835c7ff01 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2953,14 +2953,14 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
else
CG_SET_FILL_COLOR_WITH_FRAME_CURSOR (context, f);
- CGContextSetAlpha(context, 1);
+ CGContextSetAlpha (context, 1);
}
else
{
- CGContextSetAlpha(context, f->alpha_background);
+ CGContextSetAlpha (context, f->alpha_background);
CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
}
- CGContextClearRect(context, background_rect);
+ CGContextClearRect (context, background_rect);
CGContextFillRects (context, &background_rect, 1);
}
@@ -2969,7 +2969,7 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
CGAffineTransform atfm;
CGContextScaleCTM (context, 1, -1);
- CGContextSetAlpha(context, 1);
+ CGContextSetAlpha (context, 1);
if (s->hl == DRAW_CURSOR)
{
if (face && (NS_FACE_BACKGROUND (face)
diff --git a/src/nsterm.m b/src/nsterm.m
index bda3a12172f5..9ab3ff8f783f 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2803,7 +2803,8 @@ Hide the window (X11 semantics)
NSRect r = NSMakeRect (0, y, FRAME_PIXEL_WIDTH (f), height);
ns_focus (f, &r, 1);
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (NSMakeRect (0, y, width, height));
NSRectFill (NSMakeRect (FRAME_PIXEL_WIDTH (f) - width,
y, width, height));
@@ -2967,7 +2968,8 @@ Hide the window (X11 semantics)
if (! NSIsEmptyRect (clearRect))
{
NSTRACE_RECT ("clearRect", clearRect);
- [[[NSColor colorWithUnsignedLong:face->background] colorWithAlphaComponent: f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong:face->background]
+ colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (clearRect);
}
@@ -3719,7 +3721,8 @@ Function modeled after x_draw_glyph_string_box ().
if (s->face->box == FACE_SIMPLE_BOX && s->face->box_color)
{
ns_draw_box (r, abs (hthickness), abs (vthickness),
- [[NSColor colorWithUnsignedLong:face->box_color] colorWithAlphaComponent: s->f->alpha_background],
+ [[NSColor colorWithUnsignedLong:face->box_color]
+ colorWithAlphaComponent: s->f->alpha_background],
left_p, right_p);
}
else
@@ -3904,7 +3907,8 @@ Function modeled after x_draw_glyph_string_box ().
otherwise, since we composite the image under NS (instead of mucking
with its background color), we must clear just the image area. */
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: s->f->alpha_background] set];
if (bg_height > s->slice.height || s->img->hmargin || s->img->vmargin
|| s->img->mask || s->img->pixmap == 0 || s->width != s->background_width)
@@ -3974,7 +3978,8 @@ Function modeled after x_draw_glyph_string_box ().
if (s->hl == DRAW_CURSOR)
{
[FRAME_CURSOR_COLOR (s->f) set];
- tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: s->f->alpha_background];
+ tdCol = [[NSColor colorWithUnsignedLong: NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: s->f->alpha_background];
}
else
tdCol = [NSColor colorWithUnsignedLong: NS_FACE_FOREGROUND (face)];
@@ -4068,10 +4073,12 @@ Function modeled after x_draw_glyph_string_box ().
face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
prepare_face_for_display (s->f, face);
- [[[NSColor colorWithUnsignedLong: face->background] colorWithAlphaComponent: s->f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong: face->background]
+ colorWithAlphaComponent: s->f->alpha_background] set];
}
else
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong: s->face->background]
+ colorWithAlphaComponent: s->f->alpha_background] set];
NSRectFill (NSMakeRect (x, y, w, h));
}
}
@@ -4097,7 +4104,8 @@ Function modeled after x_draw_glyph_string_box ().
if (s->hl == DRAW_CURSOR)
[FRAME_CURSOR_COLOR (s->f) set];
else
- [[[NSColor colorWithUnsignedLong: s->face->background] colorWithAlphaComponent: s->f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong: s->face->background]
+ colorWithAlphaComponent: s->f->alpha_background] set];
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
}
@@ -8438,7 +8446,8 @@ - (void)toggleFullScreen: (id)sender
}
[w setContentView:[fw contentView]];
- [w setBackgroundColor: [col colorWithAlphaComponent: f->alpha_background]];
+ [w setBackgroundColor: [col colorWithAlphaComponent:
+ f->alpha_background]];
if (f->alpha_background != (EmacsCGFloat) 1.0)
[w setOpaque: NO];
@@ -9175,7 +9184,8 @@ - (instancetype) initWithEmacsFrame: (struct frame *) f
col = [NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND
(FACE_FROM_ID (f, DEFAULT_FACE_ID))];
- [self setBackgroundColor:[col colorWithAlphaComponent:f->alpha_background]];
+ [self setBackgroundColor:
+ [col colorWithAlphaComponent:f->alpha_background]];
if (f->alpha_background != (EmacsCGFloat) 1.0)
[self setOpaque:NO];
From 896596aac2932ab98dbeb68f48a963275fdb76c5 Mon Sep 17 00:00:00 2001
From: Jon Rubens <jonathanrubens@gmail.com>
Date: Wed, 31 Jan 2024 13:30:13 -0800
Subject: [PATCH 3/3] More code formatting
---
src/nsfns.m | 11 ++++++-----
src/nsterm.m | 8 +++++---
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/nsfns.m b/src/nsfns.m
index 3e19cce89de9..67d8449c70dd 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -321,11 +321,6 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
{
[[view window] setBackgroundColor: [col colorWithAlphaComponent: alpha]];
- if (alpha != (EmacsCGFloat) 1.0)
- [[view window] setOpaque: NO];
- else
- [[view window] setOpaque: YES];
-
face = FRAME_DEFAULT_FACE (f);
if (face)
{
@@ -369,6 +364,12 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side.
f->alpha_background = alpha;
[[view window] setBackgroundColor: [f->output_data.ns->background_color
colorWithAlphaComponent: alpha]];
+
+ if (alpha != (EmacsCGFloat) 1.0)
+ [[view window] setOpaque: NO];
+ else
+ [[view window] setOpaque: YES];
+
recompute_basic_faces (f);
SET_FRAME_GARBAGED (f);
}
diff --git a/src/nsterm.m b/src/nsterm.m
index 9ab3ff8f783f..6feef6236449 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2648,9 +2648,11 @@ Hide the window (X11 semantics)
r = NSIntersectionRect (r, [view frame]);
ns_focus (f, &r, 1);
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (r);
+ [[view window] invalidateShadow];
ns_unfocus (f);
return;
@@ -2752,7 +2754,8 @@ Hide the window (X11 semantics)
return;
ns_focus (f, NULL, 1);
- [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)] colorWithAlphaComponent: f->alpha_background] set];
+ [[[NSColor colorWithUnsignedLong:NS_FACE_BACKGROUND (face)]
+ colorWithAlphaComponent: f->alpha_background] set];
NSRectFill (NSMakeRect (0, margin, width, border));
NSRectFill (NSMakeRect (0, 0, border, height));
NSRectFill (NSMakeRect (0, margin, width, border));
@@ -4106,7 +4109,6 @@ Function modeled after x_draw_glyph_string_box ().
else
[[[NSColor colorWithUnsignedLong: s->face->background]
colorWithAlphaComponent: s->f->alpha_background] set];
-
NSRectFill (NSMakeRect (x, s->y, background_width, s->height));
}
}

View File

@@ -287,7 +287,7 @@ func (s *Updater) createRepoFile(
s.logger.Info(
"new commit created",
"commit", contResp.GetSHA(), "message", contResp.GetMessage(),
"url", contResp.Commit.GetHTMLURL(),
"url", contResp.GetHTMLURL(),
)
return nil
@@ -354,7 +354,7 @@ func (s *Updater) updateRepoFile(
s.logger.Info(
"new commit created",
"commit", contResp.GetSHA(), "message", contResp.GetMessage(),
"url", contResp.Commit.GetHTMLURL(),
"url", contResp.GetHTMLURL(),
)
return true, nil

View File

@@ -38,6 +38,10 @@ func planCmd() *cli2.Command {
Name: "sha",
Usage: "override commit SHA of specified git branch/tag",
},
&cli2.IntFlag{
Name: "build-variant",
Usage: "build variant to add to the end of the version string",
},
&cli2.StringFlag{
Name: "format",
Aliases: []string{"f"},
@@ -90,6 +94,7 @@ func planAction(c *cli2.Context, opts *Options) error {
EmacsRepo: c.String("emacs-repo"),
Ref: ref,
SHAOverride: c.String("sha"),
BuildVariant: c.Int("build-variant"),
OutputDir: c.String("output-dir"),
TestBuild: c.String("test-build"),
TestBuildType: plan.Prerelease,

View File

@@ -65,10 +65,7 @@ func (s *OSInfo) distinctVersion(version string) string {
return parts[0]
}
max := len(parts)
if max > 2 {
max = 2
}
end := min(len(parts), 2)
return strings.Join(parts[0:max], ".")
return strings.Join(parts[0:end], ".")
}

View File

@@ -35,6 +35,7 @@ type Options struct {
EmacsRepo string
Ref string
SHAOverride string
BuildVariant int
OutputDir string
TestBuild string
TestBuildType TestBuildType
@@ -95,6 +96,12 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) { //nolint:funlen
releaseName = "Emacs." + version
}
if opts.BuildVariant != 0 {
variant := strconv.Itoa(opts.BuildVariant)
absoluteVersion += "-" + variant
releaseName += "-" + variant
}
// Attempt to get the macOS SDK version from the environment, if it's not
// available, use the version from the system.
targetMacOSVersion := osInfo.DistinctSDKVersion()