homebrew-core/Formula/minimal-racket.rb

104 lines
3.7 KiB
Ruby

class MinimalRacket < Formula
desc "Modern programming language in the Lisp/Scheme family"
homepage "https://racket-lang.org/"
url "https://mirror.racket-lang.org/installers/8.5/racket-minimal-8.5-src.tgz"
sha256 "55d585e3ac9fbaacfbe840a6ec74ce3e7bee9fe85e32213f1b3e4f6f593cae39"
license any_of: ["MIT", "Apache-2.0"]
# File links on the download page are created using JavaScript, so we parse
# the filename from a string in an object. We match the version from the
# "Unix Source + built packages" option, as the `racket-minimal` archive is
# only found on the release page for a given version (e.g., `/releases/8.0/`).
livecheck do
url "https://download.racket-lang.org/"
regex(/["'][^"']*?racket(?:-minimal)?[._-]v?(\d+(?:\.\d+)+)-src\.t/i)
end
bottle do
sha256 arm64_monterey: "acf973e4a02fb8ccf6a9f882d67597c2106a580143cf2ab362fb1771d7df2921"
sha256 arm64_big_sur: "8a8cb26ce71f6ca21a8896439cfd95dcc775167c3600ecbcb7e1b710dc175f0b"
sha256 big_sur: "b107fab5bc5575c25db9e9e0c8193eed7aa111bf46d9ac7ffd8c178a6fbaf806"
sha256 catalina: "7e42dd037afd1e8c8f44dea0c771c6483bf1794ee64470118fdf9193ff566073"
sha256 x86_64_linux: "c39f5edd41c16a55b9df0e9b12b43de2407aa1bd18c40556143e6011a6652d4d"
end
depends_on "openssl@1.1"
uses_from_macos "libffi"
# these two files are amended when (un)installing packages
skip_clean "lib/racket/launchers.rktd", "lib/racket/mans.rktd"
def install
# configure racket's package tool (raco) to do the Right Thing
# see: https://docs.racket-lang.org/raco/config-file.html
inreplace "etc/config.rktd", /\)\)\n$/, ") (default-scope . \"installation\"))\n"
cd "src" do
args = %W[
--disable-debug
--disable-dependency-tracking
--enable-origtree=no
--enable-macprefix
--prefix=#{prefix}
--mandir=#{man}
--sysconfdir=#{etc}
--enable-useprefix
]
ENV["LDFLAGS"] = "-rpath #{Formula["openssl@1.1"].opt_lib}"
ENV["LDFLAGS"] = "-Wl,-rpath=#{Formula["openssl@1.1"].opt_lib}" if OS.linux?
system "./configure", *args
system "make"
system "make", "install"
end
end
def post_install
# Run raco setup to make sure core libraries are properly compiled.
# Sometimes the mtimes of .rkt and .zo files are messed up after a fresh
# install, making Racket take 15s to start up because interpreting is slow.
system "#{bin}/raco", "setup"
end
def caveats
<<~EOS
This is a minimal Racket distribution.
If you want to build the DrRacket IDE, you may run:
raco pkg install --auto drracket
The full Racket distribution is available as a cask:
brew install --cask racket
EOS
end
test do
output = shell_output("#{bin}/racket -e '(displayln \"Hello Homebrew\")'")
assert_match "Hello Homebrew", output
# show that the config file isn't malformed
output = shell_output("'#{bin}/raco' pkg config")
assert $CHILD_STATUS.success?
assert_match Regexp.new(<<~EOS), output
^name:
#{version}
catalogs:
https://download.racket-lang.org/releases/#{version}/catalog/
https://pkgs.racket-lang.org
https://planet-compats.racket-lang.org
default-scope:
installation
EOS
# ensure Homebrew openssl is used
if OS.mac?
output = shell_output("DYLD_PRINT_LIBRARIES=1 #{bin}/racket -e '(require openssl)' 2>&1")
assert_match(%r{.*openssl@1\.1/.*/libssl.*\.dylib}, output)
else
output = shell_output("LD_DEBUG=libs #{bin}/racket -e '(require openssl)' 2>&1")
assert_match "init: #{Formula["openssl@1.1"].opt_lib}/#{shared_library("libssl")}", output
end
end
end