Skip to content

Commit

Permalink
Merge pull request #11 from unisonweb/racket-as-resource
Browse files Browse the repository at this point in the history
  • Loading branch information
aryairani authored Sep 24, 2024
2 parents 91b972f + 016cb3b commit 7b55af7
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 20 deletions.
45 changes: 35 additions & 10 deletions unison-language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ class UnisonLanguage < Formula
license "MIT"

version_scheme 1
revision 1

if OS.mac?
on_macos do
url "https://github.com/unisonweb/unison/releases/download/release%2F0.5.26/ucm-macos.tar.gz"
sha256 "445d90e6c0b14fd17720633ff143fa6c47bdb0e8eda4c5581d112e00f3b387c8"
head "https://github.com/unisonweb/unison/releases/download/trunk-build/ucm-macos.tar.gz"
elsif OS.linux?
end

on_linux do
url "https://github.com/unisonweb/unison/releases/download/release%2F0.5.26/ucm-linux.tar.gz"
sha256 "b74adcd5fe0f7e31d1bbfb73a16f2c27fe91d0a05b6103e2587aac21aa9cf926"
head "https://github.com/unisonweb/unison/releases/download/trunk-build/ucm-linux.tar.gz"
end
end

option "with-compile-native", "experimental support for `compile.native`"
depends_on "minimal-racket" if build.with? "compile-native"
depends_on "fzf" => :recommended

def install
Expand All @@ -25,18 +27,41 @@ def install
pkgshare.install "ui"

if build.with? "compile-native"
pkgshare.install "racket"
ENV["PLTUSERHOME"] = pkgshare/"racket"/"home"
resource "minimal-racket" do
if OS.linux?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-x86_64-linux-cs.tgz"
sha256 "a1b5cab3adee21cd00219c7e85315c945db4eab11a6c80653db7687b11c993f0"
elsif OS.mac?
if Hardware::CPU.intel?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-x86_64-macosx-cs.tgz"
sha256 "168644f90c09b5474a84293e0f81a4b9b2c165cdabb3a5e595953f6b956ec1ed"
elsif Hardware::CPU.arm?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-aarch64-macosx-cs.tgz"
sha256 "5d3e0c94668889ffb744fa99f7e787b1352de6b30587665cf0a80d34f02e421a"
end
else
odie "Unsupported OS"
end
end

resource("minimal-racket").stage do
(libexec/"racket").install Dir["*"]
end

raco = "#{libexec}/racket/bin/raco"

ohai "Installing Racket unison library"
ohai "#{pkgshare}/racket/unison.zip"
system "raco", "pkg", "install", "--scope", "user", "--auto", "#{pkgshare}/racket/unison.zip"
pkgshare.install "racket"
jitlib = "#{pkgshare}/racket/unison.zip"
system raco, "pkg", "install", "--scope", "installation", "--auto", jitlib

ohai "Installing Racket compiler-lib library"
system "raco", "pkg", "install", "--scope", "user", "--auto", "--skip-installed", "compiler-lib"
system raco, "pkg", "install", "--scope", "installation", "--auto", "--skip-installed", "compiler-lib"

(bin/"ucm").write <<~EOS
#!/bin/bash
export PLTUSERHOME="#{pkgshare}/racket/home"
PATH="#{opt_libexec}/racket/bin:$PATH" \\
UCM_WEB_UI="#{pkgshare}/ui" \\
#{opt_libexec}/unison \\
--runtime-path #{opt_libexec}/runtime/bin/unison-runtime \\
Expand Down
44 changes: 34 additions & 10 deletions unison-language.template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ class UnisonLanguage < Formula

version_scheme 1

if OS.mac?
on_macos do
url "https://github.com/unisonweb/unison/releases/download/release%2F${version}/ucm-macos.tar.gz"
sha256 "${macos_sha}"
head "https://github.com/unisonweb/unison/releases/download/trunk-build/ucm-macos.tar.gz"
elsif OS.linux?
end

on_linux do
url "https://github.com/unisonweb/unison/releases/download/release%2F${version}/ucm-linux.tar.gz"
sha256 "${linux_sha}"
head "https://github.com/unisonweb/unison/releases/download/trunk-build/ucm-linux.tar.gz"
end
end

option "with-compile-native", "experimental support for `compile.native`"
depends_on "minimal-racket" if build.with? "compile-native"
depends_on "fzf" => :recommended

def install
Expand All @@ -25,18 +26,41 @@ def install
pkgshare.install "ui"

if build.with? "compile-native"
pkgshare.install "racket"
ENV["PLTUSERHOME"] = pkgshare/"racket"/"home"
resource "minimal-racket" do
if OS.linux?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-x86_64-linux-cs.tgz"
sha256 "a1b5cab3adee21cd00219c7e85315c945db4eab11a6c80653db7687b11c993f0"
elsif OS.mac?
if Hardware::CPU.intel?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-x86_64-macosx-cs.tgz"
sha256 "168644f90c09b5474a84293e0f81a4b9b2c165cdabb3a5e595953f6b956ec1ed"
elsif Hardware::CPU.arm?
url "https://download.racket-lang.org/releases/8.14/installers/racket-minimal-8.14-aarch64-macosx-cs.tgz"
sha256 "5d3e0c94668889ffb744fa99f7e787b1352de6b30587665cf0a80d34f02e421a"
end
else
odie "Unsupported OS"
end
end

resource("minimal-racket").stage do
(libexec/"racket").install Dir["*"]
end

raco = "#{libexec}/racket/bin/raco"

ohai "Installing Racket unison library"
ohai "#{pkgshare}/racket/unison.zip"
system "raco", "pkg", "install", "--scope", "user", "--auto", "#{pkgshare}/racket/unison.zip"
pkgshare.install "racket"
jitlib = "#{pkgshare}/racket/unison.zip"
system raco, "pkg", "install", "--scope", "installation", "--auto", jitlib

ohai "Installing Racket compiler-lib library"
system "raco", "pkg", "install", "--scope", "user", "--auto", "--skip-installed", "compiler-lib"
system raco, "pkg", "install", "--scope", "installation", "--auto", "--skip-installed", "compiler-lib"

(bin/"ucm").write <<~EOS
#!/bin/bash
export PLTUSERHOME="#{pkgshare}/racket/home"
PATH="#{opt_libexec}/racket/bin:$PATH" \\
UCM_WEB_UI="#{pkgshare}/ui" \\
#{opt_libexec}/unison \\
--runtime-path #{opt_libexec}/runtime/bin/unison-runtime \\
Expand Down

0 comments on commit 7b55af7

Please sign in to comment.