14
14
15
15
# Build the node-problem-detector image.
16
16
17
- .PHONY : all build-container build-tar build push-container push-tar push \
18
- clean vet fmt version \
19
- Dockerfile build-binaries docker-builder build-in-docker
17
+ .PHONY : all \
18
+ vet fmt version test e2e-test \
19
+ build-binaries build-container build-tar build \
20
+ docker-builder build-in-docker push-container push-tar push clean
20
21
21
22
all : build
22
23
24
+ # PLATFORMS is the set of OS_ARCH that NPD can build against.
25
+ PLATFORMS =linux_amd64 windows_amd64
26
+
23
27
# VERSION is the version of the binary.
24
28
VERSION? =$(shell if [ -d .git ]; then echo `git describe --tags --dirty`; else echo "UNKNOWN"; fi)
25
29
48
52
# PARALLEL specifies the number of parallel test nodes to run for e2e tests.
49
53
PARALLEL? =3
50
54
55
+ NPD_NAME_VERSION? =node-problem-detector-$(VERSION )
51
56
# TARBALL is the name of release tar. Include binary version by default.
52
- TARBALL? =node-problem-detector- $( VERSION ) .tar.gz
57
+ TARBALL = $( NPD_NAME_VERSION ) .tar.gz
53
58
54
59
# IMAGE is the image name of the node problem detector container image.
55
60
IMAGE: =$(REGISTRY ) /node-problem-detector:$(TAG )
87
92
88
93
ifeq ($(ENABLE_JOURNALD ) , 1)
89
94
# Enable journald build tag.
90
- LINUX_BUILD_TAGS := $(BUILD_TAGS) journald
95
+ LINUX_BUILD_TAGS := journald $(BUILD_TAGS)
91
96
# Enable cgo because sdjournal needs cgo to compile. The binary will be
92
97
# dynamically linked if CGO_ENABLED is enabled. This is fine because fedora
93
98
# already has necessary dynamic library. We can not use `-extldflags "-static"`
@@ -112,23 +117,16 @@ fmt:
112
117
version :
113
118
@echo $(VERSION )
114
119
115
- WINDOWS_AMD64_BINARIES = bin/windows_amd64/node-problem-detector.exe bin/windows_amd64/health-checker.exe
116
- WINDOWS_AMD64_TEST_BINARIES = test/bin/windows_amd64/problem-maker.exe
117
- LINUX_AMD64_BINARIES = bin/linux_amd64/node-problem-detector bin/linux_amd64/health-checker
118
- LINUX_AMD64_TEST_BINARIES = test/bin/linux_amd64/problem-maker
120
+ BINARIES = bin/node-problem-detector bin/health-checker test/bin/problem-maker
121
+ BINARIES_LINUX_ONLY =
119
122
ifeq ($(ENABLE_JOURNALD ) , 1)
120
- LINUX_AMD64_BINARIES += bin/linux_amd64 /log-counter
123
+ BINARIES_LINUX_ONLY += bin/log-counter
121
124
endif
122
125
123
- WINDOWS_BINARIES = $(WINDOWS_AMD64_BINARIES ) $(WINDOWS_AMD64_TEST_BINARIES )
124
- LINUX_BINARIES = $(LINUX_AMD64_BINARIES ) $(LINUX_AMD64_TEST_BINARIES )
125
-
126
- windows-binaries : $(WINDOWS_BINARIES )
126
+ ALL_BINARIES = $(foreach binary, $(BINARIES ) $(BINARIES_LINUX_ONLY ) , ./$(binary ) ) $(foreach binary, $(BINARIES ) $(BINARIES_LINUX_ONLY ) , output/linux_amd64/$(binary ) ) $(foreach binary, $(BINARIES ) , output/windows_amd64/$(binary ) .exe)
127
+ ALL_TARBALLS = $(foreach platform, $(PLATFORMS ) , $(NPD_NAME_VERSION ) -$(platform ) .tar.gz)
127
128
128
- bin/windows_amd64/% .exe : $(PKG_SOURCES )
129
- ifeq ($(ENABLE_JOURNALD ) , 1)
130
- echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
131
- endif
129
+ output/windows_amd64/bin/% .exe : $(PKG_SOURCES )
132
130
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
133
131
-mod vendor \
134
132
-o $@ \
@@ -137,17 +135,14 @@ endif
137
135
./cmd/$(subst -,,$* )
138
136
touch $@
139
137
140
- ./test/bin/windows_amd64/% .exe : $(PKG_SOURCES )
141
- ifeq ($(ENABLE_JOURNALD ) , 1)
142
- echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
143
- endif
138
+ output/windows_amd64/test/bin/% .exe : $(PKG_SOURCES )
144
139
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
145
140
-mod vendor \
146
141
-o $@ \
147
142
-tags " $( WINDOWS_BUILD_TAGS) " \
148
143
./test/e2e/$(subst -,,$* )
149
144
150
- bin /linux_amd64/% : $(PKG_SOURCES )
145
+ output /linux_amd64/bin /% : $(PKG_SOURCES )
151
146
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
152
147
-mod vendor \
153
148
-o $@ \
@@ -156,18 +151,13 @@ bin/linux_amd64/%: $(PKG_SOURCES)
156
151
./cmd/$(subst -,,$* )
157
152
touch $@
158
153
159
- ./ test/bin/linux_amd64 /% : $(PKG_SOURCES )
154
+ output/linux_amd64/ test/bin/% : $(PKG_SOURCES )
160
155
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED ) GO111MODULE=on go build \
161
156
-mod vendor \
162
157
-o $@ \
163
158
-tags " $( LINUX_BUILD_TAGS) " \
164
159
./test/e2e/$(subst -,,$* )
165
160
166
- ifneq ($(ENABLE_JOURNALD ) , 1)
167
- bin/linux_amd64/log-counter :
168
- echo " Warning: log-counter requires journald, skipping."
169
- endif
170
-
171
161
# In the future these targets should be deprecated.
172
162
./bin/log-counter : $(PKG_SOURCES )
173
163
ifeq ($(ENABLE_JOURNALD ) , 1)
@@ -217,16 +207,25 @@ e2e-test: vet fmt build-tar
217
207
-boskos-project-type=$(BOSKOS_PROJECT_TYPE ) -job-name=$(JOB_NAME ) \
218
208
-artifacts-dir=$(ARTIFACTS )
219
209
220
- build-binaries : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker $(WINDOWS_BINARIES ) $(LINUX_BINARIES )
210
+ $(NPD_NAME_VERSION ) -% .tar.gz : $(ALL_BINARIES ) test/e2e-install.sh
211
+ mkdir -p output/$* / output/$* /test/
212
+ cp -r config/ output/$* /
213
+ cp test/e2e-install.sh output/$* /test/e2e-install.sh
214
+ (cd output/$* / && tar -zcvf ../../$@ * )
215
+ sha512sum $@ > $@ .sha512
216
+
217
+ build-binaries : $(ALL_BINARIES )
221
218
222
219
build-container : build-binaries Dockerfile
223
220
docker build -t $(IMAGE ) --build-arg BASEIMAGE=$(BASEIMAGE ) --build-arg LOGCOUNTER=$(LOGCOUNTER ) .
224
221
225
- build-tar : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
222
+ $( TARBALL ) : ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
226
223
tar -zcvf $(TARBALL ) bin/ config/ test/e2e-install.sh test/bin/problem-maker
227
224
sha1sum $(TARBALL )
228
225
md5sum $(TARBALL )
229
226
227
+ build-tar : $(TARBALL ) $(ALL_TARBALLS )
228
+
230
229
build : build-container build-tar
231
230
232
231
docker-builder :
@@ -243,13 +242,12 @@ push-container: build-container
243
242
244
243
push-tar : build-tar
245
244
gsutil cp $(TARBALL ) $(UPLOAD_PATH ) /node-problem-detector/
245
+ gsutil cp node-problem-detector-$(VERSION ) -* .tar.gz* $(UPLOAD_PATH ) /node-problem-detector/
246
246
247
247
push : push-container push-tar
248
248
249
249
clean :
250
- rm -f bin/health-checker
251
- rm -f bin/log-counter
252
- rm -f bin/node-problem-detector
253
- rm -f $(WINDOWS_AMD64_BINARIES ) $(LINUX_AMD64_BINARIES )
254
- rm -f test/bin/problem-maker
255
- rm -f node-problem-detector-* .tar.gz
250
+ rm -rf bin/
251
+ rm -rf test/bin/
252
+ rm -f node-problem-detector-* .tar.gz*
253
+ rm -rf output/
0 commit comments