91 lines
2.6 KiB
Ruby
91 lines
2.6 KiB
Ruby
class QtMysql < Formula
|
|
desc "Qt SQL Database Driver"
|
|
homepage "https://www.qt.io/"
|
|
url "https://download.qt.io/official_releases/qt/6.0/6.0.3/submodules/qtbase-everywhere-src-6.0.3.tar.xz"
|
|
sha256 "1a45b61c2a349964625c50e3ea40cbb309e269762dd0786397e0e18e7e10d394"
|
|
license all_of: ["LGPL-2.1-only", "LGPL-3.0-only"]
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "d76cc888ba43cd6ac5518bf668b9fb438362b1e4f7f6cb4725b875b46f434ae4"
|
|
sha256 cellar: :any, big_sur: "de31674cd4806465fed2f387e67ce2e791f33462df09d8bf44b29af6e9ed9f8c"
|
|
sha256 cellar: :any, catalina: "1fe85d7d7af7e036e652ca1a79a7f59055f1db29309498db8fd87837f375bd17"
|
|
sha256 cellar: :any, mojave: "b36545cbc96fca2ab14c5ddd19d63790ee0de9d6ce7cf27645d2b61b4044262a"
|
|
end
|
|
|
|
depends_on "cmake" => [:build, :test]
|
|
|
|
depends_on "mysql"
|
|
depends_on "qt"
|
|
|
|
conflicts_with "qt-mariadb", "qt-percona-server",
|
|
because: "qt-mysql, qt-mariadb, and qt-percona install the same binaries"
|
|
|
|
def install
|
|
args = std_cmake_args + %W[
|
|
-DCMAKE_STAGING_PREFIX=#{prefix}
|
|
|
|
-DFEATURE_sql_ibase=OFF
|
|
-DFEATURE_sql_mysql=ON
|
|
-DFEATURE_sql_oci=OFF
|
|
-DFEATURE_sql_odbc=OFF
|
|
-DFEATURE_sql_psql=OFF
|
|
-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 a(argc, argv);
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
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
|