fix: detect non-amd64 arch and set noasm tag (#20290)

pull/20300/head
Daniel Moran 2020-12-09 11:52:59 -05:00 committed by GitHub
parent 1058a8e3f1
commit 074cd24a60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 23 deletions

View File

@ -14,8 +14,24 @@
# SUBDIRS are directories that have their own Makefile.
# It is required that all SUBDIRS have the `all` and `clean` targets.
SUBDIRS := http ui chronograf query storage
GO_TAGS=
GO_ARGS=-tags '$(GO_TAGS)'
export GOOS=$(shell go env GOOS)
export GOARCH=$(shell go env GOARCH)
ifeq ($(GOARCH), amd64)
# Including the assets tag requires the UI to be built for compilation to succeed.
# Don't force it for running tests.
GO_TEST_TAGS :=
GO_BUILD_TAGS := assets
else
# noasm needed to avoid a panic in Flux for non-amd64.
GO_TEST_TAGS := noasm
GO_BUILD_TAGS := assets,noasm
endif
GO_TEST_ARGS := -tags '$(GO_TEST_TAGS)'
GO_BUILD_ARGS := -tags '$(GO_BUILD_TAGS)'
ifeq ($(OS), Windows_NT)
VERSION := $(shell git describe --exact-match --tags 2>nil)
else
@ -31,15 +47,14 @@ endif
# Test vars can be used by all recursive Makefiles
export PKG_CONFIG:=$(PWD)/scripts/pkg-config.sh
export GOOS=$(shell go env GOOS)
export GO_BUILD=env GO111MODULE=on go build $(GO_ARGS) -ldflags "$(LDFLAGS)"
export GO_BUILD_SM=env GO111MODULE=on go build $(GO_ARGS) -ldflags "-s -w $(LDFLAGS)"
export GO_INSTALL=env GO111MODULE=on go install $(GO_ARGS) -ldflags "$(LDFLAGS)"
export GO_TEST=env GOTRACEBACK=all GO111MODULE=on go test $(GO_ARGS)
export GO_BUILD=env GO111MODULE=on go build $(GO_BUILD_ARGS) -ldflags "$(LDFLAGS)"
export GO_BUILD_SM=env GO111MODULE=on go build $(GO_BUILD_ARGS) -ldflags "-s -w $(LDFLAGS)"
export GO_INSTALL=env GO111MODULE=on go install $(GO_BUILD_ARGS) -ldflags "$(LDFLAGS)"
export GO_TEST=env GOTRACEBACK=all GO111MODULE=on go test $(GO_TEST_ARGS)
# Do not add GO111MODULE=on to the call to go generate so it doesn't pollute the environment.
export GO_GENERATE=go generate $(GO_ARGS)
export GO_VET=env GO111MODULE=on go vet $(GO_ARGS)
export GO_RUN=env GO111MODULE=on go run $(GO_ARGS)
export GO_GENERATE=go generate $(GO_BUILD_ARGS)
export GO_VET=env GO111MODULE=on go vet $(GO_TEST_ARGS)
export GO_RUN=env GO111MODULE=on go run $(GO_BUILD_ARGS)
export PATH := $(PWD)/bin/$(GOOS):$(PATH)
@ -60,18 +75,6 @@ CMDS := \
bin/$(GOOS)/influx \
bin/$(GOOS)/influxd
# Default target to build all go commands.
#
# This target sets up the dependencies to correctly build all go commands.
# Other targets must depend on this target to correctly builds CMDS.
ifeq ($(GOARCH), arm64)
all: GO_ARGS=-tags 'assets noasm $(GO_TAGS)'
bin/$(GOOS)/influx: GO_ARGS=-tags 'noasm $(GO_TAGS)'
else
all: GO_ARGS=-tags 'assets $(GO_TAGS)'
bin/$(GOOS)/influx: GO_ARGS=-tags '$(GO_TAGS)'
endif
all: $(SUBDIRS) generate $(CMDS)
# Target to build subdirs.
@ -82,7 +85,7 @@ $(SUBDIRS):
#
# Define targets for commands
#
$(CMDS): $(SOURCES)
bin/$(GOOS)/influxd: $(SOURCES)
$(GO_BUILD) -o $@ ./cmd/$(shell basename "$@")
bin/$(GOOS)/influx: $(SOURCES)