Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (74 loc) · 2.51 KB
/
Copy pathMakefile
File metadata and controls
94 lines (74 loc) · 2.51 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Copyright 2014 Canonical Ltd.
# Licensed under the AGPLv3, see LICENCE file for details.
# Makefile for the candid identity service.
GIT_COMMIT := $(shell git rev-parse --verify HEAD)
GIT_VERSION := $(shell git describe --dirty)
GO_VERSION := $(shell go list -f {{.GoVersion}} -m)
ARCH := $(shell dpkg --print-architecture)
DEPENDENCIES := build-essential bzr
SNAP_DEPENDENCIES := go snapcraft
default: build
build: version/init.go
go build ./...
check: version/init.go
go test ./...
install: version/init.go
go install $(INSTALL_FLAGS) -v ./...
clean:
go clean ./...
-$(RM) version/init.go
-snapcraft clean
# Reformat source files.
format:
gofmt -w -l .
# Reformat and simplify source files.
simplify:
gofmt -w -l -s .
candidsrv: version/init.go
go build ./cmd/candidsrv
# Run the candid server.
server: candidsrv
./candidsrv cmd/candidsrv/config.yaml
# Generate version information
version/init.go: version/init.go.tmpl FORCE
gofmt -r "unknownVersion -> Version{GitCommit: \"${GIT_COMMIT}\", Version: \"${GIT_VERSION}\",}" $< >$@
# Generate snaps
candid_$(GIT_VERSION)_$(ARCH).snap:
snapcraft
RELEASE_BINARY_PACKAGES=./cmd/candidsrv
.PHONY: deploy
deploy: candid_$(GIT_VERSION)_$(ARCH).snap
$(MAKE) -C charm build
juju deploy -v ./charm/build/candid --resource candid=candid_$(GIT_VERSION)_$(ARCH).snap
# Install packages required to develop the candid service and run tests.
APT_BASED := $(shell command -v apt-get >/dev/null; echo $$?)
sysdeps:
ifeq ($(APT_BASED),0)
@echo Installing dependencies
@sudo apt-get update
@sudo apt-get -y install $(DEPENDENCIES)
@sudo snap install $(SNAP_DEPENDENCIES)
else
@echo sysdeps runs only on systems with apt-get
@echo on OS X with homebrew try: brew install bazaar mongodb
endif
image:
DOCKER_BUILDKIT=1 \
docker build \
--build-arg="GIT_COMMIT=$(GIT_COMMIT)" \
--build-arg="VERSION=$(GIT_VERSION)" \
--build-arg="GO_VERSION=$(GO_VERSION)" \
--build-arg="ARCH=$(ARCH)" \
. -f ./Dockerfile -t candid
help:
@echo -e 'Identity service - list of make targets:\n'
@echo 'make - Build the package.'
@echo 'make check - Run tests.'
@echo 'make install - Install the package.'
@echo 'make server - Start the candid server.'
@echo 'make clean - Remove object files from package source directories.'
@echo 'make sysdeps - Install the development environment system packages.'
@echo 'make format - Format the source files.'
@echo 'make simplify - Format and simplify the source files.'
.PHONY: build check install clean format server simplify snap sysdeps help FORCE
FORCE: