diff --git a/README.md b/README.md index d9252e6..626cebb 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,22 @@ go get -u github.com/logos-messaging/logos-messaging-go-bindings export CGO_LDFLAGS="-L${LMN_DIR}/build -lwaku -Wl,-rpath,${LMN_DIR}/build" # compile all packages - go build ./waku + make -C waku build # run all tests - go test ./waku + make -C waku test # run a specific test - go test ./waku -count=1 -run TestConnectedPeersInfo -v + make -C waku test TEST=TestConnectedPeersInfo ``` 2. **Automatic clone (default)** – if `LMN_DIR` is **unset**, running ```bash - make -C waku build + make -C waku build-auto + make -C waku test-auto + make -C waku test-auto TEST=TestConnectedPeersInfo ``` + will clone a shallow copy of `logos-messaging-nim` into `third_party/nwaku`, build `libwaku`, and compile the Go bindings. This is what CI uses. > **Downstream projects**: When importing `logos-messaging-go-bindings` in another Go module you must ensure `LMN_DIR` is exported (or vendor `libwaku`) before running `go build`. Otherwise the CGO step will fail. diff --git a/waku/Makefile b/waku/Makefile index e33fe63..8300865 100644 --- a/waku/Makefile +++ b/waku/Makefile @@ -1,7 +1,7 @@ # Makefile for Waku Go Bindings # Path to logos-messaging-nim (nwaku) submodule -LMN_DIR ?= $(shell pwd)/../vendor/logos-messaging-nim/ +LMN_DIR ?= $(shell pwd)/../vendor/logos-messaging-nim # Default paths for libwaku library and headers (can be overridden) LIBWAKU_HEADER_PATH ?= $(LMN_DIR)/library @@ -14,7 +14,7 @@ export CGO_LDFLAGS := -L$(LIBWAKU_LIB_PATH)/ -lwaku -Wl,-rpath,$(LIBWAKU_LIB_PAT HEADER_FILE := $(LIBWAKU_HEADER_PATH)/libwaku.h LIB_FILES := $(wildcard $(LIBWAKU_LIB_PATH)/libwaku.*) -.PHONY: all clean prepare build build-auto build-manual test-auto test-manual build-libwaku +.PHONY: all clean prepare build test build-auto test-auto build-libwaku # Validate necessary folders and files check-folders: @@ -58,21 +58,30 @@ build-libwaku: $(MAKE) -C $(LMN_DIR) libwaku; \ fi +build: build-libwaku check-folders + @echo "Building Waku Go Bindings (manual)..." + go build ./waku + +test: build + @echo "Running tests (manual)..." + @if [ -z "$(TEST)" ]; then \ + go test ./waku; \ + else \ + go test ./waku -count=1 -run $(TEST) -v; \ + fi + build-auto: build-libwaku check-folders @echo "Building Waku Go Bindings (auto)..." go build ./ -build-manual: build-libwaku check-folders - @echo "Building Waku Go Bindings (manual)..." - go build ./waku - test-auto: build-auto @echo "Running tests (auto)..." - go test ./ + @if [ -z "$(TEST)" ]; then \ + go test ./...; \ + else \ + go test ./ -count=1 -run $(TEST) -v; \ + fi -test-manual: build-manual - @echo "Running tests (manual)..." - go test ./waku # Clean up generated files clean: