homebrew-core/Formula/macvim.rb

86 lines
3.3 KiB
Ruby

# Reference: https://github.com/macvim-dev/macvim/wiki/building
class Macvim < Formula
desc "GUI for vim, made for macOS"
homepage "https://github.com/macvim-dev/macvim"
url "https://github.com/macvim-dev/macvim/archive/snapshot-172.tar.gz"
version "8.2-172"
sha256 "b5e16d721444d8cb6231df739b1b74dec8f3cb0bde1fe8327dd86e25fc322331"
license "Vim"
revision 1
head "https://github.com/macvim-dev/macvim.git", branch: "master"
bottle do
sha256 arm64_monterey: "0e39822873ca26d8914c14ef4e1b7f19252cb848b0903620e2075d0c243174f2"
sha256 arm64_big_sur: "1f3a828044e23eacd6914d42dd6d6b361d79f79eb144b5e63e262d920785dcfc"
sha256 monterey: "6f7605e4db8b76bbed4bdec217fa2e4243281db34839936b9a32f5bd0aa7c635"
sha256 big_sur: "99a2d020534238af1975e48408860e83831aaff27a7f7045e92ca9b38b520ebf"
sha256 catalina: "6d12f8581f8336dc214b9b44627861f072c22a1400bf8e100ded02cea26b2957"
end
depends_on xcode: :build
depends_on "cscope"
depends_on "gettext"
depends_on "lua"
depends_on :macos
depends_on "python@3.10"
depends_on "ruby"
conflicts_with "vim",
because: "vim and macvim both install vi* binaries"
def install
# Avoid issues finding Ruby headers
ENV.delete("SDKROOT")
# MacVim doesn't have or require any Python package, so unset PYTHONPATH
ENV.delete("PYTHONPATH")
# make sure that CC is set to "clang"
ENV.clang
system "./configure", "--with-features=huge",
"--enable-multibyte",
"--enable-perlinterp",
"--enable-rubyinterp",
"--enable-tclinterp",
"--enable-terminal",
"--with-tlib=ncurses",
"--with-compiledby=Homebrew",
"--with-local-dir=#{HOMEBREW_PREFIX}",
"--enable-cscope",
"--enable-luainterp",
"--with-lua-prefix=#{Formula["lua"].opt_prefix}",
"--enable-luainterp",
"--enable-python3interp",
"--disable-sparkle",
"--with-macarchs=#{Hardware::CPU.arch}"
system "make"
prefix.install "src/MacVim/build/Release/MacVim.app"
# Remove autoupdating universal binaries
(prefix/"MacVim.app/Contents/Frameworks/Sparkle.framework").rmtree
bin.install_symlink prefix/"MacVim.app/Contents/bin/mvim"
# Create MacVim vimdiff, view, ex equivalents
executables = %w[mvimdiff mview mvimex gvim gvimdiff gview gvimex]
executables += %w[vi vim vimdiff view vimex]
executables.each { |e| bin.install_symlink "mvim" => e }
end
test do
output = shell_output("#{bin}/mvim --version")
assert_match "+ruby", output
assert_match "+gettext", output
# Simple test to check if MacVim was linked to Homebrew's Python 3
py3_exec_prefix = shell_output(Formula["python@3.10"].opt_bin/"python3-config --exec-prefix")
assert_match py3_exec_prefix.chomp, output
(testpath/"commands.vim").write <<~EOS
:python3 import vim; vim.current.buffer[0] = 'hello python3'
:wq
EOS
system bin/"mvim", "-v", "-T", "dumb", "-s", "commands.vim", "test.txt"
assert_equal "hello python3", (testpath/"test.txt").read.chomp
end
end