117 lines
4.3 KiB
Ruby
117 lines
4.3 KiB
Ruby
class ClickhouseOdbc < Formula
|
|
desc "Official ODBC driver implementation for accessing ClickHouse as a data source"
|
|
homepage "https://github.com/ClickHouse/clickhouse-odbc#readme"
|
|
url "https://github.com/ClickHouse/clickhouse-odbc.git",
|
|
tag: "v1.1.10.20210822",
|
|
revision: "c7aaff6860e448acee523f5f7d3ee97862fd07d2"
|
|
license "Apache-2.0"
|
|
head "https://github.com/ClickHouse/clickhouse-odbc.git", branch: "master"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "7eadbafc340ed5a82784f324c3089c18e9d61b39960a855a75f195ab2ec2d86b"
|
|
sha256 cellar: :any, arm64_big_sur: "f41c561476fdb934633db980241c84284cd10ee2e1b6a063c8b8bf4d1defe560"
|
|
sha256 cellar: :any, monterey: "2b563f20b056ba7fd8c15fa6ca7a980946192fbdcf0bcd09146f12a19238c0d7"
|
|
sha256 cellar: :any, big_sur: "e6d1f023de5da25925976a49e6e67752ca2f21e03b8830ff29f445b76d494229"
|
|
sha256 cellar: :any, catalina: "321dd3734dac814a4e3d02a407195f700a0217a9edc5c94bc01aa0aec4b161a0"
|
|
sha256 cellar: :any, mojave: "e2087770d6ff73e2ca07bfa972b7a59b6b38eb02a1262fc8a537282ac78b07b1"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "3c4e8d0d6b0e858be6367eb3a10520b9dfa99ebea2c0be44c81e6cc79f105b48"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "icu4c"
|
|
depends_on "openssl@1.1"
|
|
|
|
on_macos do
|
|
depends_on "libiodbc"
|
|
end
|
|
|
|
on_linux do
|
|
depends_on "unixodbc"
|
|
depends_on "gcc"
|
|
end
|
|
|
|
fails_with gcc: "5"
|
|
fails_with gcc: "6"
|
|
|
|
def install
|
|
cmake_args = std_cmake_args.dup
|
|
|
|
cmake_args << "-DOPENSSL_ROOT_DIR=#{Formula["openssl@1.1"].opt_prefix}"
|
|
cmake_args << "-DICU_ROOT=#{Formula["icu4c"].opt_prefix}"
|
|
|
|
if OS.mac?
|
|
cmake_args << "-DODBC_PROVIDER=iODBC"
|
|
cmake_args << "-DODBC_DIR=#{Formula["libiodbc"].opt_prefix}"
|
|
elsif OS.linux?
|
|
cmake_args << "-DODBC_PROVIDER=UnixODBC"
|
|
cmake_args << "-DODBC_DIR=#{Formula["unixodbc"].opt_prefix}"
|
|
end
|
|
|
|
system "cmake", "-S", ".", "-B", "build", *cmake_args
|
|
system "cmake", "--build", "build"
|
|
system "cmake", "--install", "build"
|
|
end
|
|
|
|
test do
|
|
(testpath/"my.odbcinst.ini").write <<~EOS
|
|
[ODBC Drivers]
|
|
ClickHouse ODBC Test Driver A = Installed
|
|
ClickHouse ODBC Test Driver W = Installed
|
|
|
|
[ClickHouse ODBC Test Driver A]
|
|
Description = ODBC Driver for ClickHouse (ANSI)
|
|
Driver = #{lib/shared_library("libclickhouseodbc")}
|
|
Setup = #{lib/shared_library("libclickhouseodbc")}
|
|
UsageCount = 1
|
|
|
|
[ClickHouse ODBC Test Driver W]
|
|
Description = ODBC Driver for ClickHouse (Unicode)
|
|
Driver = #{lib/shared_library("libclickhouseodbcw")}
|
|
Setup = #{lib/shared_library("libclickhouseodbcw")}
|
|
UsageCount = 1
|
|
EOS
|
|
|
|
(testpath/"my.odbc.ini").write <<~EOS
|
|
[ODBC Data Sources]
|
|
ClickHouse ODBC Test DSN A = ClickHouse ODBC Test Driver A
|
|
ClickHouse ODBC Test DSN W = ClickHouse ODBC Test Driver W
|
|
|
|
[ClickHouse ODBC Test DSN A]
|
|
Driver = ClickHouse ODBC Test Driver A
|
|
Description = DSN for ClickHouse ODBC Test Driver (ANSI)
|
|
Url = https://default:password@example.com:8443/query?database=default
|
|
|
|
[ClickHouse ODBC Test DSN W]
|
|
Driver = ClickHouse ODBC Test Driver W
|
|
Description = DSN for ClickHouse ODBC Test Driver (Unicode)
|
|
Url = https://default:password@example.com:8443/query?database=default
|
|
EOS
|
|
|
|
ENV["ODBCSYSINI"] = testpath
|
|
ENV["ODBCINSTINI"] = "my.odbcinst.ini"
|
|
ENV["ODBCINI"] = "#{ENV["ODBCSYSINI"]}/my.odbc.ini"
|
|
|
|
if OS.mac?
|
|
ENV["ODBCINSTINI"] = "#{ENV["ODBCSYSINI"]}/#{ENV["ODBCINSTINI"]}"
|
|
|
|
assert_match "SQL>",
|
|
pipe_output("#{Formula["libiodbc"].bin}/iodbctest 'DSN=ClickHouse ODBC Test DSN A'", "exit\n")
|
|
|
|
assert_match "SQL>",
|
|
pipe_output("#{Formula["libiodbc"].bin}/iodbctestw 'DSN=ClickHouse ODBC Test DSN W'", "exit\n")
|
|
elsif OS.linux?
|
|
assert_match "Connected!",
|
|
pipe_output("#{Formula["unixodbc"].bin}/isql 'ClickHouse ODBC Test DSN A'", "quit\n")
|
|
|
|
assert_match "Connected!",
|
|
pipe_output("#{Formula["unixodbc"].bin}/iusql 'ClickHouse ODBC Test DSN W'", "quit\n")
|
|
end
|
|
end
|
|
end
|