Skip to content

Commit

Permalink
add native-comp feature
Browse files Browse the repository at this point in the history
Co-authored-by: Davide Restivo <daviderestivo@users.noreply.github.com>
  • Loading branch information
d12frosted and daviderestivo committed Dec 22, 2020
1 parent 53c7edf commit d8247e4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/emacs-28.yml
Expand Up @@ -29,6 +29,7 @@ jobs:
- ""
- "--with-xwidgets"
- "--with-no-titlebar"
- "--with-native-comp"

env:
HOMEBREW_GITHUB_REF: ${{ github.head_ref || github.ref }}
Expand All @@ -42,6 +43,10 @@ jobs:
if: contains(matrix.os, 'macos-11.0')
run: sudo xcode-select -s "/Applications/Xcode_12.2.app"

- name: Update brew
if: contains(matrix.build_opts, '--with-native-comp')
run: brew update

- name: Build emacs-plus@28 ${{ matrix.build_opts }}
run: brew install emacs-plus@28.rb ${{ matrix.build_opts }}
working-directory: Formula
Expand Down
55 changes: 54 additions & 1 deletion Formula/emacs-plus@28.rb
Expand Up @@ -2,7 +2,6 @@
require_relative "../Library/UrlResolver"

class EmacsPlusAT28 < EmacsBase
url "https://github.com/emacs-mirror/emacs.git"
version "28.0.50"

#
Expand All @@ -19,6 +18,7 @@ class EmacsPlusAT28 < EmacsBase
option "with-debug", "Build with debug symbols and debugger friendly optimizations"
option "with-xwidgets", "Experimental: build with xwidgets support"
option "with-no-frame-refocus", "Disables frame re-focus (ie. closing one frame does not refocus another one)"
option "with-native-comp", "Build from feature/native-comp branch"

#
# Dependencies
Expand All @@ -42,6 +42,13 @@ class EmacsPlusAT28 < EmacsBase
depends_on "fontconfig" => :recommended
end

if build.with? "native-comp"
depends_on "libgccjit" => :recommended
depends_on "gcc" => :build
depends_on "gmp" => :build
depends_on "libjpeg" => :build
end

#
# Incompatible options
#
Expand All @@ -52,6 +59,16 @@ class EmacsPlusAT28 < EmacsBase
end
end

#
# URL
#

if build.with? "native-comp"
url "https://github.com/emacs-mirror/emacs.git", :branch => "feature/native-comp"
else
url "https://github.com/emacs-mirror/emacs.git"
end

#
# Icons
#
Expand Down Expand Up @@ -98,6 +115,25 @@ def install
args << "--with-xml2"
args << "--with-gnutls"

args << "--with-nativecomp" if build.with? "native-comp"

if build.with? "native-comp"
gcc_ver = Formula["gcc"].any_installed_version
gcc_ver_major = gcc_ver.major
gcc_lib="#{HOMEBREW_PREFIX}/lib/gcc/#{gcc_ver_major}"

ENV.append "CFLAGS", "-I#{Formula["gcc"].include}"
ENV.append "CFLAGS", "-I#{Formula["libgccjit"].include}"
ENV.append "CFLAGS", "-I#{Formula["gmp"].include}"
ENV.append "CFLAGS", "-I#{Formula["libjpeg"].include}"

ENV.append "LDFLAGS", "-L#{gcc_lib}"
ENV.append "LDFLAGS", "-I#{Formula["gcc"].include}"
ENV.append "LDFLAGS", "-I#{Formula["libgccjit"].include}"
ENV.append "LDFLAGS", "-I#{Formula["gmp"].include}"
ENV.append "LDFLAGS", "-I#{Formula["libjpeg"].include}"
end

ENV.append "CFLAGS", "-g -Og" if build.with? "debug"

args <<
Expand Down Expand Up @@ -152,6 +188,22 @@ def install
system "make"
system "make", "install"

if build.with? "native-comp"
contents_dir = buildpath/"nextstep/Emacs.app/Contents"
contents_dir.install "native-lisp"

# Change .eln files dylib ID to avoid that after the post-install phase
# all of the *.eln files end up with the same ID. See:
# https://github.com/Homebrew/brew/issues/9526 and
# https://github.com/Homebrew/brew/pull/10075
Dir.glob(contents_dir/"native-lisp/*/*.eln").each do |f|
fo = MachO::MachOFile.new(f)
ohai "Change dylib_id of ELN files before post_install phase"
fo.dylib_id = "#{contents_dir}/" + f
fo.write!
end
end

icons_dir = buildpath/"nextstep/Emacs.app/Contents/Resources"
ICONS_CONFIG.each_key do |icon|
next if build.without? "#{icon}-icon"
Expand All @@ -162,6 +214,7 @@ def install
end
end

# (prefix/"share/emacs/#{version}").install "lisp"
prefix.install "nextstep/Emacs.app"

# Replace the symlink with one that avoids starting Cocoa.
Expand Down

0 comments on commit d8247e4

Please sign in to comment.