homebrew-core/Formula/minimal-racket.rb
2019-02-01 13:31:50 +08:00

75 lines
2.2 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/7.2/racket-minimal-7.2-src-builtpkgs.tgz"
sha256 "dd75401824b877964b70d8b475b05f424721f72015f41d5ae6c508b60dab3ad5"
bottle do
cellar :any
sha256 "ab2fab8e8e2363ed71b7720d82642993a1aaac3ba2dc50155da932b2f990224f" => :mojave
sha256 "fbd8113cd50ee9bb0621ff1a0b23f8f9863c5ecebb548a7b09a9ad338d5f25c3" => :high_sierra
sha256 "4820d0e8e2b784d65aa1f512e96e8f64746a25f07e04c0a2a5970cbb241213b6" => :sierra
end
# these two files are amended when (un)installing packages
skip_clean "lib/racket/launchers.rktd", "lib/racket/mans.rktd"
def install
cd "src" do
args = %W[
--disable-debug
--disable-dependency-tracking
--enable-macprefix
--prefix=#{prefix}
--man=#{man}
--sysconfdir=#{etc}
]
system "./configure", *args
system "make"
system "make", "install"
end
# configure racket's package tool (raco) to do the Right Thing
# see: https://docs.racket-lang.org/raco/config-file.html
inreplace etc/"racket/config.rktd" do |s|
s.gsub!(
/\(bin-dir\s+\.\s+"#{Regexp.quote(bin)}"\)/,
"(bin-dir . \"#{HOMEBREW_PREFIX}/bin\")",
)
s.gsub!(
/\n\)$/,
"\n (default-scope . \"installation\")\n)",
)
end
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 cask install 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
end
end