|
| 1 | +#!/usr/bin/env ruby |
| 2 | +# SPDX-FileCopyrightText: 2023 Oxhead Alpha |
| 3 | +# SPDX-License-Identifier: LicenseRef-MIT-OA |
| 4 | + |
| 5 | +class TezosSmartRollupWasmDebugger < Formula |
| 6 | + @all_bins = [] |
| 7 | + |
| 8 | + class << self |
| 9 | + attr_accessor :all_bins |
| 10 | + end |
| 11 | + homepage "https://gitlab.com/tezos/tezos" |
| 12 | + |
| 13 | + url "https://gitlab.com/tezos/tezos.git", :tag => "v18.0-rc1", :shallow => false |
| 14 | + |
| 15 | + version "v18.0-rc1-1" |
| 16 | + |
| 17 | + build_dependencies = %w[pkg-config coreutils autoconf rsync wget rustup-init cmake] |
| 18 | + build_dependencies.each do |dependency| |
| 19 | + depends_on dependency => :build |
| 20 | + end |
| 21 | + |
| 22 | + dependencies = %w[gmp hidapi libev tezos-sapling-params] |
| 23 | + dependencies.each do |dependency| |
| 24 | + depends_on dependency |
| 25 | + end |
| 26 | + desc "Smart contract rollup wasm debugger" |
| 27 | + |
| 28 | + bottle do |
| 29 | + root_url "https://github.com/serokell/tezos-packaging/releases/download/#{TezosSmartRollupWasmDebugger.version}/" |
| 30 | + end |
| 31 | + |
| 32 | + def make_deps |
| 33 | + ENV.deparallelize |
| 34 | + ENV["CARGO_HOME"]="./.cargo" |
| 35 | + # Disable usage of instructions from the ADX extension to avoid incompatibility |
| 36 | + # with old CPUs, see https://gitlab.com/dannywillems/ocaml-bls12-381/-/merge_requests/135/ |
| 37 | + ENV["BLST_PORTABLE"]="yes" |
| 38 | + # Here is the workaround to use opam 2.0.9 because Tezos is currently not compatible with opam 2.1.0 and newer |
| 39 | + arch = RUBY_PLATFORM.include?("arm64") ? "arm64" : "x86_64" |
| 40 | + system "curl", "-L", "https://github.com/ocaml/opam/releases/download/2.0.9/opam-2.0.9-#{arch}-macos", "--create-dirs", "-o", "#{ENV["HOME"]}/.opam-bin/opam" |
| 41 | + system "chmod", "+x", "#{ENV["HOME"]}/.opam-bin/opam" |
| 42 | + ENV["PATH"]="#{ENV["HOME"]}/.opam-bin:#{ENV["PATH"]}" |
| 43 | + system "rustup-init", "--default-toolchain", "1.64.0", "-y" |
| 44 | + system "opam", "init", "--bare", "--debug", "--auto-setup", "--disable-sandboxing" |
| 45 | + system ["source .cargo/env", "make build-deps"].join(" && ") |
| 46 | + end |
| 47 | + |
| 48 | + def install_template(dune_path, exec_path, name) |
| 49 | + bin.mkpath |
| 50 | + self.class.all_bins << name |
| 51 | + system ["eval $(opam env)", "dune build #{dune_path}", "cp #{exec_path} #{name}"].join(" && ") |
| 52 | + bin.install name |
| 53 | + ln_sf "#{bin}/#{name}", "#{bin}/#{name.gsub("octez", "tezos")}" |
| 54 | + end |
| 55 | + |
| 56 | + def install |
| 57 | + make_deps |
| 58 | + install_template "src/bin_wasm_debugger/main_wasm_debugger.exe", |
| 59 | + "_build/default/src/bin_wasm_debugger/main_wasm_debugger.exe", |
| 60 | + "octez-smart-rollup-wasm-debugger" |
| 61 | + end |
| 62 | +end |
0 commit comments