homebrew-core/Formula/macvim.rb

85 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"
head "https://github.com/macvim-dev/macvim.git", branch: "master"
bottle do
sha256 arm64_monterey: "583d61e85112266e0a76a0f28fc000add12a780a128050537bc2431b90857d88"
sha256 arm64_big_sur: "5353adb5cbd7cf25926390582328d748fe07e848eee0a999892c11e918721588"
sha256 monterey: "82b452d795bab0b1771eab28210e4a342b723724d3a90ed54f411e948cf26e37"
sha256 big_sur: "d901772860a5fb47aa384027e664a2ce6efcd049d66a0443545054fc17cc0c68"
sha256 catalina: "d884f16d3c245adde4cb559f40a98db6fbb2ade43b8fb9c11698fb6145b086db"
end
depends_on xcode: :build
depends_on "cscope"
depends_on "gettext"
depends_on "lua"
depends_on :macos
depends_on "python@3.9"
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.9"].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