Skip to content

Commit 49766a1

Browse files
authored
Fix mac universal build after GOBIN refactoring
In #6378 the Makefile was refactored to use the preferred GOBIN variable. However, this broke mac universal builds. This PR revises the build to skip over NONGO_BIN files and handle node exporter separately.
1 parent bd99b20 commit 49766a1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ OS_TYPE := $(shell ./scripts/ostype.sh)
1515
# overrides for cross-compiling platform-specific binaries
1616
ifdef CROSS_COMPILE_ARCH
1717
ARCH := $(CROSS_COMPILE_ARCH)
18-
GO_INSTALL := CGO_ENABLED=1 GOOS=$(OS_TYPE) GOARCH=$(ARCH) go build -o $(GOBIN)-$(OS_TYPE)-$(ARCH)
18+
GO_INSTALL := CGO_ENABLED=1 GOOS=$(OS_TYPE) GOARCH=$(ARCH) go build -o $(GOBIN)
1919
else
2020
GO_INSTALL := go install
2121
endif
@@ -194,14 +194,27 @@ ifeq ($(OS_TYPE),darwin)
194194
# lipo together
195195
mkdir -p $(GOBIN)
196196
for binary in $$(ls $(GOBIN)-darwin-arm64); do \
197+
skip=false; \
198+
for nongo_file in $(NONGO_BIN_FILES) $(GOBIN)/update.sh ; do \
199+
if [ "$(GOBIN)/$$binary" = "$$nongo_file" ]; then \
200+
echo "Skipping non-binary file: $$binary"; \
201+
skip=true; \
202+
break; \
203+
fi; \
204+
done; \
205+
if [ "$$skip" = "true" ]; then \
206+
continue; \
207+
fi; \
197208
if [ -f $(GOBIN)-darwin-amd64/$$binary ]; then \
198209
lipo -create -output $(GOBIN)/$$binary \
199210
$(GOBIN)-darwin-arm64/$$binary \
200211
$(GOBIN)-darwin-amd64/$$binary; \
201212
else \
202213
echo "Warning: Binary $$binary exists in arm64 but not in amd64"; \
203-
fi \
214+
fi; \
204215
done
216+
# for node_exporter cross-compilation is using universal binary already
217+
cp -f $(GOBIN)-darwin-arm64/node_exporter $(GOBIN)/node_exporter
205218
else
206219
echo "OS_TYPE must be darwin for universal builds, skipping"
207220
endif

0 commit comments

Comments
 (0)