Simplify sds Makefile as we assume existing libsds library and header

This commit is contained in:
Ivan Folgueira Bande 2025-11-25 17:00:43 +01:00
parent e78f763079
commit 68a4845a10
No known key found for this signature in database
GPG Key ID: 3C117481F89E24A7

View File

@ -1,50 +1,53 @@
# Makefile for SDS Go Bindings
# The NIM_SDS_LIB_PATH and NIM_SDS_HEADER_PATH env vars should be defined beforehand
# Therefore, we assume the libsds library and headers are located in the specified paths
export CGO_CFLAGS="-I${NIM_SDS_HEADER_PATH}/"
export CGO_LDFLAGS="-L${NIM_SDS_LIB_PATH}/ -lsds -Wl,-rpath,${NIM_SDS_LIB_PATH}/"
# Expected files
HEADER_FILE := $(NIM_SDS_HEADER_PATH)/libsds.h
LIB_FILES := $(wildcard $(NIM_SDS_LIB_PATH)/libsds.*)
.PHONY: all clean prepare build-libsds build
# Default target
all: build
# Prepare third_party directory and clone nim-sds
prepare:
@echo "Preparing third_party directory..."
@mkdir -p ../third_party
@echo "Setting up nim-sds..."
@if [ ! -d "../third_party/nim-sds/.git" ]; then \
echo "Cloning nim-sds repository..."; \
git clone https://github.com/waku-org/nim-sds ../third_party/nim-sds; \
else \
echo "nim-sds repository already exists."; \
# Validate necessary folders and files
check-folders:
@echo Checking header directory ...
@if [ -z "$(NIM_SDS_HEADER_PATH)" ]; then \
echo "ERROR: NIM_SDS_HEADER_PATH not set"; exit 1; \
fi
@if [ ! -d "$(NIM_SDS_HEADER_PATH)" ]; then \
echo "ERROR: Header path does not exist: $(NIM_SDS_HEADER_PATH)"; exit 1; \
fi
@echo "Updating nim-sds to get vendors and compile nim in nimbus-build-system..."
@cd ../third_party/nim-sds && \
git fetch origin && \
git checkout master && \
git pull origin master && \
echo "Running 'make update'..." && \
make update
@echo Checking lib directory ...
@if [ -z "$(NIM_SDS_LIB_PATH)" ]; then \
echo "ERROR: NIM_SDS_LIB_PATH not set"; exit 1; \
fi
@if [ ! -d "$(NIM_SDS_LIB_PATH)" ]; then \
echo "ERROR: Library path does not exist: $(NIM_SDS_LIB_PATH)"; exit 1; \
fi
@echo Checking for libsds.h ...
@if [ ! -f "$(HEADER_FILE)" ]; then \
echo "ERROR: libsds.h not found at: $(HEADER_FILE)"; exit 1; \
fi
@echo Checking for libsds library file ...
@if [ -z "$(LIB_FILES)" ]; then \
echo "ERROR: No libsds library file found in: $(NIM_SDS_LIB_PATH)"; exit 1; \
fi
# Build SDS Go Bindings
build: prepare
@echo "Building libsds..."
@cd ../third_party/nim-sds && make libsds
build: check-folders
@echo "Building SDS Go Bindings..."
go build ./...
build-android: prepare
@echo "Building libsds for Android..."
@cd ../third_party/nim-sds && make libsds-android
@echo "Building SDS Go Bindings for Android..."
go build ./...
# Clean up generated files
clean:
@echo "Cleaning up..."
@rm -rf ../third_party/
@rm -f sds-go-bindings