-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
clickhouse-odbc.rb
122 lines (101 loc) 路 4.4 KB
/
clickhouse-odbc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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.2.1.20220905",
revision: "fab6efc57d671155c3a386f49884666b2a02c7b7"
license "Apache-2.0"
revision 4
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: "6d3da8f25a679d578fc9fbca684018833ad363535bfd3e85a4ddd736f6b32e78"
sha256 cellar: :any, arm64_big_sur: "edd276cf440f60a578c73b6bd97f28405b4832794dce0b11e7bed991650e47f7"
sha256 cellar: :any, monterey: "f0bb5c75237871886d291229e6ba60ffedb04c3d8a5e2feae411968cf83537c6"
sha256 cellar: :any, big_sur: "b8ba8ebeb1a452406829d7c81315c9137a2e583f8699edd6fdc9cc7827cb3463"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0d6e08e8ba3cdeff98402a304e88bc44c416081b13aa0147d9ab9c82e6404982"
end
# https://github.com/facebook/folly/issues/1867
deprecate! date: "2023-06-15",
because: "vendors an old version of folly that is incompatible with new versions of libc++"
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "icu4c"
depends_on "openssl@3"
depends_on "poco"
on_macos do
depends_on "libiodbc"
end
on_linux do
depends_on "unixodbc"
end
fails_with :gcc do
version "6"
end
def install
# Remove bundled libraries excluding required bundled `folly` headers
%w[googletest nanodbc poco ssl].each { |l| (buildpath/"contrib"/l).rmtree }
args = %W[
-DCH_ODBC_PREFER_BUNDLED_THIRD_PARTIES=OFF
-DCH_ODBC_THIRD_PARTY_LINK_STATIC=OFF
-DICU_ROOT=#{Formula["icu4c"].opt_prefix}
-DOPENSSL_ROOT_DIR=#{Formula["openssl@3"].opt_prefix}
]
args += if OS.mac?
["-DODBC_PROVIDER=iODBC", "-DODBC_DIR=#{Formula["libiodbc"].opt_prefix}"]
else
["-DODBC_PROVIDER=UnixODBC", "-DODBC_DIR=#{Formula["unixodbc"].opt_prefix}"]
end
system "cmake", "-S", ".", "-B", "build", *args, *std_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