-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (50 loc) · 1.17 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
# Makefile for OCPP Example project
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD)fmt
# Folders definitions
BINARY_FOLDER=bin
# Get a short hash of the git had for building images.
VERSION = 1.0
TAG = $$(git rev-parse --short HEAD)
APP_NAME=golib
IMAGE_NAME = "${APP_NAME}"
DOCKERFILE = "Dockerfile"
PROJECT_PATH = $(shell pwd)
define docker-build =
docker build -t ${IMAGE_NAME}:${VERSION} -f ${DOCKERFILE} .
docker run --rm \
--name toolbox-golib-tests \
-v ${PROJECT_PATH}:/go/golib \
${IMAGE_NAME}:${VERSION} \
make -C /go/golib $(1)
endef
define docker-run =
docker run --rm \
--name toolbox-golib-tests \
-v ${PROJECT_PATH}:/go/golib \
${IMAGE_NAME}:${VERSION} \
$(1)
endef
fmts:
$(GOFMT) -w -s -d ./timelib/*.go
$(GOFMT) -w -s -d ./logging/*.go
$(GOFMT) -w -s -d ./tools/*.go
test:
@CGO_ENABLED=0 $(GOTEST) -v ./...
modinit:
$(GOMOD) init github.com/CoderSergiy/golib
clean:
$(GOCLEAN)
rm -rf $(BINARY_FOLDER)
testlib: fmts test
# Command using Docker container
dockerclean:
$(call docker-build, "clean")
dockertest:
$(call docker-build, "testlib")