From ae387cda0eb1313b6399958d5f0bee749a28eee2 Mon Sep 17 00:00:00 2001 From: Eli Mallon Date: Fri, 15 Aug 2025 19:36:04 -0700 Subject: [PATCH] rust: working `make dev` for mac --- .golangci.yaml | 2 ++ Makefile | 10 +++++++--- rust/iroh-streamplace/meson.build | 12 ++++++++++-- util/streamplace-dev.sh | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 8ce111896..a90277745 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -7,6 +7,8 @@ linters: - -QF1003 # "could use tagged switch" - -ST1003 # "should not use underscores in Go names" - indigo's code gen makes some - -SA5008 # "unknown JSON option" doesn't care for the const stuff + - -ST1006 # receiver name should be a reflection of its identity; don't use generic names such as "this" or "self" (uniffi-bindgen-go uses this) + - -ST1005 # error strings should not be capitalized (uniffi-bindgen-go uses this) disable: - unused exclusions: diff --git a/Makefile b/Makefile index a36497a3c..d38b6ce96 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,7 @@ dev-setup-meson: .PHONY: dev-setup-meson-configure dev-setup-meson-configure: + if ! which uniffi-bindgen-go; then cargo install uniffi-bindgen-go --git https://github.com/NordSecurity/uniffi-bindgen-go --tag v0.3.0+v0.28.3; fi meson setup --default-library=shared $(BUILDDIR) $(SHARED_OPTS) meson configure --default-library=shared $(BUILDDIR) $(SHARED_OPTS) @@ -78,6 +79,7 @@ dev-setup-meson-compile: dev: cp ./util/streamplace-dev.sh $(BUILDDIR)/streamplace cargo build + $(MAKE) iroh-streamplace-codegen PKG_CONFIG_PATH=$(SHARED_PKG_CONFIG_PATH) \ LD_LIBRARY_PATH=$(SHARED_LD_LIBRARY_PATH) \ DYLD_LIBRARY_PATH=$(SHARED_DYLD_LIBRARY_PATH) \ @@ -839,6 +841,8 @@ ci-homebrew: && git commit -m "Update streamplace $(VERSION)" \ && git push -.PHONY: iroh-streamplace -iroh-streamplace: - uniffi-bindgen-go --out-dir pkg/iroh/generated --library ./target/debug/libiroh_streamplace.so +.PHONY: iroh-streamplace-codegen +iroh-streamplace-codegen: + EXT=so; \ + if [ "$(BUILDOS)" = "darwin" ]; then EXT=dylib; fi; \ + uniffi-bindgen-go --out-dir pkg/iroh/generated --library ./target/debug/libiroh_streamplace.$$EXT diff --git a/rust/iroh-streamplace/meson.build b/rust/iroh-streamplace/meson.build index 01ea4b1d8..978d6289e 100644 --- a/rust/iroh-streamplace/meson.build +++ b/rust/iroh-streamplace/meson.build @@ -3,14 +3,22 @@ prog_cargo = find_program('cargo') if get_option('default_library') == 'shared' cargo_cmd = '@0@ build'.format(prog_cargo.full_path()) + if host_machine.system() == 'darwin' + ext = 'dylib' + elif host_machine.system() == 'linux' + ext = 'so' + else + error('Unsupported dev system: @0@'.format(host_machine.system())) + endif + iroh_streamplace_dep = custom_target( 'libiroh_streamplace', input: [], - output: ['libiroh_streamplace.so'], + output: ['libiroh_streamplace.' + ext], command: [ 'sh', '-c', - 'cd "@2@/../.." && @0@ && cp "@2@/../../target/debug/libiroh_streamplace.so" "@1@/libiroh_streamplace.so"'.format(cargo_cmd, meson.current_build_dir(), meson.current_source_dir()), + 'cd "@2@/../.." && @0@ && cp "@2@/../../target/debug/libiroh_streamplace.@3@" "@1@/libiroh_streamplace.@3@"'.format(cargo_cmd, meson.current_build_dir(), meson.current_source_dir(), ext), ], build_by_default: true, ) diff --git a/util/streamplace-dev.sh b/util/streamplace-dev.sh index acb950ab0..4d04b27ee 100755 --- a/util/streamplace-dev.sh +++ b/util/streamplace-dev.sh @@ -8,6 +8,6 @@ set -euo pipefail SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) STREAMPLACE_DEV_VERSION=$(go run ./pkg/config/git/git.go -v) \ LD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib/x86_64-linux-gnu:$SCRIPT_DIR/../target/debug" \ -DYLD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib" \ +DYLD_LIBRARY_PATH="$SCRIPT_DIR/lib/usr/local/lib:$SCRIPT_DIR/../target/debug" \ SP_DEV_FRONTEND_PROXY="http://127.0.0.1:38081" \ exec "$SCRIPT_DIR/libstreamplace" "$@" -- 2.51.2