homebrew-core/Formula/macvim.rb

78 lines
2.9 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-162.tar.gz"
version "8.2-162"
sha256 "e4d47e4ce441b291bc4fbee613e54f75fe065b77ea7fdbee1c85ae2c24d704b1"
head "https://github.com/macvim-dev/macvim.git"
bottle do
cellar :any
sha256 "7bb6dd7e6d3e28d167e497e4993d7bc1c44c654069bef1c0c51e2d4bd9b17565" => :catalina
sha256 "d62e3967c82b0b681be1209ca3bf4e38b9aeb2e72b80b0e6a3b29ddc66658061" => :mojave
sha256 "f4876c40c8276b6a9cd3ca58d6b9ddc87ed72a7a04d83a985908fe3dc1e3f005" => :high_sierra
end
depends_on :xcode => :build
depends_on "cscope"
depends_on "lua"
depends_on "python"
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",
"--with-macarchs=#{MacOS.preferred_arch}",
"--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"
system "make"
prefix.install "src/MacVim/build/Release/MacVim.app"
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
# Simple test to check if MacVim was linked to Homebrew's Python 3
py3_exec_prefix = Utils.popen_read("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