From 2dfb48b538bb2c9c33292a93b74567e43c227858 Mon Sep 17 00:00:00 2001 From: "@RandyMcMillan" Date: Sat, 28 Jun 2025 03:14:54 -0400 Subject: [PATCH] build tooling (#69) * script/macos:add * script/linux:add libx11-dev * Cargo.toml:pin nostr nostr-sdk nostr nostr-connect --------- Co-authored-by: reya <123083837+reyamir@users.noreply.github.com> --- .github/workflows/rust.yml | 30 ++++++++++++++++++++++ Cargo.lock | 8 ++++++ rust-toolchain.toml | 10 -------- script/linux | 1 + script/macos | 51 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/rust.yml delete mode 100644 rust-toolchain.toml create mode 100755 script/macos diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 00000000..ed4e51f9 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,30 @@ +name: Rust + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "m**" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + rustup: [stable, nightly] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: script/linux + run: chmod +x ./script/linux && ./script/linux + if: matrix.os == 'ubuntu-latest' + #- name: cargo update + # run: cargo update + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose diff --git a/Cargo.lock b/Cargo.lock index aa8aed41..8a2eb66a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3601,6 +3601,7 @@ checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" name = "nostr" version = "0.42.1" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "aes", "base64", @@ -3612,6 +3613,7 @@ dependencies = [ "chacha20poly1305", "getrandom 0.2.16", "instant", + "regex", "reqwest 0.12.20", "scrypt", "secp256k1", @@ -3625,6 +3627,7 @@ dependencies = [ name = "nostr-connect" version = "0.42.0" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "async-utility", "nostr", @@ -3637,6 +3640,7 @@ dependencies = [ name = "nostr-database" version = "0.42.0" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "flatbuffers", "lru", @@ -3648,6 +3652,7 @@ dependencies = [ name = "nostr-lmdb" version = "0.42.0" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "async-utility", "heed", @@ -3661,6 +3666,7 @@ dependencies = [ name = "nostr-relay-pool" version = "0.42.0" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "async-utility", "async-wsocket", @@ -3677,6 +3683,7 @@ dependencies = [ name = "nostr-sdk" version = "0.42.0" source = "git+https://github.com/rust-nostr/nostr#ecf711ee9f3bca83c2a31a1de0f2977cd2845af5" + dependencies = [ "async-utility", "nostr", @@ -3684,6 +3691,7 @@ dependencies = [ "nostr-lmdb", "nostr-relay-pool", "tokio", + "tracing", ] [[package]] diff --git a/rust-toolchain.toml b/rust-toolchain.toml deleted file mode 100644 index 42e14d91..00000000 --- a/rust-toolchain.toml +++ /dev/null @@ -1,10 +0,0 @@ -[toolchain] -channel = "1.87" -profile = "minimal" -components = ["rustfmt", "clippy"] -targets = [ - "x86_64-apple-darwin", - "aarch64-apple-darwin", - "x86_64-unknown-linux-gnu", - "x86_64-pc-windows-msvc", -] diff --git a/script/linux b/script/linux index 215dd8bd..0a51acc8 100644 --- a/script/linux +++ b/script/linux @@ -34,6 +34,7 @@ if [[ -n $apt ]]; then libzstd-dev libvulkan1 libgit2-dev + libx11-dev make cmake clang diff --git a/script/macos b/script/macos new file mode 100755 index 00000000..7291fd7b --- /dev/null +++ b/script/macos @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -xeuo pipefail + +export HOMEBREW_NO_INSTALL_CLEANUP=1 + +# if root or if sudo/unavailable, define an empty variable +if [ "$(id -u)" -eq 0 ] +then maysudo='' +else maysudo="$(command -v sudo || command -v doas || true)" +fi + +function finalize { + # after packages install (curl, etc), get the rust toolchain + which rustup > /dev/null 2>&1 || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + # verify the mold situation + if ! command -v mold >/dev/null 2>&1; then + echo "Warning: Mold binaries are unavailable on your system." >&2 + echo " Builds will be slower without mold. Try: script/install-mold" >&2 + fi + echo "Finished installing MacOS dependencies with script/macos" +} + +# MacOS +brew=$(command -v brew || true) +if [[ -n $brew ]]; then + deps=( + gcc + libx11 + libxkbcommon + openssl + zstd + vulkan-headers + libgit2 + libx11 + make + cmake + jq + git + curl + gettext + ) + + $brew update + for dep in "${deps[@]}";do + $brew search "$dep"; + done + $brew install "${deps[@]}" + finalize + exit 0 +fi