-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
57 lines (46 loc) · 1.65 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
CGO_ENABLED ?= 0
GOOS ?= linux
GOARCH ?= amd64
BUILD_DIR = build
TIME=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
VERSION ?= $(shell git describe --abbrev=0 --tags 2>/dev/null || echo 'v0.0.0')
COMMIT ?= $(shell git rev-parse HEAD)
EXAMPLES = addition long-addition
SERVICES = manager proplet cli proxy
define compile_service
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) \
go build -ldflags "-s -w \
-X 'github.com/absmach/magistrala.BuildTime=$(TIME)' \
-X 'github.com/absmach/magistrala.Version=$(VERSION)' \
-X 'github.com/absmach/magistrala.Commit=$(COMMIT)'" \
-o ${BUILD_DIR}/$(1) cmd/$(1)/main.go
endef
$(SERVICES):
$(call compile_service,$(@))
# Install all non-WASM executables from the build directory to GOBIN with 'propeller-' prefix
install:
$(foreach f,$(wildcard $(BUILD_DIR)/*[!.wasm]),cp $(f) $(patsubst $(BUILD_DIR)/%,$(GOBIN)/propeller-%,$(f));)
.PHONY: all $(SERVICES)
all: $(SERVICES)
clean:
rm -rf build
lint:
golangci-lint run --config .golangci.yaml
start-magistrala:
docker compose -f docker/compose.yaml up -d
stop-magistrala:
docker compose -f docker/compose.yaml down
$(EXAMPLES):
GOOS=js GOARCH=wasm tinygo build -o build/$@.wasm -target wasi examples/$@/$@.go
help:
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " build: build the binary"
@echo " install: install the binary"
@echo " all: build the binary"
@echo " clean: clean the build directory"
@echo " lint: run golangci-lint"
@echo " start-magistrala: start the magistrala docker compose"
@echo " stop-magistrala: stop the magistrala docker compose"
@echo " help: display this help message"