97 lines
2.9 KiB
Ruby
97 lines
2.9 KiB
Ruby
class QtPostgresql < Formula
|
|
desc "Qt SQL Database Driver"
|
|
homepage "https://www.qt.io/"
|
|
url "https://download.qt.io/official_releases/qt/6.4/6.4.1/submodules/qtbase-everywhere-src-6.4.1.tar.xz"
|
|
sha256 "532ad71cc0f9c8f7cb92766c47bc3d23263c60876becd9053802f9727af24fae"
|
|
license any_of: ["GPL-2.0-only", "GPL-3.0-only", "LGPL-3.0-only"]
|
|
|
|
livecheck do
|
|
formula "qt"
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_ventura: "e3996dcd6769927d7892698a5c7fa44da4fe0989b286a481d441c5e7fe38eaf4"
|
|
sha256 cellar: :any, arm64_monterey: "3451d233f3ca9099195dacb105a7ada20617bdb45981efed3384f9f8f0c5e802"
|
|
sha256 cellar: :any, arm64_big_sur: "e11a5f14ba42966ade99701fa2da57b4979c806b865ffefc4580a592532262ac"
|
|
sha256 cellar: :any, ventura: "fb58d90ef2060022b0f3378fc04d8df3de2e404326c76a0f86c6b381e51afb0e"
|
|
sha256 cellar: :any, monterey: "3c20d51cdcdaaf4723bf8fed797701d57357504874641453e6275a2299a3a7ea"
|
|
sha256 cellar: :any, big_sur: "85fd7ab0d62afe1ccb5f02959fc153caf0c24f0858384ace5361bf3268b52d62"
|
|
end
|
|
|
|
depends_on "cmake" => [:build, :test]
|
|
|
|
depends_on "libpq"
|
|
depends_on "qt"
|
|
|
|
fails_with gcc: "5"
|
|
|
|
def install
|
|
args = std_cmake_args + %W[
|
|
-DCMAKE_STAGING_PREFIX=#{prefix}
|
|
|
|
-DFEATURE_sql_ibase=OFF
|
|
-DFEATURE_sql_mysql=OFF
|
|
-DFEATURE_sql_oci=OFF
|
|
-DFEATURE_sql_odbc=OFF
|
|
-DFEATURE_sql_psql=ON
|
|
-DFEATURE_sql_sqlite=OFF
|
|
]
|
|
|
|
cd "src/plugins/sqldrivers" do
|
|
system "cmake", ".", *args
|
|
system "cmake", "--build", "."
|
|
system "cmake", "--install", "."
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"CMakeLists.txt").write <<~EOS
|
|
cmake_minimum_required(VERSION #{Formula["cmake"].version})
|
|
project(test VERSION 1.0.0 LANGUAGES CXX)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
find_package(Qt6 COMPONENTS Core Sql REQUIRED)
|
|
add_executable(test
|
|
main.cpp
|
|
)
|
|
target_link_libraries(test PRIVATE Qt6::Core Qt6::Sql)
|
|
EOS
|
|
|
|
(testpath/"test.pro").write <<~EOS
|
|
QT += core sql
|
|
QT -= gui
|
|
TARGET = test
|
|
CONFIG += console debug
|
|
CONFIG -= app_bundle
|
|
TEMPLATE = app
|
|
SOURCES += main.cpp
|
|
EOS
|
|
|
|
(testpath/"main.cpp").write <<~EOS
|
|
#include <QCoreApplication>
|
|
#include <QtSql>
|
|
#include <cassert>
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication::addLibraryPath("#{share}/qt/plugins");
|
|
QCoreApplication a(argc, argv);
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
|
|
assert(db.isValid());
|
|
return 0;
|
|
}
|
|
EOS
|
|
|
|
system "cmake", "-S", ".", "-B", "build", "-DCMAKE_BUILD_TYPE=Debug"
|
|
system "cmake", "--build", "build"
|
|
system "./build/test"
|
|
|
|
ENV.delete "CPATH"
|
|
system "qmake"
|
|
system "make"
|
|
system "./test"
|
|
end
|
|
end
|