Skip to content

Commit

Permalink
Merge pull request #2 from fermyon/spin-formula
Browse files Browse the repository at this point in the history
Spin 1.4.1
  • Loading branch information
kate-goldenring authored Aug 23, 2023
2 parents 6b8d74c + bd58e13 commit 79dcfd9
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Formula/spin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
class Spin < Formula
desc "Open-source tool for building and running serverless WebAssembly applications"
homepage "https://spin.fermyon.dev/"
url "https://github.com/fermyon/spin.git",
tag: "v1.4.1",
revision: "e0bd9115fa51399e106681ac1c9ed1afbad1baaa"
license "Apache-2.0" => { with: "LLVM-exception" }

depends_on "cmake" => :build
depends_on "rustup-init" => [:build, :test]

uses_from_macos "zlib"

on_linux do
depends_on "pkg-config" => :build
end

def install
system "#{Formula["rustup-init"].bin}/rustup-init", "-qy", "--no-modify-path"
ENV.prepend_path "PATH", HOMEBREW_CACHE/"cargo_cache/bin"
system "rustup", "target", "add", "wasm32-wasi", "wasm32-unknown-unknown"
system "cargo", "install", *std_cargo_args

# Install default templates and plugins for language tooling and deploying apps to the cloud.
# Templates and plugins are installed into `pkgetc/"templates"` and `pkgetc/"plugins"`.
system "#{bin}/spin", "templates", "install", "--git", "https://github.com/fermyon/spin", "--upgrade"
system "#{bin}/spin", "templates", "install", "--git", "https://github.com/fermyon/spin-python-sdk", "--upgrade"
system "#{bin}/spin", "templates", "install", "--git", "https://github.com/fermyon/spin-js-sdk", "--upgrade"
system "#{bin}/spin", "plugins", "update"
system "#{bin}/spin", "plugins", "install", "js2wasm", "--yes"
system "#{bin}/spin", "plugins", "install", "py2wasm", "--yes"
system "#{bin}/spin", "plugins", "install", "cloud", "--yes"
# Set permissions for local plugins repository
chmod_R(0755, etc/"fermyon-spin/plugins")
end

test do
system "#{Formula["rustup-init"].bin}/rustup-init", "-qy", "--no-modify-path"
ENV.prepend_path "PATH", HOMEBREW_CACHE/"cargo_cache/bin"
system "rustup", "target", "add", "wasm32-wasi", "wasm32-unknown-unknown"
system bin/"spin", "new", "http-rust", "test-app", "--accept-defaults"
system bin/"spin", "build", "--from", testpath/"test-app/spin.toml"
assert_predicate testpath/"test-app/target/wasm32-wasi/release/test_app.wasm", :exist?
end
end

0 comments on commit 79dcfd9

Please sign in to comment.