-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
61 lines (49 loc) · 2 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
58
59
60
61
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 compute hello-world
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/supermq.BuildTime=$(TIME)' \
-X 'github.com/absmach/supermq.Version=$(VERSION)' \
-X 'github.com/absmach/supermq.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) $(EXAMPLES)
all: $(SERVICES) $(EXAMPLES)
clean:
rm -rf build
lint:
golangci-lint run --config .golangci.yaml
start-supermq:
docker compose -f docker/compose.yaml --env-file docker/.env up -d
stop-supermq:
docker compose -f docker/compose.yaml --env-file docker/.env down
$(EXAMPLES):
GOOS=js GOARCH=wasm tinygo build -no-debug -panic=trap -scheduler=none -gc=leaking -o build/[email protected] -target wasi examples/$@/[email protected]
addition-wat:
@wat2wasm examples/addition-wat/addition.wat -o build/addition-wat.wasm
@base64 build/addition-wat.wasm > build/addition-wat.b64
help:
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@echo " <service>: build the binary for the service i.e manager, proplet, cli"
@echo " all: build all binaries i.e manager, proplet, cli"
@echo " install: install the binary i.e copies to GOBIN"
@echo " clean: clean the build directory"
@echo " lint: run golangci-lint"
@echo " start-supermq: start the supermq docker compose"
@echo " stop-supermq: stop the supermq docker compose"
@echo " help: display this help message"