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.2/meson-0.63.2.tar.gz"
sha256 "16222f17ef76be0542c91c07994f9676ae879f46fc21c0c786a21ef2cb518bbf"
license "Apache-2.0"
head "https://github.com/mesonbuild/meson.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "d6aa86323d9f5949dc4c8e544137da3937f55cbdee47fea39a826ee48fa16437"
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