|
| 1 | +class TclTk < Formula |
| 2 | + desc "Tool Command Language" |
| 3 | + homepage "https://www.tcl-lang.org" |
| 4 | + url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.14/tcl8.6.14-src.tar.gz" |
| 5 | + mirror "https://fossies.org/linux/misc/tcl8.6.14-src.tar.gz" |
| 6 | + sha256 "5880225babf7954c58d4fb0f5cf6279104ce1cd6aa9b71e9a6322540e1c4de66" |
| 7 | + license "TCL" |
| 8 | + |
| 9 | + livecheck do |
| 10 | + url :stable |
| 11 | + regex(%r{url=.*?/(?:tcl|tk).?v?(\d+(?:\.\d+)+)[._-]src\.t}i) |
| 12 | + end |
| 13 | + |
| 14 | + bottle do |
| 15 | + sha256 arm64_sonoma: "fd7e83ade328ee3637f37f7df94ff33511602344486ba460f691aef19e8d22a9" |
| 16 | + sha256 arm64_ventura: "487f5c28c06b23a7a629ba591e3aaf4b49bc72afe4ae3d426b6a956bb6f66e0d" |
| 17 | + sha256 arm64_monterey: "afc256f0efcbbc946a2400f9dd000a752a17822528890f85da544bde74a98a5e" |
| 18 | + sha256 sonoma: "9f9891e88796a9e5c2c3f4422824b3bc720e91e52b110a1ad94c37f0152b568c" |
| 19 | + sha256 ventura: "f2b933dbeb9d19730a11441f021017591194ea9715c4051267d7730539389326" |
| 20 | + sha256 monterey: "ea9f1f004014ce9c03d4556834ddc8443de9167eea09ac203e82da4bba444be6" |
| 21 | + sha256 x86_64_linux: "f38ded8ef2931e50e9108a007bce02a07c6a93a8c44ac82de2ae9ee2ffe1111a" |
| 22 | + end |
| 23 | + |
| 24 | + depends_on "openssl@3" |
| 25 | + |
| 26 | + uses_from_macos "zlib" |
| 27 | + |
| 28 | + on_linux do |
| 29 | + depends_on "freetype" => :build |
| 30 | + depends_on "pkg-config" => :build |
| 31 | + depends_on "libx11" |
| 32 | + depends_on "libxext" |
| 33 | + end |
| 34 | + |
| 35 | + conflicts_with "page", because: "both install `page` binaries" |
| 36 | + |
| 37 | + resource "critcl" do |
| 38 | + url "https://github.com/andreas-kupries/critcl/archive/refs/tags/3.2.tar.gz" |
| 39 | + sha256 "20061944e28dda4ab2098b8f77682cab77973f8961f6fa60b95bcc09a546789e" |
| 40 | + end |
| 41 | + |
| 42 | + resource "tcllib" do |
| 43 | + url "https://downloads.sourceforge.net/project/tcllib/tcllib/1.21/tcllib-1.21.tar.xz" |
| 44 | + sha256 "10c7749e30fdd6092251930e8a1aa289b193a3b7f1abf17fee1d4fa89814762f" |
| 45 | + end |
| 46 | + |
| 47 | + resource "tcltls" do |
| 48 | + url "https://core.tcl-lang.org/tcltls/uv/tcltls-1.7.22.tar.gz" |
| 49 | + sha256 "e84e2b7a275ec82c4aaa9d1b1f9786dbe4358c815e917539ffe7f667ff4bc3b4" |
| 50 | + end |
| 51 | + |
| 52 | + resource "tk" do |
| 53 | + url "https://downloads.sourceforge.net/project/tcl/Tcl/8.6.14/tk8.6.14-src.tar.gz" |
| 54 | + mirror "https://fossies.org/linux/misc/tk8.6.14-src.tar.gz" |
| 55 | + sha256 "8ffdb720f47a6ca6107eac2dd877e30b0ef7fac14f3a84ebbd0b3612cee41a94" |
| 56 | + end |
| 57 | + |
| 58 | + # "https://downloads.sourceforge.net/project/incrtcl/%5Bincr%20Tcl_Tk%5D-4-source/itk%204.1.0/itk4.1.0.tar.gz" |
| 59 | + # would cause `bad URI(is not URI?)` error on 12/13 builds |
| 60 | + resource "itk4" do |
| 61 | + url "https://deb.debian.org/debian/pool/main/i/itk4/itk4_4.1.0.orig.tar.gz" |
| 62 | + mirror "https://src.fedoraproject.org/lookaside/extras/itk/itk4.1.0.tar.gz/sha512/1deed09daf66ae1d0cc88550be13814edff650f3ef2ecb5ae8d28daf92e37550b0e46921eb161da8ccc3886aaf62a4a3087df0f13610839b7c2d6f4b39c9f07e/itk4.1.0.tar.gz" |
| 63 | + sha256 "da646199222efdc4d8c99593863c8d287442ea5a8687f95460d6e9e72431c9c7" |
| 64 | + end |
| 65 | + |
| 66 | + def install |
| 67 | + args = %W[ |
| 68 | + --prefix=#{prefix} |
| 69 | + --includedir=#{include}/tcl-tk |
| 70 | + --mandir=#{man} |
| 71 | + --enable-threads |
| 72 | + --enable-64bit |
| 73 | + ] |
| 74 | + |
| 75 | + ENV["TCL_PACKAGE_PATH"] = "#{HOMEBREW_PREFIX}/lib" |
| 76 | + cd "unix" do |
| 77 | + system "./configure", *args |
| 78 | + system "make" |
| 79 | + system "make", "install" |
| 80 | + system "make", "install-private-headers" |
| 81 | + ln_s bin/"tclsh#{version.to_f}", bin/"tclsh" |
| 82 | + end |
| 83 | + |
| 84 | + # Let tk finds our new tclsh |
| 85 | + ENV.prepend_path "PATH", bin |
| 86 | + |
| 87 | + resource("tk").stage do |
| 88 | + cd "unix" do |
| 89 | + args << "--enable-aqua=yes" if OS.mac? |
| 90 | + system "./configure", *args, "--without-x", "--with-tcl=#{lib}" |
| 91 | + system "make" |
| 92 | + system "make", "install" |
| 93 | + system "make", "install-private-headers" |
| 94 | + ln_s bin/"wish#{version.to_f}", bin/"wish" |
| 95 | + end |
| 96 | + end |
| 97 | + |
| 98 | + resource("critcl").stage do |
| 99 | + system bin/"tclsh", "build.tcl", "install" |
| 100 | + end |
| 101 | + |
| 102 | + resource("tcllib").stage do |
| 103 | + system "./configure", "--prefix=#{prefix}", "--mandir=#{man}" |
| 104 | + system "make", "install" |
| 105 | + system "make", "critcl" |
| 106 | + cp_r "modules/tcllibc", "#{lib}/" |
| 107 | + ln_s "#{lib}/tcllibc/macosx-x86_64-clang", "#{lib}/tcllibc/macosx-x86_64" if OS.mac? |
| 108 | + end |
| 109 | + |
| 110 | + resource("tcltls").stage do |
| 111 | + system "./configure", "--with-ssl=openssl", |
| 112 | + "--with-openssl-dir=#{Formula["openssl@3"].opt_prefix}", |
| 113 | + "--prefix=#{prefix}", |
| 114 | + "--mandir=#{man}" |
| 115 | + system "make", "install" |
| 116 | + end |
| 117 | + |
| 118 | + resource("itk4").stage do |
| 119 | + itcl_dir = Pathname.glob(lib/"itcl*").last |
| 120 | + args = %W[ |
| 121 | + --prefix=#{prefix} |
| 122 | + --exec-prefix=#{prefix} |
| 123 | + --with-tcl=#{lib} |
| 124 | + --with-tclinclude=#{include}/tcl-tk |
| 125 | + --with-tk=#{lib} |
| 126 | + --with-tkinclude=#{include}/tcl-tk |
| 127 | + --with-itcl=#{itcl_dir} |
| 128 | + ] |
| 129 | + system "./configure", *args |
| 130 | + system "make" |
| 131 | + system "make", "install" |
| 132 | + end |
| 133 | + |
| 134 | + # Rename all section 3 man pages in the Debian/Ubuntu style, to avoid conflicts |
| 135 | + man3.glob("*.3") { |file| file.rename("#{file}tcl") } |
| 136 | + |
| 137 | + # Use the sqlite-analyzer formula instead |
| 138 | + # https://github.com/Homebrew/homebrew-core/pull/82698 |
| 139 | + rm bin/"sqlite3_analyzer" |
| 140 | + end |
| 141 | + |
| 142 | + def caveats |
| 143 | + <<~EOS |
| 144 | + The sqlite3_analyzer binary is in the `sqlite-analyzer` formula. |
| 145 | + EOS |
| 146 | + end |
| 147 | + |
| 148 | + test do |
| 149 | + assert_match "#{HOMEBREW_PREFIX}/lib", pipe_output("#{bin}/tclsh", "puts $auto_path\n") |
| 150 | + assert_equal "honk", pipe_output("#{bin}/tclsh", "puts honk\n").chomp |
| 151 | + |
| 152 | + # Fails with: no display name and no $DISPLAY environment variable |
| 153 | + return if OS.linux? && ENV["HOMEBREW_GITHUB_ACTIONS"] |
| 154 | + |
| 155 | + test_itk = <<~EOS |
| 156 | + # Check that Itcl and Itk load, and that we can define, instantiate, |
| 157 | + # and query the properties of a widget. |
| 158 | +
|
| 159 | +
|
| 160 | + # If anything errors, just exit |
| 161 | + catch { |
| 162 | + package require Itcl |
| 163 | + package require Itk |
| 164 | +
|
| 165 | + # Define class |
| 166 | + itcl::class TestClass { |
| 167 | + inherit itk::Toplevel |
| 168 | + constructor {args} { |
| 169 | + itk_component add bye { |
| 170 | + button $itk_interior.bye -text "Bye" |
| 171 | + } |
| 172 | + eval itk_initialize $args |
| 173 | + } |
| 174 | + } |
| 175 | +
|
| 176 | + # Create an instance |
| 177 | + set testobj [TestClass .#auto] |
| 178 | +
|
| 179 | + # Check the widget has a bye component with text property "Bye" |
| 180 | + if {[[$testobj component bye] cget -text]=="Bye"} { |
| 181 | + puts "OK" |
| 182 | + } |
| 183 | + } |
| 184 | + exit |
| 185 | + EOS |
| 186 | + assert_equal "OK\n", pipe_output("#{bin}/wish", test_itk), "Itk test failed" |
| 187 | + end |
| 188 | +end |
0 commit comments