Skip to content

Commit

Permalink
feat(patches/alpha-background): add experimental alpha-background patch
Browse files Browse the repository at this point in the history
Resolves #111
  • Loading branch information
jimeh committed Dec 7, 2024
1 parent d396165 commit e3d57f9
Show file tree
Hide file tree
Showing 3 changed files with 533 additions and 21 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -142,10 +141,12 @@ 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)
Expand Down
58 changes: 41 additions & 17 deletions build-emacs-for-macos
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,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?
Expand Down Expand Up @@ -1052,7 +1052,7 @@ class Build
end
end

def patches(opts = {})
def build_patches
p = []

# Enabled by default patches.
Expand Down Expand Up @@ -1129,14 +1129,30 @@ 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/' \
"patches/emacs-#{effective_version}/xwidgets_webkit_in_cocoa.patch"
}
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 = {}
Expand Down Expand Up @@ -1940,12 +1956,6 @@ class CLIOptions
'(default: enabled if IN_NIX_SHELL is set)'
) { |v| options[:use_nix] = v }

opts.on(
'--[no-]xwidgets',
'Enable/disable XWidgets if supported ' \
'(default: enabled)'
) { |v| options[:xwidgets] = v }

opts.on(
'--[no-]tree-sitter',
'Enable/disable tree-sitter if supported ' \
Expand Down Expand Up @@ -2010,23 +2020,37 @@ class CLIOptions
) { |v| options[:dbus] = v }

opts.on(
'--no-titlebar',
'Apply no-titlebar patch (default: disabled)'
) { 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
'--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 (default: disabled)'
'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 ' \
Expand Down
Loading

0 comments on commit e3d57f9

Please sign in to comment.