BUILD CURDIR build abspath BUILD SOURCE_DIR CURDIR export GOPATH expor

 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
BUILD ?= "$(CURDIR)/build"
M = $(abspath $(BUILD))
SOURCE_DIR="${CURDIR}"
export GOPATH = ${M}
export GOBIN = ${M}/bin
export CGO_ENABLED=0
export PATH := ${M}/bin:${M}/go/bin:${PATH}
PROTOC_URL=https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protoc-3.11.3-linux-x86_64.zip
GO_URL=https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz
.PHONY: kernelbuilder kernelrequester kerneldeliveryserver
all: kernelbuilder kernelrequester kerneldeliveryserver
golang:
@\
which go; \
if [ $$? -ne 0 ]; then \
if [ ! -d ${M}/go ]; then \
wget "${GO_URL}" -O "${M}/golang.tag.gz" && \
tar -C "${M}" -zxvf "${M}/golang.tag.gz" && \
rm -rf ""${M}"/golang.tag.gz"; \
fi \
fi
protoc:
@if [ ! -f ${M}/bin/protoc ]; then \
wget ${PROTOC_URL} -O ${M}/protoc.zip; \
unzip ${M}/protoc.zip bin/protoc -d ${M} && rm -rf ${M}/protoc.zip; \
fi
dep: golang
go get -u github.com/golang/dep/cmd/dep
proto: protoc golang
mkdir -p ${M}/src/proto
GO111MODULE=on go get github.com/golang/protobuf/protoc-gen-go@v1.3.2 && chmod -R 777 ${M}/pkg/mod # БАГ НЕ ПОЗВОЛЯЮЩИЙ УДАЛИТЬ ДИРЕКТОРИЮ
PATH="${M}/bin" ${M}/bin/protoc -I ${SOURCE_DIR}/src/proto/ ${SOURCE_DIR}/src/proto/messages.proto --go_out=plugins=grpc:${M}/src/proto
dependencies: dep proto
kernelbuilder: dependencies
mkdir -p ${M}/src/kernelbuilder
ln -sf ${SOURCE_DIR}/src/kernelbuilder/* ${M}/src/kernelbuilder/
cd ${M}/src/kernelbuilder/ && dep ensure -v
go build -o ${M}/bin/kernelbuilder kernelbuilder/
kerneldeliveryserver: dependencies
mkdir -p ${M}/src/kerneldeliveryserver
ln -sf ${SOURCE_DIR}/src/kerneldeliveryserver/* ${M}/src/kerneldeliveryserver/
cd ${M}/src/kerneldeliveryserver/ && dep ensure -v
ln -sf ${M}/src/proto ${M}/src/kerneldeliveryserver/vendor/proto
go build -o ${M}/bin/kerneldeliveryserver kerneldeliveryserver
kernelrequester: dependencies
echo ${PATH}
mkdir -p ${M}/src/kernelrequester
ln -sf ${SOURCE_DIR}/src/kernelrequester/* ${M}/src/kernelrequester/
cd ${M}/src/kernelrequester/ && dep ensure -v
ln -sf ${M}/src/proto ${M}/src/kernelrequester/vendor/proto
go build -o ${M}/bin/kernelrequester kernelrequester
.PHONY: fmt
fmt:
@gofmt -s -w $(shell find ${SOURCE_DIR}/src/kerneldeliveryserver -name '*.go')
@gofmt -s -w $(shell find ${SOURCE_DIR}/src/kernelrequester -name '*.go')
@gofmt -s -w $(shell find ${SOURCE_DIR}/src/kernelbuilder -name '*.go')
clean:
rm -rf "${M}"