Skip to content

Commit 82e9d22

Browse files
committed
Support MacOS
Signed-off-by: Ed Snible <snible@us.ibm.com>
1 parent 60bff86 commit 82e9d22

1 file changed

Lines changed: 23 additions & 30 deletions

File tree

Makefile

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ endif
1818
lint fmt audit coverage coverage-check \
1919
fuzz fuzz-build \
2020
container container-run \
21-
test-container test-container-run \
2221
run-echo run-debug \
2322
tools clean-tools \
2423
help
@@ -58,21 +57,6 @@ container-run:
5857
podman run --rm --network=host $(IMAGE):$(VERSION) 2>&1 || \
5958
docker run --rm --network=host $(IMAGE):$(VERSION) 2>&1
6059

61-
# -------------------------------------------------------------------
62-
# Test Container
63-
# -------------------------------------------------------------------
64-
65-
test-container:
66-
podman build --ignorefile Containerfile.test.dockerignore \
67-
-t $(IMAGE)-test:$(VERSION) -f Containerfile.test . || \
68-
docker build -t $(IMAGE)-test:$(VERSION) -f Containerfile.test .
69-
70-
test-container-run: test-container
71-
podman run --rm -v $(CURDIR):/src -v praxis-test-cache:/cache \
72-
$(IMAGE)-test:$(VERSION) 2>&1 || \
73-
docker run --rm -v $(CURDIR):/src -v praxis-test-cache:/cache \
74-
$(IMAGE)-test:$(VERSION) 2>&1
75-
7660
# -------------------------------------------------------------------
7761
# Test
7862
# -------------------------------------------------------------------
@@ -115,7 +99,15 @@ test-smoke:
11599
# Bench
116100
# -------------------------------------------------------------------
117101

118-
bench: $(VEGETA) $(FORTIO)
102+
# Fortio builds are not available on GitHub for Darwin (Mac OSX)
103+
# To install Fortio on the Mac, use `brew install fortio`.
104+
ifeq ($(UNAME_S),darwin)
105+
FORTIO_DEP :=
106+
else
107+
FORTIO_DEP := $(FORTIO)
108+
endif
109+
110+
bench: $(VEGETA) $(FORTIO_DEP)
119111
PATH="$(BINUTILS_PATH):$(PATH)" cargo bench -p benchmarks
120112

121113
# -------------------------------------------------------------------
@@ -173,8 +165,8 @@ run-debug:
173165
# Binutils
174166
# -------------------------------------------------------------------
175167

176-
BINUTILS_DIR ?= target/praxis-binutils
177-
BINUTILS_PATH := $(abspath $(BINUTILS_DIR))
168+
BINUTILS_DIR := target/praxis-binutils
169+
BINUTILS_PATH := $(CURDIR)/$(BINUTILS_DIR)
178170

179171
H2SPEC_VERSION := 2.6.0
180172
VEGETA_VERSION := 12.13.0
@@ -187,6 +179,10 @@ FORTIO := $(BINUTILS_DIR)/fortio
187179
UNAME_S := $(shell uname -s | tr A-Z a-z)
188180
UNAME_M := $(shell uname -m)
189181

182+
# The MacOS / OSX sha256 command does not support the needed options.
183+
# On the Mac, do `brew install coreutils` to install gsha256sum, a GNU-compatible sha256sum
184+
SHA256SUM := $(shell command -v gsha256sum 2>/dev/null || echo sha256sum)
185+
190186
# Map architecture names
191187
ifeq ($(UNAME_M),x86_64)
192188
ARCH_GO := amd64
@@ -202,8 +198,8 @@ $(BINUTILS_DIR):
202198
H2SPEC_SHA256_linux_amd64 := 157ee0de702e01ad40e752dbf074b366027e550c8e7504f9450da2809e279318
203199
H2SPEC_SHA256_darwin_amd64 := 981cb9f90a6f5e36300063022bd4eb7438d3dcf66d63a146a8541359697d1601
204200

205-
# h2spec has no arm64 builds; fall back to amd64.
206-
ifeq ($(ARCH_GO),arm64)
201+
# h2spec has no arm64 builds; fall back to amd64 (runs under Rosetta on macOS).
202+
ifeq ($(UNAME_S)_$(ARCH_GO),darwin_arm64)
207203
H2SPEC_ARCH := amd64
208204
else
209205
H2SPEC_ARCH := $(ARCH_GO)
@@ -214,34 +210,33 @@ H2SPEC_SHA256 := $(H2SPEC_SHA256_$(UNAME_S)_$(H2SPEC_ARCH))
214210
$(H2SPEC): | $(BINUTILS_DIR)
215211
curl -sSfL -o $(BINUTILS_DIR)/h2spec.tar.gz \
216212
https://github.com/summerwind/h2spec/releases/download/v$(H2SPEC_VERSION)/h2spec_$(UNAME_S)_$(H2SPEC_ARCH).tar.gz
217-
$(if $(H2SPEC_SHA256),echo "$(H2SPEC_SHA256) $(BINUTILS_DIR)/h2spec.tar.gz" | sha256sum -c,)
213+
$(if $(H2SPEC_SHA256),echo "$(H2SPEC_SHA256) $(BINUTILS_DIR)/h2spec.tar.gz" | $(SHA256SUM) --check --status,)
218214
tar xz -C $(BINUTILS_DIR) -f $(BINUTILS_DIR)/h2spec.tar.gz h2spec
219215
rm -f $(BINUTILS_DIR)/h2spec.tar.gz
220216

221217
VEGETA_SHA256_linux_amd64 := e8759ce45c14e18374bdccd3ba6068197bc3a9f9b7e484db3837f701b9d12e61
222-
VEGETA_SHA256_linux_arm64 := 950381173a5575e25e8e086f36fc03bf65d61a2433329b48e41e1cb5e4133bba
223218
VEGETA_SHA256_darwin_amd64 := 4e912c83ce07db4e1e394e1cbb657f2396dff2f7ed90f03869a184cc17d0f994
219+
VEGETA_SHA256_darwin_arm64 := fc408e242c4f4839e6fe536dbf1130bb02f430134827f6d831bf367a0929a799
224220
VEGETA_SHA256 := $(VEGETA_SHA256_$(UNAME_S)_$(ARCH_GO))
225221

226222
$(VEGETA): | $(BINUTILS_DIR)
227223
curl -sSfL -o $(BINUTILS_DIR)/vegeta.tar.gz \
228224
https://github.com/tsenart/vegeta/releases/download/v$(VEGETA_VERSION)/vegeta_$(VEGETA_VERSION)_$(UNAME_S)_$(ARCH_GO).tar.gz
229-
$(if $(VEGETA_SHA256),echo "$(VEGETA_SHA256) $(BINUTILS_DIR)/vegeta.tar.gz" | sha256sum -c,)
225+
echo "$(VEGETA_SHA256) $(BINUTILS_DIR)/vegeta.tar.gz" | $(SHA256SUM) --check --status
230226
tar xz -C $(BINUTILS_DIR) -f $(BINUTILS_DIR)/vegeta.tar.gz vegeta
231227
rm -f $(BINUTILS_DIR)/vegeta.tar.gz
232228

233-
FORTIO_SHA256_linux_amd64 := 92da34238dee258191a9dc6691c8bc75305b308951e934e2c3b4e658db0d77d1
234-
FORTIO_SHA256_linux_arm64 := f66275a56ef41e9a5afb2ea8181eb53ca36b34c6d19a201b58aec17dbe95a853
229+
FORTIO_SHA256_linux_amd64 := 92da34238dee258191a9dc6691c8bc75305b308951e934e2c3b4e658db0d77d1
235230
FORTIO_SHA256 := $(FORTIO_SHA256_$(UNAME_S)_$(ARCH_GO))
236231

237232
$(FORTIO): | $(BINUTILS_DIR)
238233
curl -sSfL -o $(BINUTILS_DIR)/fortio.tgz \
239234
https://github.com/fortio/fortio/releases/download/v$(FORTIO_VERSION)/fortio-$(UNAME_S)_$(ARCH_GO)-$(FORTIO_VERSION).tgz
240-
$(if $(FORTIO_SHA256),echo "$(FORTIO_SHA256) $(BINUTILS_DIR)/fortio.tgz" | sha256sum -c,)
235+
$(if $(FORTIO_SHA256),echo "$(FORTIO_SHA256) $(BINUTILS_DIR)/fortio.tgz" | $(SHA256SUM) --check --status,)
241236
tar xz -C $(BINUTILS_DIR) -f $(BINUTILS_DIR)/fortio.tgz usr/bin/fortio --strip-components=2
242237
rm -f $(BINUTILS_DIR)/fortio.tgz
243238

244-
tools: $(H2SPEC) $(VEGETA) $(FORTIO)
239+
tools: $(H2SPEC) $(VEGETA) $(FORTIO_DEP)
245240

246241
clean-tools:
247242
rm -rf $(BINUTILS_DIR)
@@ -293,8 +288,6 @@ help:
293288
@echo "Container:"
294289
@echo " container build container image"
295290
@echo " container-run run container in foreground (host network)"
296-
@echo " test-container build test container image"
297-
@echo " test-container-run build and run test suite in container"
298291
@echo ""
299292
@echo "Binutils (target/praxis-binutils/):"
300293
@echo " tools download all external CLI tools"

0 commit comments

Comments
 (0)