forked from lfedgeai/SPEAR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (53 loc) · 1.75 KB
/
Makefile
File metadata and controls
70 lines (53 loc) · 1.75 KB
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
62
63
64
65
66
67
68
69
70
VERSION := $(shell git describe --tags --match "*" --always --dirty)
REPO_ROOT := $(shell pwd)
OUTPUT_DIR := $(REPO_ROOT)/bin
FLATC := $(shell command -v flatc 2> /dev/null)
ifndef FLATC
$(error "flatc binary not found in PATH. Please install flatc.")
endif
all: clean spearlet workload sdk
SUBDIRS := $(shell find $(REPO_ROOT) -mindepth 1 -maxdepth 3 -type d -exec test -e {}/Makefile \; -exec echo {} \; | grep -v spear-next)
WORKLOAD_SUBDIRS := $(shell find $(REPO_ROOT)/workload -mindepth 1 -maxdepth 3 -type d -exec test -e {}/Makefile \; -exec echo {} \;)
clean:
@set -ex; \
docker system prune -f || true && \
rm -rf $(OUTPUT_DIR) && \
rm -rf $(REPO_ROOT)/pkg/spear && \
for dir in $(SUBDIRS); do \
make -C $$dir clean; \
done
build: spearlet
@set -e; \
for dir in $(SUBDIRS); do \
make -C $$dir build; \
done
install_sdk: build
@set -e; \
cd $(REPO_ROOT)/sdk/python && \
file=$$(printf "%s\n" ./dist/spear-*.whl | head -n1); \
python -m pip install "$$file" --force-reinstall
spearlet: pkg/spear
go build -o $(OUTPUT_DIR)/spearlet \
-ldflags "-X 'github.com/lfedgeai/spear/pkg/common.Version=$(VERSION)'" \
$(REPO_ROOT)/cmd/spearlet/main.go
test: workload build install_sdk
@set -e; \
go test -v ./test/... && \
for dir in $(SUBDIRS); do \
make -C $$dir test; \
done
workload: build
@set -e; \
for dir in $(WORKLOAD_SUBDIRS); do \
make -C $$dir; \
done
format_python:
black $(REPO_ROOT)/; \
isort $(REPO_ROOT)/
format_golang:
gofmt -w .
format: format_python format_golang
pkg/spear:
allfiles=`find ${REPO_ROOT}/proto -name "*.fbs"`; \
$(FLATC) -o $(REPO_ROOT)/pkg/ -I ${REPO_ROOT}/proto --go-module-name "github.com/lfedgeai/spear/pkg" --go --gen-all $${allfiles}
.PHONY: all spearlet test workload clean format_python format