72 lines
2.2 KiB
Ruby
72 lines
2.2 KiB
Ruby
class Lit < Formula
|
|
include Language::Python::Virtualenv
|
|
|
|
desc "Portable tool for LLVM- and Clang-style test suites"
|
|
homepage "https://llvm.org"
|
|
url "https://files.pythonhosted.org/packages/62/c8/0fbfd36d69fb395c52c0d3875a00e9a201e674f516a040f35b4b0ca738c9/lit-15.0.1.tar.gz"
|
|
sha256 "84ae8245d4f4dcb4562d7b95b6fecd53a7b3562af1e348949ce8794969a3a9b6"
|
|
license "Apache-2.0" => { with: "LLVM-exception" }
|
|
|
|
bottle do
|
|
sha256 cellar: :any_skip_relocation, all: "1ff34f0764d9ebc6c86680ab96721ec61e94559b257228316ae56c2721517385"
|
|
end
|
|
|
|
depends_on "llvm" => :test
|
|
depends_on "python@3.10"
|
|
|
|
def python3
|
|
"python3.10"
|
|
end
|
|
|
|
def install
|
|
system python3, *Language::Python.setup_install_args(prefix, python3)
|
|
|
|
# Install symlinks so that `import lit` works with multiple versions of Python
|
|
python_versions = Formula.names
|
|
.select { |name| name.start_with? "python@" }
|
|
.map { |py| py.delete_prefix("python@") }
|
|
.reject { |xy| xy == Language::Python.major_minor_version(python3) }
|
|
site_packages = Language::Python.site_packages(python3).delete_prefix("lib/")
|
|
python_versions.each do |xy|
|
|
(lib/"python#{xy}/site-packages").install_symlink (lib/site_packages).children
|
|
end
|
|
end
|
|
|
|
test do
|
|
ENV.prepend_path "PATH", Formula["llvm"].opt_bin
|
|
|
|
(testpath/"example.c").write <<~EOS
|
|
// RUN: cc %s -o %t
|
|
// RUN: %t | FileCheck %s
|
|
// CHECK: hello world
|
|
#include <stdio.h>
|
|
|
|
int main() {
|
|
printf("hello world");
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
(testpath/"lit.site.cfg.py").write <<~EOS
|
|
import lit.formats
|
|
|
|
config.name = "Example"
|
|
config.test_format = lit.formats.ShTest(True)
|
|
|
|
config.suffixes = ['.c']
|
|
EOS
|
|
|
|
system bin/"lit", "-v", "."
|
|
|
|
if OS.mac?
|
|
ENV.prepend_path "PYTHONPATH", prefix/Language::Python.site_packages(python3)
|
|
else
|
|
python = deps.reject { |d| d.build? || d.test? }
|
|
.find { |d| d.name.match?(/^python@\d+(\.\d+)*$/) }
|
|
.to_formula
|
|
ENV.prepend_path "PATH", python.opt_bin
|
|
end
|
|
system python3, "-c", "import lit"
|
|
end
|
|
end
|