jackett 0.22.1382
[Homebrew/homebrew-core.git] / Formula / b / bdw-gc.rb
blobe35fb3f75257bf0de790ede3a322517c3214ed71
1 class BdwGc < Formula
2   desc "Garbage collector for C and C++"
3   homepage "https://www.hboehm.info/gc/"
4   url "https://github.com/ivmai/bdwgc/releases/download/v8.2.8/gc-8.2.8.tar.gz"
5   sha256 "7649020621cb26325e1fb5c8742590d92fb48ce5c259b502faf7d9fb5dabb160"
6   license "MIT"
7   head "https://github.com/ivmai/bdwgc.git", branch: "master"
9   livecheck do
10     url :stable
11     strategy :github_latest
12   end
14   bottle do
15     sha256 cellar: :any,                 arm64_sequoia:  "58c2b5cf58c6ea30fc56a34aacfe36f774bed4cee1dca9808ef58d154a5ec965"
16     sha256 cellar: :any,                 arm64_sonoma:   "26862c04a22c24bbbe25d7fd1a2fa4d499d5a7216101625115be645123ea0445"
17     sha256 cellar: :any,                 arm64_ventura:  "55890248e3f2624e882660e38695e9090a8be1bff6c9a829ef35b0a30a890fee"
18     sha256 cellar: :any,                 arm64_monterey: "013ffdfc107f8ec5d5382af87412bdfd4cb3503e866555fbe3252c3d7dcdcc10"
19     sha256 cellar: :any,                 sonoma:         "54cd5df410fb01fc0f7a9b212b5ef40e8160e360e597b5d20e6e489df306ce37"
20     sha256 cellar: :any,                 ventura:        "71c1beb334094059de83c81be4f1239e4ece22a1f7baf5c98d9682a2243b13bb"
21     sha256 cellar: :any,                 monterey:       "33e2046794356d765327d03b638c8449e38a69055f801542ee4abd2ea6329f49"
22     sha256 cellar: :any_skip_relocation, x86_64_linux:   "f666fdf55ce3b41704f5869120ddfd3e973051d1fc0dc32a80733f20ba15ea0c"
23   end
25   depends_on "cmake" => :build
27   def install
28     args = %w[
29       -Denable_cplusplus=ON
30       -Denable_large_config=ON
31       -Dwithout_libatomic_ops=OFF
32       -Dwith_libatomic_ops=OFF
33     ]
35     system "cmake", "-S", ".", "-B", "build",
36                     "-Dbuild_tests=ON",
37                     "-DBUILD_SHARED_LIBS=ON",
38                     "-DCMAKE_INSTALL_RPATH=#{rpath}",
39                     *args, *std_cmake_args,
40                     "-DBUILD_TESTING=ON" # Pass this *after* `std_cmake_args`
41     system "cmake", "--build", "build"
42     if OS.linux? || Hardware::CPU.arm? || MacOS.version > :monterey
43       # Fails on 12-x86_64.
44       system "ctest", "--test-dir", "build",
45                       "--parallel", ENV.make_jobs,
46                       "--rerun-failed",
47                       "--output-on-failure"
48     end
49     system "cmake", "--install", "build"
51     system "cmake", "-S", ".", "-B", "build-static", "-DBUILD_SHARED_LIBS=OFF", *args, *std_cmake_args
52     system "cmake", "--build", "build-static"
53     lib.install buildpath.glob("build-static/*.a")
54   end
56   test do
57     (testpath/"test.c").write <<~C
58       #include <assert.h>
59       #include <stdio.h>
60       #include "gc.h"
62       int main(void)
63       {
64         int i;
66         GC_INIT();
67         for (i = 0; i < 10000000; ++i)
68         {
69           int **p = (int **) GC_MALLOC(sizeof(int *));
70           int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int));
71           assert(*p == 0);
72           *p = (int *) GC_REALLOC(q, 2 * sizeof(int));
73         }
74         return 0;
75       }
76     C
78     system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgc", "-o", "test"
79     system "./test"
80   end
81 end