-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |