chore: daily ci improvement

This commit is contained in:
darshankabariya 2025-12-19 14:43:52 +05:30
parent 576c379ab2
commit 099ca17868
No known key found for this signature in database
GPG Key ID: 9A92CCD9899F0D22
2 changed files with 29 additions and 29 deletions

View File

@ -8,34 +8,28 @@ Go bindings for the Waku library.
go get -u github.com/logos-messaging/logos-messaging-go-bindings
```
## Dependencies
## Building & Dependencies
This repository doesn't download or build `logos-messaging-nim`. You must provide `libwaku` and its headers.
`libwaku` (from `logos-messaging-nim`) is required at compile-time. The Makefile gives you two ways to satisfy this:
To do so, you can:
- Build `libwaku` from https://github.com/logos-messaging/logos-messaging-nim.
- Point `cgo` to the headers and compiled library when building your project.
1. **Automatic clone (default)** if `LMN_DIR` is **unset**, running
```bash
make -C waku build
```
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.
Example environment setup (adjust paths to your logos-messaging-nim checkout):
```
export LMN_DIR=/path/to/logos-messaging-nim
export CGO_CFLAGS="-I${LMN_DIR}/library"
export CGO_LDFLAGS="-L${LMN_DIR}/build -lwaku -Wl,-rpath,${LMN_DIR}/build"
```
2. **Reuse an existing clone** if you already have `logos-messaging-nim` checked out, point the build to it:
```bash
export LMN_DIR=/path/to/your/logos-messaging-nim
make -C waku build
```
Existing `libwaku` artifacts under that path are reused, so this is fast for local development.
Such setup would look like this in a `Makefile`:
```Makefile
LMN_DIR ?= /path/to/logos-messaging-nim
CGO_CFLAGS = -I$(LMN_DIR)/library
CGO_LDFLAGS = -L$(LMN_DIR)/build -lwaku -Wl,-rpath,$(LMN_DIR)/build
The Makefile sets `CGO_CFLAGS` and `CGO_LDFLAGS` automatically; no extra environment is required.
build: ## Your project build command
go build ./...
```
> **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.
For a reference integration, see how `status-go` wires `CGO_CFLAGS` and `CGO_LDFLAGS` in its build setup.
NOTE: If your project is itself used as a Go dependency, all its clients will have to follow the same logos-messaging-nim setup.
---
## Development

View File

@ -48,19 +48,25 @@ check-folders:
fi
# Build SDS Go Bindings
build: build-libwaku check-folders
build: build-libwaku
@echo "Building Waku Go Bindings..."
go build ./...
# Build libwaku from the nwaku submodule
# Build libwaku once (clone if needed). Skips work when headers & libs already exist.
build-libwaku:
@echo "Building libwaku from logos-messaging-nim submodule..."
@if [ ! -d "$(LMN_DIR)" ]; then \
echo "nwaku sources not found at $(LMN_DIR), cloning shallow copy..."; \
mkdir -p $(dir $(LMN_DIR)); \
git clone --depth 1 https://github.com/logos-messaging/logos-messaging-nim.git $(LMN_DIR); \
@echo "Checking/Building libwaku ..."
@if [ -f "$(HEADER_FILE)" ] && [ -n "$(LIB_FILES)" ]; then \
echo "libwaku artifacts found, skipping build"; \
else \
if [ ! -d "$(LMN_DIR)" ]; then \
echo "No nwaku sources at $(LMN_DIR); cloning shallow copy"; \
mkdir -p $(dir $(LMN_DIR)); \
git clone --depth 1 https://github.com/logos-messaging/logos-messaging-nim.git $(LMN_DIR); \
fi; \
echo "Compiling libwaku ..."; \
$(MAKE) -C $(LMN_DIR) libwaku; \
fi
$(MAKE) -C $(LMN_DIR) libwaku
# Clean up generated files
clean: