-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (52 loc) · 1.57 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
62
63
64
65
SHELL := /bin/bash
ifeq ($(shell uname -s),Darwin)
CGO_CFLAGS := "-I/usr/local/include"
CGO_LDFLAGS := "-L/usr/local/lib"
endif
ifeq ($(shell uname), Linux)
export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH):/usr/local/lib
endif
define build_examples_function
@for dir in $(1)/*; do \
if [ -d "$$dir" ] && [ -f "$$dir/$$(basename $$dir).go" ]; then \
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go build -o "$$(basename $$dir)" $$dir/$$(basename $$dir).go; \
echo "Built $$dir"; \
fi \
done
endef
.PHONY: all
all: build fmt lint vet test tidy vendor test
.PHONY: build
build:
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go build ./...
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: lint
lint:
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) golangci-lint run
.PHONY: vet
vet:
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go vet -v ./...
.PHONY: test
test:
CGO_CFLAGS=$(CGO_CFLAGS) CGO_LDFLAGS=$(CGO_LDFLAGS) go test ./...
.PHONY: tidy
tidy:
go mod tidy
.PHONY: vendor
vendor:
go mod vendor
.PHONY: example
example:
$(call build_examples_function,./example)
.PHONY: furiosa-smi-go-boilerplate
furiosa-smi-go-boilerplate:
c-for-go -debug -nostamp -out pkg/smi pkg/smi/furiosa-smi.yml
go build -o clean_cgo tools/clean_cgo.go
./clean_cgo -source=pkg/smi/binding/types.go -output=pkg/smi/binding/zz_types.go
./clean_cgo -source=pkg/smi/binding/binding.go -output=pkg/smi/binding/zz_binding.go
rm -rf pkg/smi/binding/types.go
rm -rf pkg/smi/binding/binding.go
rm -rf pkg/smi/binding/cgo_helpers.go
rm clean_cgo