quantus-cli 1.4.0

Command line interface and library for interacting with the Quantus Network
---
name: macos dependencies
description: installs dependencies required to compile quantus-cli on macos

runs:
  using: composite
  steps:
    - name: rust compilation prerequisites (macos)
      run: |
        brew update
        OK=0
        for i in 1 2 3; do
          if brew install protobuf llvm; then OK=1; break; fi
          echo "brew install attempt $i failed (often transient ghcr.io), retrying in 15s..."
          sleep 15
        done
        if [ "$OK" -ne 1 ]; then echo "::error::brew install protobuf llvm failed after 3 attempts"; exit 1; fi
        curl https://sh.rustup.rs -sSf | sh -s -- -y
        brew uninstall cmake
        set +e
        brew install openssl cmake 2>&1 | sed '/already installed and up-to-date/d'
        brew_status=${PIPESTATUS[0]}
        set -e
        
        if [ "$brew_status" -ne 0 ]; then
          exit "$brew_status"
        fi
        
        rustup toolchain install
        rustup target add wasm32-unknown-unknown
        rustup component add rustfmt --toolchain nightly
        rustup component add clippy rust-src
      shell: bash
    - name: Set LIBCLANG_PATH for clang-sys (bindgen/rocksdb etc.)
      run: |
        # Homebrew LLVM provides libclang.dylib; clang-sys looks for libclang.dylib.
        # ARM (Apple Silicon): /opt/homebrew/opt/llvm/lib
        # x86 (Intel):         /usr/local/opt/llvm/lib
        DIR=
        if command -v brew >/dev/null 2>&1; then
          PREFIX="$(brew --prefix llvm 2>/dev/null)"
          [ -n "$PREFIX" ] && [ -d "$PREFIX/lib" ] && ls "$PREFIX/lib"/libclang*.dylib 1>/dev/null 2>&1 && DIR="$PREFIX/lib"
        fi
        if [ -z "$DIR" ] && [ -d /usr/local/opt/llvm/lib ] && ls /usr/local/opt/llvm/lib/libclang*.dylib 1>/dev/null 2>&1; then
          DIR=/usr/local/opt/llvm/lib
        fi
        if [ -z "$DIR" ] && [ -d /opt/homebrew/opt/llvm/lib ] && ls /opt/homebrew/opt/llvm/lib/libclang*.dylib 1>/dev/null 2>&1; then
          DIR=/opt/homebrew/opt/llvm/lib
        fi
        if [ -n "$DIR" ]; then
          echo "LIBCLANG_PATH=$DIR" >> $GITHUB_ENV
        fi
        echo "LIBCLANG_PATH=${LIBCLANG_PATH:-not set}"
      shell: bash