Skip to content

Commit 979670e

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 979670e

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ 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
3537
GINKGO := ginkgo
3638

37-
RESOLVED_PWD := $(shell realpath $(shell pwd))
38-
BUILD_PATH := $(RESOLVED_PWD)/build
39+
BUILD_PATH := build
3940
BIN_PATH := $(BUILD_PATH)/bin
4041
COVERAGE_PATH := $(BUILD_PATH)/coverage
4142

@@ -69,6 +70,8 @@ allclean: clean clean-cache
6970

7071
test: test-gopkgs
7172

73+
FORCE:
74+
7275
#
7376
# build targets
7477
#
@@ -98,14 +101,14 @@ clean-cache:
98101
# plugins build targets
99102
#
100103

101-
$(BIN_PATH)/%: plugins/%/*
104+
$(BIN_PATH)/%: FORCE
102105
$(Q)echo "Building $@..."; \
103-
cd $(dir $<) && $(GO_BUILD) -o $@ .
106+
$(GO_BUILD) -C plugins/$* -o ../../$@ $(GO_BUILD_FLAGS) .
104107

105-
$(BIN_PATH)/wasm: plugins/wasm/
108+
$(BIN_PATH)/wasm: FORCE
106109
$(Q)echo "Building $@..."; \
107110
mkdir -p $(BIN_PATH) && \
108-
cd $(dir $<) && GOOS=wasip1 GOARCH=wasm $(GO_BUILD) -o $@ -buildmode=c-shared .
111+
GOOS=wasip1 GOARCH=wasm $(GO_BUILD) -C plugins/wasm -o ../../$@ $(GO_BUILD_FLAGS) -buildmode=c-shared .
109112

110113
#
111114
# 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)