homebrew-core/Formula/minimal-racket.rb

119 lines
4.3 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.7/racket-minimal-8.7-src.tgz"
sha256 "232ed9cf17cd7f743b2ccf73d775ec35b5af26b25e551129aeb6038bb0cdc0ec"
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_ventura: "9375edb94086199a84a020c8154decdc03423b074c7e983a36781daa5c58be7c"
sha256 arm64_monterey: "a538c529b173d438a826b88f42b76246e3735406d69ad90e3f0a323d72557416"
sha256 arm64_big_sur: "4a401845840cc499f04dd6b3183c90c2c15e3ceb0253a2ac9a1761744e059e56"
sha256 ventura: "4bd500c10f40d1fb58330f90e3d594cb51ad0b46e9033b306369e5c0991611ff"
sha256 monterey: "42f952bd64fb7bc553d1ecc8bcf2a9fa3ece19d0242cd2dc6cadca9d776f3164"
sha256 big_sur: "0500ac1f3a24a56dff09316eea8af255cd6b4106ee2ab6636bc77c1707609405"
sha256 catalina: "6989b1d87308d32f45896b4b33eb0ae74d1ab39759e272de4c9fac70caefaf78"
sha256 x86_64_linux: "65d80647f223a59f9af580f0c7853d0aed4747e8f481093b02108d65706ba73b"
end
depends_on "openssl@1.1"
uses_from_macos "libffi"
uses_from_macos "zlib"
# these two files are amended when (un)installing packages
skip_clean "lib/racket/launchers.rktd", "lib/racket/mans.rktd"
def racket_config
etc/"racket/config.rktd"
end
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
inreplace racket_config, prefix, opt_prefix
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"
return unless racket_config.read.include?(HOMEBREW_CELLAR)
ohai "Fixing up Cellar references in #{racket_config}..."
inreplace racket_config, %r{#{Regexp.escape(HOMEBREW_CELLAR)}/minimal-racket/[^/]}o, opt_prefix
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