forked from tjfoc/fabric-ca-gm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
171 lines (135 loc) · 4.8 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Copyright IBM Corp All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -------------------------------------------------------------
# This makefile defines the following targets
#
# - all (default) - builds all targets and runs all tests
# - license - check all go files for license headers
# - fabric-ca-server - builds the fabric-ca-server executable
# - fabric-ca-client - builds the fabric-ca-client executable
# - unit-tests - Performs checks first and runs the go-test based unit tests
# - checks - runs all check conditions (license, format, imports, lint and vet)
# - docker[-clean] - ensures all docker images are available[/cleaned]
# - clean - cleans the build area
PROJECT_NAME = fabric-ca
BASE_VERSION = 1.0.3
PREV_VERSION = 1.0.2
IS_RELEASE = false
ifneq ($(IS_RELEASE),true)
EXTRA_VERSION ?= snapshot-$(shell git rev-parse --short HEAD)
PROJECT_VERSION=$(BASE_VERSION)-$(EXTRA_VERSION)
else
PROJECT_VERSION=$(BASE_VERSION)
endif
ARCH=$(shell uname -m)
ifeq ($(ARCH),s390x)
PGVER=9.4
else
PGVER=9.5
endif
BASEIMAGE_RELEASE = 0.3.1
PKGNAME = github.com/hyperledger/$(PROJECT_NAME)
DOCKER_ORG = hyperledger
IMAGES = $(PROJECT_NAME)
FVTIMAGE = $(PROJECT_NAME)-fvt
path-map.fabric-ca-client := ./cmd/fabric-ca-client
path-map.fabric-ca-server := ./cmd/fabric-ca-server
include docker-env.mk
all: rename fabric-ca-server fabric-ca-client
rename: .FORCE
@scripts/rename-repo
docker: $(patsubst %,build/image/%/$(DUMMY), $(IMAGES))
docker-fvt: $(patsubst %,build/image/%/$(DUMMY), $(FVTIMAGE))
changelog:
./scripts/changelog.sh v$(PREV_VERSION) HEAD v$(BASE_VERSION)
checks: vet lint format imports
license: .FORCE
@scripts/check_license
format: .FORCE
@scripts/check_format
imports: .FORCE
@scripts/check_imports
lint: .FORCE
@scripts/check_lint
vet: .FORCE
@scripts/check_vet
fabric-ca-client: bin/fabric-ca-client
fabric-ca-server: bin/fabric-ca-server
bin/%:
@echo "Building ${@F} in bin directory ..."
@mkdir -p bin && go build -o bin/${@F} $(path-map.${@F})
@echo "Built bin/${@F}"
# We (re)build a package within a docker context but persist the $GOPATH/pkg
# directory so that subsequent builds are faster
build/docker/bin/%:
@echo "Building $@"
@mkdir -p $(@D) build/docker/$(@F)/pkg
@$(DRUN) \
-v $(abspath build/docker/bin):/opt/gopath/bin \
-v $(abspath build/docker/$(@F)/pkg):/opt/gopath/pkg \
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) \
go install -ldflags "$(DOCKER_GO_LDFLAGS)" $(PKGNAME)/$(path-map.${@F})
@touch $@
build/docker/busybox:
@echo "Building $@"
@$(DRUN) \
hyperledger/fabric-baseimage:$(BASE_DOCKER_TAG) \
make -f busybox/Makefile install BINDIR=$(@D)
build/image/%/$(DUMMY): Makefile build/image/%/payload
$(eval TARGET = ${patsubst build/image/%/$(DUMMY),%,${@}})
$(eval DOCKER_NAME = $(DOCKER_ORG)/$(TARGET))
@echo "Building docker $(TARGET) image"
@cat images/$(TARGET)/Dockerfile.in \
| sed -e 's/_BASE_TAG_/$(BASE_DOCKER_TAG)/g' \
| sed -e 's/_TAG_/$(DOCKER_TAG)/g' \
| sed -e 's/_PGVER_/$(PGVER)/g' \
> $(@D)/Dockerfile
$(DBUILD) -t $(DOCKER_NAME) $(@D)
docker tag $(DOCKER_NAME) $(DOCKER_NAME):$(DOCKER_TAG)
@touch $@
build/image/fabric-ca/payload: \
build/docker/bin/fabric-ca-client \
build/docker/bin/fabric-ca-server \
build/fabric-ca.tar.bz2
build/image/fabric-ca-fvt/payload: \
build/docker/bin/fabric-ca-client \
build/docker/bin/fabric-ca-server \
images/fabric-ca-fvt/base.ldif \
images/fabric-ca-fvt/add-users.ldif \
images/fabric-ca-fvt/start.sh
build/image/%/payload:
@echo "Copying $^ to $@"
mkdir -p $@
cp $^ $@
build/fabric-ca.tar.bz2: $(shell git ls-files images/fabric-ca/payload)
build/%.tar.bz2:
@echo "Building $@"
@tar -jc -C images/$*/payload $(notdir $^) > $@
unit-tests: checks fabric-ca-server fabric-ca-client
@scripts/run_tests
container-tests: docker
fvt-tests:
@scripts/run_fvt_tests
ci-tests: docker-clean docker-fvt unit-tests
@docker run -v $(shell pwd):/opt/gopath/src/github.com/hyperledger/fabric-ca hyperledger/fabric-ca-fvt
%-docker-clean:
$(eval TARGET = ${patsubst %-docker-clean,%,${@}})
-docker images -q $(DOCKER_ORG)/$(TARGET):latest | xargs -I '{}' docker rmi -f '{}'
-@rm -rf build/image/$(TARGET) ||:
docker-clean: $(patsubst %,%-docker-clean, $(IMAGES) $(PROJECT_NAME)-fvt)
@rm -rf build/docker/bin/* ||:
.PHONY: clean
clean: docker-clean
-@rm -rf build bin ||:
.FORCE: