-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
43 lines (38 loc) · 1.68 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
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
mkfile_dir := $(dir $(mkfile_path))
build_dir := $(mkfile_dir)/build
r10e_build_dir := $(mkfile_dir)/r10e-build
GOOS ?= $(shell go version | awk '{print $$NF}' | cut -d/ -f1)
GOARCH ?= $(shell go version | awk '{print $$NF}' | cut -d/ -f2)
bin := $(build_dir)/r10edocker-$(GOOS)-$(GOARCH)
# project_name must match that in config.json
project_name := go-r10e-docker
config_file := $(mkfile_dir)/config.json
.PHONY: all build r10e-build clean
all: build
build:
mkdir -p $(build_dir)
ifndef VERSION
CGO_ENABLED=0 go build -trimpath -o $(bin) $(mkfile_dir)
else
CGO_ENABLED=0 go build -trimpath -ldflags "-X main.ver=$(VERSION)" -o $(bin) $(mkfile_dir)
endif
r10e-build: build
cp $(bin) $(build_dir)/r10edocker
$(build_dir)/r10edocker -c $(config_file)
bash $(mkfile_dir)/r10e-docker/build_container.sh
docker load -i $(mkfile_dir)/r10e-docker/out/$(project_name)-latest.tar.gz
mkdir -p $(r10e_build_dir)
$(mkfile_dir)/scripts/container_cp.sh "$(project_name):latest" \
"/app/r10edocker-linux-amd64" "$(r10e_build_dir)/r10edocker-linux-amd64"
$(mkfile_dir)/scripts/container_cp.sh "$(project_name):latest" \
"/app/r10edocker-linux-arm64" "$(r10e_build_dir)/r10edocker-linux-arm64"
$(mkfile_dir)/scripts/container_cp.sh "$(project_name):latest" \
"/app/r10edocker-darwin-amd64" "$(r10e_build_dir)/r10edocker-darwin-amd64"
$(mkfile_dir)/scripts/container_cp.sh "$(project_name):latest" \
"/app/r10edocker-darwin-arm64" "$(r10e_build_dir)/r10edocker-darwin-arm64"
cd $(r10e_build_dir) && sha256sum r10edocker-* | sort -k2 > sha256sums.r10e.txt
gzip -9 $(r10e_build_dir)/r10edocker-*
clean:
rm -rf $(build_dir)
rm -rf $(r10e_build_dir)