|
| 1 | +class SqlbSqlite < Formula |
| 2 | + desc "Command-line interface for SQLite" |
| 3 | + homepage "https://sqlite.org/index.html" |
| 4 | + url "https://www.sqlite.org/2025/sqlite-autoconf-3480000.tar.gz" |
| 5 | + version "3.48.0" |
| 6 | + sha256 "ac992f7fca3989de7ed1fe99c16363f848794c8c32a158dafd4eb927a2e02fd5" |
| 7 | + license "blessing" |
| 8 | + |
| 9 | + bottle do |
| 10 | + root_url "https://github.com/lucydodo/homebrew-tap/releases/download/sqlb-sqlite-3.48.0" |
| 11 | + sha256 cellar: :any, arm64_sonoma: "90e6a864154e6089ff1cfaacc5e589efae5cc844b47369174a8ebb04039f843b" |
| 12 | + end |
| 13 | + env :std |
| 14 | + |
| 15 | + livecheck do |
| 16 | + url :homepage |
| 17 | + regex(%r{href=.*?releaselog/v?(\d+(?:[._]\d+)+)\.html}i) |
| 18 | + strategy :page_match do |page, regex| |
| 19 | + page.scan(regex).map { |match| match&.first&.tr("_", ".") } |
| 20 | + end |
| 21 | + end |
| 22 | + |
| 23 | + keg_only :shadowed_by_macos |
| 24 | + |
| 25 | + depends_on arch: :arm64 |
| 26 | + |
| 27 | + def install |
| 28 | + # Determine the minimum macOS version. |
| 29 | + # Match the required version of the DB Browser for SQLite app. |
| 30 | + ENV["MACOSX_DEPLOYMENT_TARGET"] = "10.13" |
| 31 | + ENV.append "CPPFLAGS", "-mmacosx-version-min=10.13" |
| 32 | + ENV.append "LDFLAGS", "-mmacosx-version-min=10.13" |
| 33 | + |
| 34 | + ENV.append "CFLAGS", "-arch x86_64 -arch arm64" |
| 35 | + |
| 36 | + # Default value of MAX_VARIABLE_NUMBER is 999 which is too low for many |
| 37 | + # applications. Set to 250000 (Same value used in Debian and Ubuntu). |
| 38 | + ENV.append "CPPFLAGS", %w[ |
| 39 | + -DSQLITE_ENABLE_API_ARMOR=1 |
| 40 | + -DSQLITE_ENABLE_COLUMN_METADATA=1 |
| 41 | + -DSQLITE_ENABLE_DBSTAT_VTAB=1 |
| 42 | + -DSQLITE_ENABLE_FTS3=1 |
| 43 | + -DSQLITE_ENABLE_FTS3_PARENTHESIS=1 |
| 44 | + -DSQLITE_ENABLE_FTS5=1 |
| 45 | + -DSQLITE_ENABLE_GEOPOLY=1 |
| 46 | + -DSQLITE_ENABLE_JSON1=1 |
| 47 | + -DSQLITE_ENABLE_MATH_FUNCTIONS=1 |
| 48 | + -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 |
| 49 | + -DSQLITE_ENABLE_RTREE=1 |
| 50 | + -DSQLITE_ENABLE_SNAPSHOT=1 |
| 51 | + -DSQLITE_ENABLE_SOUNDEX=1 |
| 52 | + -DSQLITE_ENABLE_STAT4=1 |
| 53 | + -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 |
| 54 | + -DSQLITE_MAX_ATTACHED=125 |
| 55 | + -DSQLITE_MAX_VARIABLE_NUMBER=250000 |
| 56 | + -DSQLITE_USE_URI=1 |
| 57 | + ].join(" ") |
| 58 | + |
| 59 | + args = %W[ |
| 60 | + --prefix=#{prefix} |
| 61 | + --disable-dependency-tracking |
| 62 | + --enable-dynamic-extensions |
| 63 | + --disable-readline |
| 64 | + --disable-editline |
| 65 | + ] |
| 66 | + |
| 67 | + system "./configure", *args |
| 68 | + system "make", "install" |
| 69 | + |
| 70 | + # Avoid rebuilds of dependants that hardcode this path. |
| 71 | + inreplace lib/"pkgconfig/sqlite3.pc", prefix, opt_prefix |
| 72 | + end |
| 73 | + |
| 74 | + test do |
| 75 | + path = testpath/"school.sql" |
| 76 | + path.write <<~EOS |
| 77 | + create table students (name text, age integer); |
| 78 | + insert into students (name, age) values ('Bob', 14); |
| 79 | + insert into students (name, age) values ('Sue', 12); |
| 80 | + insert into students (name, age) values ('Tim', 13); |
| 81 | + select name from students order by age asc; |
| 82 | + EOS |
| 83 | + |
| 84 | + names = shell_output("#{bin}/sqlite3 < #{path}").strip.split("\n") |
| 85 | + assert_equal %w[Sue Tim Bob], names |
| 86 | + end |
| 87 | +end |
0 commit comments