homebrew-core/Formula/meson.rb

61 lines
2.0 KiB
Ruby

class Meson < Formula
desc "Fast and user friendly build system"
homepage "https://mesonbuild.com/"
url "https://github.com/mesonbuild/meson/releases/download/0.63.3/meson-0.63.3.tar.gz"
sha256 "519c0932e1a8b208741f0fdce90aa5c0b528dd297cf337009bf63539846ac056"
license "Apache-2.0"
head "https://github.com/mesonbuild/meson.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "03addafae9868a5198f8e74508d7649e51aafadd107434acc7f893db9edf1971"
end
depends_on "ninja"
depends_on "python@3.10"
def install
python = "python3.10"
system python, *Language::Python.setup_install_args(prefix, python), "--install-data=#{prefix}"
bash_completion.install "data/shell-completions/bash/meson"
zsh_completion.install "data/shell-completions/zsh/_meson"
vim_plugin_dir = buildpath/"data/syntax-highlighting/vim"
(share/"vim/vimfiles").install %w[ftdetect ftplugin indent syntax].map { |dir| vim_plugin_dir/dir }
# Make the bottles uniform. This also ensures meson checks `HOMEBREW_PREFIX`
# for fulfilling dependencies rather than just `/usr/local`.
mesonbuild = prefix/Language::Python.site_packages(python)/"mesonbuild"
inreplace_files = %w[
coredata.py
dependencies/boost.py
dependencies/cuda.py
dependencies/qt.py
mesonlib/universal.py
modules/python.py
].map { |f| mesonbuild/f }
inreplace_files << (bash_completion/"meson")
# Passing `build.stable?` ensures a failed `inreplace` won't fail HEAD installs.
inreplace inreplace_files, "/usr/local", HOMEBREW_PREFIX, build.stable?
end
test do
(testpath/"helloworld.c").write <<~EOS
main() {
puts("hi");
return 0;
}
EOS
(testpath/"meson.build").write <<~EOS
project('hello', 'c')
executable('hello', 'helloworld.c')
EOS
system bin/"meson", "setup", "build"
assert_predicate testpath/"build/build.ninja", :exist?
system "meson", "compile", "-C", "build", "--verbose"
assert_equal "hi", shell_output("build/hello").chomp
end
end