Skip to content

Commit d92ebd6

Browse files
committed
Makefile: unconditionally build plugins
Changes the build targets of plugins to always unconditionally execute without trying to check dependencies. The previous make targets were faulty, e.g. changing something in the library didn't rebuild the plugins. This is a simple and stupid fix that I believe is good enough - building the plugins is really fast and go compiler caching makes it super fast for "unnecessary" builds. Signed-off-by: Markus Lehtonen <markus.lehtonen@intel.com>
1 parent 65eda50 commit d92ebd6

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ GO_LINT := golint -set_exit_status
2929
GO_FMT := gofmt
3030
GO_VET := $(GO_CMD) vet
3131

32+
GO_BUILD_FLAGS ?=
33+
3234
GO_MODULES := $(shell $(GO_CMD) list ./...)
3335

3436
GOLANG_CILINT := golangci-lint
@@ -69,6 +71,8 @@ allclean: clean clean-cache
6971

7072
test: test-gopkgs
7173

74+
FORCE:
75+
7276
#
7377
# build targets
7478
#
@@ -98,14 +102,14 @@ clean-cache:
98102
# plugins build targets
99103
#
100104

101-
$(BIN_PATH)/%: plugins/%/*
105+
$(BIN_PATH)/% build/bin/%: FORCE
102106
$(Q)echo "Building $@..."; \
103-
cd $(dir $<) && $(GO_BUILD) -o $@ .
107+
$(GO_BUILD) -C plugins/$* -o $(abspath $@) $(GO_BUILD_FLAGS) .
104108

105-
$(BIN_PATH)/wasm: plugins/wasm/
109+
$(BIN_PATH)/wasm build/bin/wasm: FORCE
106110
$(Q)echo "Building $@..."; \
107111
mkdir -p $(BIN_PATH) && \
108-
cd $(dir $<) && GOOS=wasip1 GOARCH=wasm $(GO_BUILD) -o $@ -buildmode=c-shared .
112+
GOOS=wasip1 GOARCH=wasm $(GO_BUILD) -C plugins/wasm -o $(abspath $@) $(GO_BUILD_FLAGS) -buildmode=c-shared .
109113

110114
#
111115
# test targets

plugins/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ RUN --mount=type=cache,target=/go/pkg/mod/ go mod download
2727
COPY . .
2828

2929
RUN --mount=type=cache,target=/go/pkg/mod/ \
30-
make /go/src/build/bin/${PLUGIN} \
31-
GO_BUILD="CGO_ENABLED=0 go build -ldflags '-extldflags=-static'"
30+
make build/bin/${PLUGIN} \
31+
GO_BUILD="CGO_ENABLED=0 go build" \
32+
GO_BUILD_FLAGS="-ldflags '-extldflags=-static'"
3233

3334
# Construct final image
3435
FROM scratch

0 commit comments

Comments
 (0)