11.PHONY : statusgo all test clean help
22.PHONY : statusgo-ios-library statusgo-android-library
33.PHONY : build-libsds clean-libsds rebuild-libsds
4+ .PHONY : clone-storage build-storage clean-storage test-storage
5+ .PHONY : storage-help
46
57# Clear any GOROOT set outside of the Nix shell
68export GOROOT =
@@ -133,6 +135,70 @@ LIBSDS ?= $(NIM_SDS_LIB_DIR)/libsds.$(LIB_EXT)
133135CGO_CFLAGS+ =-I$(NIM_SDS_INC_DIR )
134136CGO_LDFLAGS+ =-L$(NIM_SDS_LIB_DIR ) -lsds
135137
138+ # `logos-storage` variables (opt-in)
139+ USE_LOGOS_STORAGE ?= false
140+ LOGOS_STORAGE_VERSION ?= 3c09f008bb5266a669fd19f18368f9e8b861b664
141+ LOGOS_STORAGE_SOURCE_DIR ?= $(GIT_ROOT ) /../logos-storage-nim
142+
143+ # Option 1: Provide LOGOS_STORAGE_SOURCE_DIR. Make clones it if missing.
144+ # Option 2: Provide LOGOS_STORAGE_LIB_DIR and LOGOS_STORAGE_INC_DIR.
145+ ifdef LOGOS_STORAGE_LIB_DIR
146+ ifdef LOGOS_STORAGE_INC_DIR
147+ LOGOS_STORAGE_BUILD_FROM_SOURCE := false
148+ else
149+ $(error LOGOS_STORAGE_INC_DIR must be provided when LOGOS_STORAGE_LIB_DIR is set)
150+ endif
151+ else
152+ LOGOS_STORAGE_LIB_DIR := $(LOGOS_STORAGE_SOURCE_DIR ) /build
153+ LOGOS_STORAGE_INC_DIR := $(LOGOS_STORAGE_SOURCE_DIR ) /library
154+ LOGOS_STORAGE_BUILD_FROM_SOURCE := true
155+ endif
156+
157+ LIBSTORAGE ?= $(LOGOS_STORAGE_LIB_DIR ) /libstorage.$(LIB_EXT )
158+
159+ RUNTIME_LIB_DIRS := $(NIM_SDS_LIB_DIR )
160+ LOGOS_STORAGE_BUILD_DEPS :=
161+ ifeq ($(USE_LOGOS_STORAGE ) ,true)
162+ BUILD_TAGS += use_logos_storage
163+ CGO_CFLAGS += -I$(LOGOS_STORAGE_INC_DIR)
164+ CGO_LDFLAGS += -L$(LOGOS_STORAGE_LIB_DIR) -lstorage -Wl,-rpath,$(LOGOS_STORAGE_LIB_DIR)
165+ RUNTIME_LIB_DIRS := $(LOGOS_STORAGE_LIB_DIR):$(RUNTIME_LIB_DIRS)
166+ LOGOS_STORAGE_BUILD_DEPS += $(LIBSTORAGE)
167+ endif
168+
169+ clone-storage : # #@build Clone or update logos-storage-nim
170+ ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE ) ,true)
171+ @echo "Cloning or updating logos-storage-nim ..."
172+ if [ ! -d "$(LOGOS_STORAGE_SOURCE_DIR)" ]; then \
173+ git clone --recurse-submodules https://github.com/logos-storage/logos-storage-nim.git $(LOGOS_STORAGE_SOURCE_DIR); \
174+ else \
175+ cd $(LOGOS_STORAGE_SOURCE_DIR) && git fetch --tags; \
176+ fi
177+ cd $(LOGOS_STORAGE_SOURCE_DIR) && git checkout $(LOGOS_STORAGE_VERSION) && git submodule update --init --recursive
178+ endif
179+
180+ $(LIBSTORAGE ) : clone-storage
181+ ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE ) ,true)
182+ @echo "Building logos-storage: $(LIBSTORAGE)"
183+ $(MAKE) -C $(LOGOS_STORAGE_SOURCE_DIR) libstorage
184+ endif
185+
186+ build-storage : $(LIBSTORAGE )
187+
188+ clean-storage : # #@other Remove built native libstorage artifacts
189+ ifeq ($(LOGOS_STORAGE_BUILD_FROM_SOURCE ) ,true)
190+ @rm -f "$(LOGOS_STORAGE_LIB_DIR)"/libstorage.*
191+ endif
192+
193+ test-storage : build-storage $(LIBSDS ) generate # #@tests Run logosstorage package tests via gotestsum
194+ LD_LIBRARY_PATH=" $( LOGOS_STORAGE_LIB_DIR) :$( RUNTIME_LIB_DIRS) " \
195+ CGO_LDFLAGS=" $( CGO_LDFLAGS) -L$( LOGOS_STORAGE_LIB_DIR) -lstorage -Wl,-rpath,$( LOGOS_STORAGE_LIB_DIR) " \
196+ CGO_CFLAGS=" $( CGO_CFLAGS) -I$( LOGOS_STORAGE_INC_DIR) " \
197+ gotestsum --packages=" ./services/logosstorage" -f testname -- -count 1 -tags " use_logos_storage $( BUILD_TAGS) gowaku_skip_migrations"
198+
199+ storage-help : # #@build Show logos-storage build/test toggles and env vars
200+ @cat services/logosstorage/README.md
201+
136202# mbedtls configuration for go-sqlcipher
137203ifeq ($(detected_OS ) ,Windows)
138204 # On Windows, use portable C implementations and add -Werror=implicit-function-declaration workaround
@@ -211,7 +277,7 @@ nix-purge: ##@nix Completely remove Nix setup, including /nix directory
211277all : $(GO_CMD_NAMES )
212278
213279.PHONY : $(GO_CMD_NAMES ) $(GO_CMD_PATHS ) $(GO_CMD_BUILDS )
214- $(GO_CMD_BUILDS ) : generate $(LIBSDS )
280+ $(GO_CMD_BUILDS ) : generate $(LOGOS_STORAGE_BUILD_DEPS ) $( LIBSDS )
215281$(GO_CMD_BUILDS ) : # #@build Build any Go project from cmd folder
216282 CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
217283 go build -v \
@@ -400,14 +466,14 @@ clean-generated: ##@generate Remove orphaned generated files
400466 echo " Skipping cleanup of generated files" ; \
401467 fi
402468
403- generate : PACKAGES ?= $$(go list -e ./... | grep -v "/contracts/" )
404469generate : PACKAGES ?= $$(go list -e ./... | grep -v "/contracts/" )
405470generate : GO_GENERATE_CMD ?= go tool go-generate-fast
406471generate : export GO_GENERATE_FAST_DEBUG ?= false
407472generate : export GO_GENERATE_FAST_RECACHE ?= false
408473generate : clean-generated
409474generate : # #@ Run generate for all given packages using go-generate-fast, fallback to `go generate` (e.g. for docker)
410475 @GOROOT=$$(go env GOROOT ) $(GO_GENERATE_CMD ) $(PACKAGES )
476+ @go generate -tags " use_logos_storage $( BUILD_TAGS) " ./services/logosstorage
411477
412478generate-contracts :
413479 go generate ./contracts
@@ -433,7 +499,7 @@ docker-test: ##@tests Run tests in a docker container with golang.
433499
434500test : test-unit # #@tests Run basic, short tests during development
435501
436- test-unit-prep : $(LIBSDS )
502+ test-unit-prep : $(LOGOS_STORAGE_BUILD_DEPS ) $( LIBSDS )
437503test-unit-prep : generate
438504test-unit-prep : export BUILD_TAGS ?=
439505test-unit-prep : export UNIT_TEST_DRY_RUN ?= false
@@ -444,17 +510,17 @@ test-unit-prep: export UNIT_TEST_REPORT_CODECOV ?= false
444510
445511test-unit : test-unit-prep
446512test-unit : export UNIT_TEST_RERUN_FAILS ?= true
447- test-unit : export UNIT_TEST_PACKAGES ?= $(call sh, go list ./... | \
513+ test-unit : export UNIT_TEST_PACKAGES ?= $(call sh, go list -tags ' $( BUILD_TAGS ) ' ./... | \
448514 grep -v /t/e2e | \
449515 grep -v /t/benchmarks | \
450516 grep -v /transactions/fake | \
451517 grep -v /tests-unit-network)
452518test-unit : # #@tests Run unit and integration tests
453- LD_LIBRARY_PATH=" $( NIM_SDS_LIB_DIR ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
519+ LD_LIBRARY_PATH=" $( RUNTIME_LIB_DIRS ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
454520 ./scripts/run_unit_tests.sh
455521
456522test-single : test-unit-prep
457- LD_LIBRARY_PATH=" $( NIM_SDS_LIB_DIR ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
523+ LD_LIBRARY_PATH=" $( RUNTIME_LIB_DIRS ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
458524 go test -v $(PKG ) -testify.m $(TEST )
459525
460526test-unit-network : test-unit-prep
@@ -469,15 +535,20 @@ test-unit-race: test-unit ##@tests Run unit and integration tests with -race fla
469535test-functional : generate
470536test-functional : export FUNCTIONAL_TESTS_DOCKER_UID ?= $(call sh, id -u)
471537test-functional : export FUNCTIONAL_TESTS_REPORT_CODECOV ?= false
538+ test-functional : export USE_LOGOS_STORAGE := $(USE_LOGOS_STORAGE )
472539test-functional :
473540 @./scripts/run_functional_tests.sh
474541
475542benchmark : export FUNCTIONAL_TESTS_DOCKER_UID ?= $(call sh, id -u)
476543benchmark :
477544 @./scripts/run_benchmark.sh
478545
546+ empty :=
547+ space := $(empty ) $(empty )
548+ comma := ,
549+
479550lint-panics : generate
480- GOFLAGS=-tags=' $(BUILD_TAGS), lint' \
551+ GOFLAGS=-tags=' $(subst $(space),$(comma),$(strip $(BUILD_TAGS) lint)) ' \
481552 go tool goroutine-defer-guard -test=false -target github.com/status-im/status-go/common.LogOnPanic ./...
482553
483554lint : generate lint-panics
@@ -487,7 +558,7 @@ lint:
487558lint-fix : generate
488559 golangci-lint --build-tags ' $(BUILD_TAGS) lint' run --fix ./...
489560
490- clean : # #@other Cleanup
561+ clean : clean-storage # #@other Cleanup
491562 rm -fr build/bin/*
492563
493564git-clean :
@@ -559,5 +630,5 @@ pytest-lint:
559630 $(MAKE ) -C tests-functional lint
560631
561632generate-db : # #@build Generate fake sqlite DBs in ./build directory for IDE SQL inspections
562- LD_LIBRARY_PATH=" $( NIM_SDS_LIB_DIR ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
633+ LD_LIBRARY_PATH=" $( RUNTIME_LIB_DIRS ) " CGO_LDFLAGS=" $( CGO_LDFLAGS) " CGO_CFLAGS=" $( CGO_CFLAGS) " \
563634 go run tools/generate-db/main.go -out-dir build/db
0 commit comments