1 class Traildb < Formula
2 desc "Blazingly-fast database for log-structured data"
3 homepage "https://traildb.io/"
4 url "https://github.com/traildb/traildb/archive/refs/tags/0.6.tar.gz"
5 sha256 "f73515fe56c547f861296cf8eecc98b8e8bf00d175ad9fb7f4b981ad7cf8b67c"
10 regex(/^v?(\d+(?:\.\d+)+)$/i)
15 sha256 arm64_sequoia: "6855e108a52b0df9a4f13492f09ccf0d8ae7efcb2b25441f88a9d1e214137c4c"
16 sha256 arm64_sonoma: "54903d470c8c610d59b4122f43e3c0292781c8949d5ba8e141f59362e1beb16e"
17 sha256 arm64_ventura: "fc31267f2145da6af9f4cf19609bebd1e4e5f7e468549bb2adbdfd40bd3b50ad"
18 sha256 arm64_monterey: "f34fd4ae7821c7f82a44e374e4c07603a63ec224c5ddb441c38e0defcaaeb4a7"
19 sha256 arm64_big_sur: "1889bda4c138dbcf3d7a7229a47705631f2c5880f20a23e3612685c8a1ad7208"
20 sha256 sonoma: "b3d15cca75203e35bc56037c0ec9e1139c54ab909c81ec36a02d7b7ed9daa117"
21 sha256 ventura: "0534a5fd56705faf95c68bd3a4e0ab4b401baaef55d4e8fc37f88126643e5f16"
22 sha256 monterey: "f973d38d9cfe84c422bf98fc4c91265b2d3865efde148fe9b32a2a3af75d44e9"
23 sha256 big_sur: "c86da6038d5ffb50fac4db5af5e0e4cb91c93814fcd712fc4e2697747db2a0a8"
24 sha256 x86_64_linux: "eacba47e211b4e29a1a44507087e2fc1cb501f00c853ee406a0c954c8ba4c47e"
27 depends_on "pkgconf" => :build
29 depends_on "libarchive"
31 uses_from_macos "python" => :build
33 # Update waf script for Python 3
34 # Use resource instead of patch since applying corrupts waf
37 url "https://raw.githubusercontent.com/traildb/traildb/053ed8e5d0301c792f3ee703cd9936c49ecf41a1/waf"
38 sha256 "2e0cf83a63843da127610420cef1d3126f1187d8e572b6b3a28052fc2250d4bf"
41 # Update `waf` further for Python 3.12+ support. We don't use this on macOS as newer versions
42 # fail to find `libarchive` on non-/usr/local prefix due to wscript PKG_CONFIG_PATH override
43 url "https://waf.io/waf-2.1.4"
44 sha256 "7803d63e698ada49a74ab6979a0fd708a5f9a3456206cba3a3e07387fdcf946d"
49 ENV["PREFIX"] = prefix
50 resource("waf").stage { buildpath.install Dir["*"].first => "waf" }
51 system "python3", "./waf", "configure", "install"
55 # Check that the library has been installed correctly
56 (testpath/"test.c").write <<~C
60 const char *path = "test.tdb";
61 const char *fields[] = {};
62 tdb_cons* c1 = tdb_cons_init();
63 assert(tdb_cons_open(c1, path, fields, 0) == 0);
64 assert(tdb_cons_finalize(c1) == 0);
66 assert(tdb_open(t1, path) == 0);
69 system ENV.cc, "test.c", "-L#{lib}", "-ltraildb", "-o", "test"
72 # Check that the provided tdb binary works correctly
73 (testpath/"in.csv").write("1234 1234\n")
74 system bin/"tdb", "make", "-c", "-i", "in.csv", "--tdb-format", "pkg"