Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

macvim: Fix compilation on Mac OS X 10.9 #20473

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 61 additions & 1 deletion Library/Formula/macvim.rb
Expand Up @@ -22,6 +22,14 @@ class Macvim < Formula
env :std if MacOS.version <= :snow_leopard
# Help us! We'd like to use superenv in these environments too

# Mavericks Patches:
# * Fix Ruby.framework detection on OS X 10.9
# * Allow building against specific Ruby.framework version matcing ruby-command
# * Add missing version macros include for 10.9
def patches
DATA unless build.head?
end

def install
# Set ARCHFLAGS so the Python app (with C extension) that is
# used to create the custom icons will not try to compile in
Expand All @@ -31,14 +39,17 @@ def install
# If building for 10.7 or up, make sure that CC is set to "clang".
ENV.clang if MacOS.version >= :lion

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need changed?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the brew binary still uses ruby 1.8 which RUBY_PATH is derived from, so configure would detect ruby version 1.8 while compiling against the Ruby 2.0 framework, which would fail. This is because it uses -framework Rubyto compile, which will choose the Current version, which will be 1.8 on older OS X and 2.0 on 10.9. So using the Current ruby binary just matches the version detection to the Current framework.

Another approach would be to adjust configure to compile against the Ruby framework matching the ruby-command but I don't see the value of using an outdated framework.

# macvim HEAD only works with the current Ruby.framework because it builds with -framework Ruby
system_ruby = build.head? ? "/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby" : RUBY_PATH

args = %W[
--with-features=huge
--enable-multibyte
--with-macarchs=#{MacOS.preferred_arch}
--enable-perlinterp
--enable-rubyinterp
--enable-tclinterp
--with-ruby-command=#{RUBY_PATH}
--with-ruby-command=#{system_ruby}
--with-tlib=ncurses
--with-compiledby=Homebrew
--with-local-dir=#{HOMEBREW_PREFIX}
Expand Down Expand Up @@ -116,3 +127,52 @@ def caveats; <<-EOS.undent
EOS
end
end

__END__
diff --git a/src/auto/configure b/src/auto/configure
index 4fd7b82..08af7f3 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -7206,8 +7208,9 @@ echo "${ECHO_T}$rubyhdrdir" >&6; }
librubyarg="$librubyarg"
RUBY_LIBS="$RUBY_LIBS -L$rubylibdir"
elif test -d "/System/Library/Frameworks/Ruby.framework"; then
- RUBY_LIBS="-framework Ruby"
- RUBY_CFLAGS=
+ ruby_fw_ver=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG['ruby_version'][0,3]"`
+ RUBY_LIBS="/System/Library/Frameworks/Ruby.framework/Versions/$ruby_fw_ver/Ruby"
+ RUBY_CFLAGS="-I/System/Library/Frameworks/Ruby.framework/Versions/$ruby_fw_ver/Headers -DRUBY_VERSION=$rubyversion"
librubyarg=
fi

diff --git a/src/if_ruby.c b/src/if_ruby.c
index 4436e06..44fd5ee 100644
--- a/src/if_ruby.c
+++ b/src/if_ruby.c
@@ -96,11 +96,7 @@
# define rb_num2int rb_num2int_stub
#endif

-#ifdef FEAT_GUI_MACVIM
-# include <Ruby/ruby.h>
-#else
-# include <ruby.h>
-#endif
+#include <ruby.h>
#ifdef RUBY19_OR_LATER
# include <ruby/encoding.h>
#endif
diff --git a/src/os_mac.h b/src/os_mac.h
index 78b79c2..54009ab 100644
--- a/src/os_mac.h
+++ b/src/os_mac.h
@@ -16,6 +16,9 @@
# define OPAQUE_TOOLBOX_STRUCTS 0
#endif

+/* Include MAC_OS_X_VERSION_* macros */
+#include <AvailabilityMacros.h>
+
/*
* Macintosh machine-dependent things.
*