Skip to content

Commit 91466b2

Browse files
Build swag using native arch in cross build (#107)
* Build `swag` using native `amd64` arch. Else during cross compiling, swag binary will be placed in architecture specific bin folder. --------- Signed-off-by: Mahendra Paipuri <[email protected]>
1 parent 5b4b637 commit 91466b2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Makefile.common

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ifneq ($(shell command -v gotestsum > /dev/null),)
4242
endif
4343
endif
4444

45-
PROMU_VERSION ?= 0.15.0
45+
PROMU_VERSION ?= 0.17.0
4646
PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_VERSION)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM).tar.gz
4747

4848
SKIP_GOLANGCI_LINT :=
@@ -239,10 +239,15 @@ $(PROMU):
239239
cp $(PROMU_TMP)/promu-$(PROMU_VERSION).$(GO_BUILD_PLATFORM)/promu $(FIRST_GOPATH)/bin/promu
240240
rm -r $(PROMU_TMP)
241241

242+
# Set CC and CXX vars here else during cross compilation swag will be built in ARCH
243+
# specific bin folder like $(GOPATH)/bin/linux_386/swag. By setting CC and CXX we are
244+
# explicitly saying it to build as default arch and bin will be placed in $(GOPATH)/bin
242245
.PHONY: swag
243246
swag: $(SWAG)
244247
$(SWAG):
245-
$(GO) install github.com/swaggo/swag/cmd/swag@latest
248+
ifeq ($(CGO_BUILD), 1)
249+
cc='gcc' cxx='g++' GOARCH='amd64' $(GO) install github.com/swaggo/swag/cmd/[email protected]
250+
endif
246251

247252
.PHONY: proto
248253
proto:

0 commit comments

Comments
 (0)