build: Linux arm64 support

* protoc zip fetching
* Makefile:
    * GOOS and GOARCH
    * run vet on all targets

Note: freebsd/arm64 is apparently not supported

fixes #180
refs #181
This commit is contained in:
Christian Schwarz 2019-06-23 12:10:52 +02:00
parent 90b32c7377
commit 234a327a03
4 changed files with 45 additions and 9 deletions

View File

@ -16,8 +16,10 @@ GO_LDFLAGS := "-X github.com/zrepl/zrepl/version.zreplVersion=$(_ZREPL_VERSION)"
GO_BUILD := go build -ldflags $(GO_LDFLAGS) GO_BUILD := go build -ldflags $(GO_LDFLAGS)
# keep in sync with vet target
RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64 RELEASE_BINS := $(ARTIFACTDIR)/zrepl-freebsd-amd64
RELEASE_BINS += $(ARTIFACTDIR)/zrepl-linux-amd64 RELEASE_BINS += $(ARTIFACTDIR)/zrepl-linux-amd64
RELEASE_BINS += $(ARTIFACTDIR)/zrepl-linux-arm64
RELEASE_BINS += $(ARTIFACTDIR)/zrepl-darwin-amd64 RELEASE_BINS += $(ARTIFACTDIR)/zrepl-darwin-amd64
RELEASE_NOARCH := $(ARTIFACTDIR)/zrepl-noarch.tar RELEASE_NOARCH := $(ARTIFACTDIR)/zrepl-noarch.tar
@ -42,12 +44,17 @@ build:
test: test:
go test ./... go test ./...
# TODO compile the tests for each supported platform
# but `go test -c ./...` is not supported
vet: vet:
go vet ./...
# for each supported platform to cover conditional compilation # for each supported platform to cover conditional compilation
GOOS=linux go vet ./... # (keep in sync with RELEASE_BINS)
GOOS=darwin go vet ./... GOOS=freebsd GOARCH=amd64 go vet ./...
GOOS=freebsd go vet ./... GOOS=linux GOARCH=amd64 go vet ./...
GOOS=linux GOARCH=arm64 go vet ./...
GOOS=darwin GOARCH=amd64 go vet ./...
$(ARTIFACTDIR): $(ARTIFACTDIR):
mkdir -p "$@" mkdir -p "$@"
@ -71,12 +78,12 @@ docs-clean:
clean \ clean \
BUILDDIR=../artifacts/docs BUILDDIR=../artifacts/docs
.PHONY: $(RELEASE_BINS) .PHONY: $(RELEASE_BINS)
# TODO: two wildcards possible # TODO: two wildcards possible
$(RELEASE_BINS): $(ARTIFACTDIR)/zrepl-%-amd64: generate $(ARTIFACTDIR) vet test lint $(RELEASE_BINS): $(ARTIFACTDIR)/zrepl-%: generate $(ARTIFACTDIR) vet test lint
@echo "INFO: In case of missing dependencies, run 'make vendordeps'" @echo "INFO: In case of missing dependencies, run 'make vendordeps'"
GOOS=$* GOARCH=amd64 $(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$*-amd64" STEM=$*; GOOS="$${STEM%%-*}"; GOARCH="$${STEM##*-}"; export GOOS GOARCH; \
$(GO_BUILD) -o "$(ARTIFACTDIR)/zrepl-$$GOOS-$$GOARCH"
$(RELEASE_NOARCH): docs $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/go_version.txt $(RELEASE_NOARCH): docs $(ARTIFACTDIR)/bash_completion $(ARTIFACTDIR)/go_version.txt
tar --mtime='1970-01-01' --sort=name \ tar --mtime='1970-01-01' --sort=name \

View File

@ -4,9 +4,8 @@ RUN apt-get update && apt-get install -y \
python3-pip \ python3-pip \
unzip unzip
RUN wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protoc-3.6.1-linux-x86_64.zip ADD build.installprotoc.bash ./
RUN echo "6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807 protoc-3.6.1-linux-x86_64.zip" | sha256sum -c RUN bash build.installprotoc.bash
RUN unzip -d /usr protoc-3.6.1-linux-x86_64.zip
ADD lazy.sh /tmp/lazy.sh ADD lazy.sh /tmp/lazy.sh
ADD docs/requirements.txt /tmp/requirements.txt ADD docs/requirements.txt /tmp/requirements.txt

25
build.installprotoc.bash Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
set -x
MACH=$(uname -m)
MACH="${MACH/aarch64/aarch_64}"
VERSION=3.6.1
FILENAME=protoc-"$VERSION"-linux-"$MACH".zip
if [ -e "$FILENAME" ]; then
echo "$FILENAME" already exists 1>&2
exit 1
fi
wget https://github.com/protocolbuffers/protobuf/releases/download/v"$VERSION"/"$FILENAME"
stat "$FILENAME"
sha256sum -c --ignore-missing <<EOF
6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807 protoc-3.6.1-linux-x86_64.zip
af8e5aaaf39ddec62ec8dd2be1b8d9602c6da66564883a16393ade5f71170922 protoc-3.6.1-linux-aarch_64.zip
EOF
unzip -d /usr "$FILENAME"

View File

@ -25,6 +25,11 @@ We use the following annotations for classifying changes:
* |bugfix| Change that fixes a bug, no regressions or incompatibilities expected. * |bugfix| Change that fixes a bug, no regressions or incompatibilities expected.
* |docs| Change to the documentation. * |docs| Change to the documentation.
0.1.2
-----
* Linux ARM64 Docker build support & binary builds
0.1.1 0.1.1
----- -----