homebrew-core/Formula/tcl-tk.rb

158 lines
4.6 KiB
Ruby

class TclTk < Formula
desc "Tool Command Language"
homepage "https://www.tcl-lang.org"
url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.10/tcl8.6.10-src.tar.gz"
mirror "https://ftp.osuosl.org/pub/blfs/conglomeration/tcl/tcl8.6.10-src.tar.gz"
sha256 "5196dbf6638e3df8d5c87b5815c8c2b758496eb6f0e41446596c9a4e638d87ed"
license "TCL"
livecheck do
url :stable
regex(%r{url=.*?/(?:tcl|tk).?v?(\d+(?:\.\d+)+)[._-]src\.t}i)
end
bottle do
rebuild 1
sha256 "4740b30b97f0308ecc59c1308945c38ddca5d3da528d779f38199a2dad905fa1" => :catalina
sha256 "1851fee12a3ee44648845d8663a192712ce6827ef8fe167301d2638ac9ddb96c" => :mojave
sha256 "d1d689cc3e9cf08b2a42d487db3c4142e7ee4ff322bef22d6187fc67a5b776b7" => :high_sierra
end
keg_only :provided_by_macos
depends_on "openssl@1.1"
on_linux do
depends_on "pkg-config" => :build
end
resource "critcl" do
url "https://github.com/andreas-kupries/critcl/archive/3.1.18.tar.gz"
sha256 "6fb0263cc8dfb787ab162ae130570c19f665a03229b8a046ec1c11809c2ff70e"
end
resource "tcllib" do
url "https://downloads.sourceforge.net/project/tcllib/tcllib/1.20/tcllib-1.20.tar.xz"
sha256 "199e8ec7ee26220e8463bc84dd55c44965fc8ef4d4ac6e4684b2b1c03b1bd5b9"
end
resource "tcltls" do
url "https://core.tcl-lang.org/tcltls/uv/tcltls-1.7.20.tar.gz"
sha256 "397a4e7cd4ea7a6dbf8a1a664e73945b91828c7c76d02474875261d22fb4e4ca"
end
resource "tk" do
url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.10/tk8.6.10-src.tar.gz"
mirror "https://fossies.org/linux/misc/tk8.6.10-src.tar.gz"
sha256 "63df418a859d0a463347f95ded5cd88a3dd3aaa1ceecaeee362194bc30f3e386"
end
resource "itk4" do
url "https://downloads.sourceforge.net/project/incrtcl/%5Bincr%20Tcl_Tk%5D-4-source/itk%204.1.0/itk4.1.0.tar.gz"
sha256 "da646199222efdc4d8c99593863c8d287442ea5a8687f95460d6e9e72431c9c7"
end
def install
args = %W[
--prefix=#{prefix}
--mandir=#{man}
--enable-threads
--enable-64bit
]
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
system "./configure", *args, "--enable-aqua=yes",
"--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"
ENV["SDKROOT"] = MacOS.sdk_path
system "make", "critcl"
cp_r "modules/tcllibc", "#{lib}/"
ln_s "#{lib}/tcllibc/macosx-x86_64-clang", "#{lib}/tcllibc/macosx-x86_64"
end
resource("tcltls").stage do
system "./configure", "--with-ssl=openssl",
"--with-openssl-dir=#{Formula["openssl@1.1"].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-tk=#{lib}
--with-itcl=#{itcl_dir}
]
system "./configure", *args
system "make"
system "make", "install"
end
end
test do
assert_equal "honk", pipe_output("#{bin}/tclsh", "puts honk\n").chomp
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