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/1.0.0/meson-1.0.0.tar.gz"
sha256 "aa50a4ba4557c25e7d48446abfde857957dcdf58385fffbe670ba0e8efacce05"
license "Apache-2.0"
head "https://github.com/mesonbuild/meson.git", branch: "master"
bottle do
sha256 cellar: :any_skip_relocation, all: "17d37236c5897dce15263e14c94dbb779525a19db7ba86d2a4ca7d80147ed8e5"
end
depends_on "ninja"
depends_on "python@3.11"
def install
python = "python3.11"
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
utils/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