-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
80 lines (52 loc) · 2.29 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.PHONY: all binary static bin clean binary-static binary-local binary-local-static client client-static daemon daemon-static install
BUILDTAGS=
PROJECT=github.com/hustcat/oci-torrent
GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null)
LDFLAGS := -X github.com/hustcat/oci-torrent/version.GitCommit=${GIT_COMMIT} ${LDFLAGS}
TEST_TIMEOUT ?= 5m
TEST_SUITE_TIMEOUT ?= 10m
RUNTIME ?= runc
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
DOCKER_IMAGE := oci-torrent-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
DOCKER_RUN := docker run --privileged --rm -i $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"
export GOPATH:=$(CURDIR)/vendor:$(GOPATH)
all: binary
static: binary-static
bin:
mkdir -p bin/
clean:
rm -rf bin
binary: bin
docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t ${DOCKER_IMAGE} .
docker run --rm --security-opt label:disable -v $$(pwd):/src/github.com/hustcat/oci-torrent ${DOCKER_IMAGE} make binary-local
binary-static: bin
docker build ${DOCKER_BUILD_ARGS} -f Dockerfile.build -t ${DOCKER_IMAGE} .
docker run --rm --security-opt label:disable -v $$(pwd):/src/github.com/hustcat/oci-torrent ${DOCKER_IMAGE} make binary-static-local
binary-local: client daemon
binary-static-local: client-static daemon-static
client:
cd cmd/ctr && go build -ldflags "${LDFLAGS}" -o ../../bin/oci-torrent-ctr
client-static:
cd cmd/ctr && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../../bin/oci-torrent-ctr
daemon:
cd cmd/daemon && go build -ldflags "${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../../bin/oci-torrentd
daemon-static:
cd cmd/daemon && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../../bin/oci-torrentd
install:
cp bin/* /usr/local/bin/
protoc:
protoc -I ./api/grpc/types ./api/grpc/types/api.proto --go_out=plugins=grpc:api/grpc/types
fmt:
@gofmt -s -l . | grep -v vendor | grep -v .pb. | tee /dev/stderr
lint:
@hack/validate-lint
validate: fmt lint
uninstall:
$(foreach file,oci-torrentd ctr,rm /usr/local/bin/$(file);)