-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
tcl-tk.rb
188 lines (158 loc) 路 6.24 KB
/
tcl-tk.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
class TclTk < Formula
desc "Tool Command Language"
homepage "https://www.tcl-lang.org"
url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.14/tcl8.6.14-src.tar.gz"
mirror "https://fossies.org/linux/misc/tcl8.6.14-src.tar.gz"
sha256 "5880225babf7954c58d4fb0f5cf6279104ce1cd6aa9b71e9a6322540e1c4de66"
license "TCL"
livecheck do
url :stable
regex(%r{url=.*?/(?:tcl|tk).?v?(\d+(?:\.\d+)+)[._-]src\.t}i)
end
bottle do
sha256 arm64_sonoma: "fd7e83ade328ee3637f37f7df94ff33511602344486ba460f691aef19e8d22a9"
sha256 arm64_ventura: "487f5c28c06b23a7a629ba591e3aaf4b49bc72afe4ae3d426b6a956bb6f66e0d"
sha256 arm64_monterey: "afc256f0efcbbc946a2400f9dd000a752a17822528890f85da544bde74a98a5e"
sha256 sonoma: "9f9891e88796a9e5c2c3f4422824b3bc720e91e52b110a1ad94c37f0152b568c"
sha256 ventura: "f2b933dbeb9d19730a11441f021017591194ea9715c4051267d7730539389326"
sha256 monterey: "ea9f1f004014ce9c03d4556834ddc8443de9167eea09ac203e82da4bba444be6"
sha256 x86_64_linux: "f38ded8ef2931e50e9108a007bce02a07c6a93a8c44ac82de2ae9ee2ffe1111a"
end
depends_on "openssl@3"
uses_from_macos "zlib"
on_linux do
depends_on "freetype" => :build
depends_on "pkg-config" => :build
depends_on "libx11"
depends_on "libxext"
end
conflicts_with "page", because: "both install `page` binaries"
resource "critcl" do
url "https://github.com/andreas-kupries/critcl/archive/refs/tags/3.2.tar.gz"
sha256 "20061944e28dda4ab2098b8f77682cab77973f8961f6fa60b95bcc09a546789e"
end
resource "tcllib" do
url "https://downloads.sourceforge.net/project/tcllib/tcllib/1.21/tcllib-1.21.tar.xz"
sha256 "10c7749e30fdd6092251930e8a1aa289b193a3b7f1abf17fee1d4fa89814762f"
end
resource "tcltls" do
url "https://core.tcl-lang.org/tcltls/uv/tcltls-1.7.22.tar.gz"
sha256 "e84e2b7a275ec82c4aaa9d1b1f9786dbe4358c815e917539ffe7f667ff4bc3b4"
end
resource "tk" do
url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.14/tk8.6.14-src.tar.gz"
mirror "https://fossies.org/linux/misc/tk8.6.14-src.tar.gz"
sha256 "8ffdb720f47a6ca6107eac2dd877e30b0ef7fac14f3a84ebbd0b3612cee41a94"
end
# "https://downloads.sourceforge.net/project/incrtcl/%5Bincr%20Tcl_Tk%5D-4-source/itk%204.1.0/itk4.1.0.tar.gz"
# would cause `bad URI(is not URI?)` error on 12/13 builds
resource "itk4" do
url "https://deb.debian.org/debian/pool/main/i/itk4/itk4_4.1.0.orig.tar.gz"
mirror "https://src.fedoraproject.org/lookaside/extras/itk/itk4.1.0.tar.gz/sha512/1deed09daf66ae1d0cc88550be13814edff650f3ef2ecb5ae8d28daf92e37550b0e46921eb161da8ccc3886aaf62a4a3087df0f13610839b7c2d6f4b39c9f07e/itk4.1.0.tar.gz"
sha256 "da646199222efdc4d8c99593863c8d287442ea5a8687f95460d6e9e72431c9c7"
end
def install
args = %W[
--prefix=#{prefix}
--includedir=#{include}/tcl-tk
--mandir=#{man}
--enable-threads
--enable-64bit
]
ENV["TCL_PACKAGE_PATH"] = "#{HOMEBREW_PREFIX}/lib"
cd "unix" do
system "./configure", *args
system "make"
system "make", "install"
system "make", "install-private-headers"
ln_s bin/"tclsh#{version.to_f}", bin/"tclsh"
end
# Let tk finds our new tclsh
ENV.prepend_path "PATH", bin
resource("tk").stage do
cd "unix" do
args << "--enable-aqua=yes" if OS.mac?
system "./configure", *args, "--without-x", "--with-tcl=#{lib}"
system "make"
system "make", "install"
system "make", "install-private-headers"
ln_s bin/"wish#{version.to_f}", bin/"wish"
end
end
resource("critcl").stage do
system bin/"tclsh", "build.tcl", "install"
end
resource("tcllib").stage do
system "./configure", "--prefix=#{prefix}", "--mandir=#{man}"
system "make", "install"
system "make", "critcl"
cp_r "modules/tcllibc", "#{lib}/"
ln_s "#{lib}/tcllibc/macosx-x86_64-clang", "#{lib}/tcllibc/macosx-x86_64" if OS.mac?
end
resource("tcltls").stage do
system "./configure", "--with-ssl=openssl",
"--with-openssl-dir=#{Formula["openssl@3"].opt_prefix}",
"--prefix=#{prefix}",
"--mandir=#{man}"
system "make", "install"
end
resource("itk4").stage do
itcl_dir = Pathname.glob(lib/"itcl*").last
args = %W[
--prefix=#{prefix}
--exec-prefix=#{prefix}
--with-tcl=#{lib}
--with-tclinclude=#{include}/tcl-tk
--with-tk=#{lib}
--with-tkinclude=#{include}/tcl-tk
--with-itcl=#{itcl_dir}
]
system "./configure", *args
system "make"
system "make", "install"
end
# Rename all section 3 man pages in the Debian/Ubuntu style, to avoid conflicts
man3.glob("*.3") { |file| file.rename("#{file}tcl") }
# Use the sqlite-analyzer formula instead
# https://github.com/Homebrew/homebrew-core/pull/82698
rm bin/"sqlite3_analyzer"
end
def caveats
<<~EOS
The sqlite3_analyzer binary is in the `sqlite-analyzer` formula.
EOS
end
test do
assert_match "#{HOMEBREW_PREFIX}/lib", pipe_output("#{bin}/tclsh", "puts $auto_path\n")
assert_equal "honk", pipe_output("#{bin}/tclsh", "puts honk\n").chomp
# Fails with: no display name and no $DISPLAY environment variable
return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"]
test_itk = <<~EOS
# Check that Itcl and Itk load, and that we can define, instantiate,
# and query the properties of a widget.
# If anything errors, just exit
catch {
package require Itcl
package require Itk
# Define class
itcl::class TestClass {
inherit itk::Toplevel
constructor {args} {
itk_component add bye {
button $itk_interior.bye -text "Bye"
}
eval itk_initialize $args
}
}
# Create an instance
set testobj [TestClass .#auto]
# Check the widget has a bye component with text property "Bye"
if {[[$testobj component bye] cget -text]=="Bye"} {
puts "OK"
}
}
exit
EOS
assert_equal "OK\n", pipe_output("#{bin}/wish", test_itk), "Itk test failed"
end
end