Skip to content

Commit

Permalink
Merge pull request #9 from na4ma4/matrix-changes
Browse files Browse the repository at this point in the history
replace GO_MATRIX_ARCH and GO_MATRIX_OS with GO_MATRIX
  • Loading branch information
na4ma4 authored Aug 10, 2021
2 parents 74c7b9a + d106dcd commit 21eca49
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,17 @@ GO_APP_VERSION ?= $(SEMVER)
GO_DEBUG_ARGS ?= -v -ldflags "-X main.version=$(GO_APP_VERSION)"
GO_RELEASE_ARGS ?= -v -ldflags "-X main.version=$(GO_APP_VERSION) -s -w"


# Build matrix configuration.
#
# GO_MATRIX_OS is a whitespace separated set of operating systems.
# GO_MATRIX_ARCH is a whitespace separated set of CPU architectures.
#
# The build-matrix is constructed from all permutations of GO_MATRIX_OS and
# GO_MATRIX_ARCH. The default is to build only for the OS and architecture
# specified by the GOHOSTOS and GOHOSTARCH environment variables, that is the OS
# and architecture of current system.
# GO_MATRIX is a whitespace separated set of operating systems and architectures.
GOHOSTOS := $(shell go env GOHOSTOS)
GOHOSTARCH := $(shell go env GOHOSTARCH)
GO_MATRIX_OS ?= $(GOHOSTOS)
GO_MATRIX_ARCH ?= $(GOHOSTARCH)
ifneq ($(GO_MATRIX_ARCH)$(GO_MATRIX_OS),)
GO_MATRIX ?=
else
GO_MATRIX ?= $(GOHOSTOS)/$(GOHOSTARCH)
endif

# GO_DEBUG_DIR is the relative path to the debug build directory for the current
# OS & architecture.
Expand Down Expand Up @@ -93,13 +91,19 @@ else
_GO_BINARIES_HOST = $(_GO_BINARIES_NIX)
endif

# _GO_BUILD_PLATFORM_MATRIX_xxx is the cartesian product of all operating
# systems and architectures specified in GO_MATRIX_OS and GO_MATRIX_ARCH.
_GO_BUILD_PLATFORM_MATRIX_ALL = $(foreach OS,$(GO_MATRIX_OS),$(foreach ARCH,$(GO_MATRIX_ARCH),$(OS)/$(ARCH)))
# _GO_BUILD_PLATFORM_MATRIX_ALL is the union of GO_MATRIX (containing os/arch) and the
# cartesian product of all operating systems and architectures specified in
# GO_MATRIX_OS and GO_MATRIX_ARCH (which are now deprecated).
_GO_BUILD_PLATFORM_MATRIX_ALL = $(sort $(foreach OS,$(GO_MATRIX_OS),$(foreach ARCH,$(GO_MATRIX_ARCH),$(OS)/$(ARCH))) $(GO_MATRIX))
_GO_BUILD_PLATFORM_MATRIX_NIX = $(filter-out windows/%,$(_GO_BUILD_PLATFORM_MATRIX_ALL))
_GO_BUILD_PLATFORM_MATRIX_WIN = $(filter windows/%,$(_GO_BUILD_PLATFORM_MATRIX_ALL))
_GO_BUILD_PLATFORM_MATRIX_HOST = $(GOHOSTOS)/$(GOHOSTARCH)

# Print deprecation warnings if GO_MATRIX_ARCH or GO_MATRIX_OS is used.
ifneq ($(GO_MATRIX_ARCH)$(GO_MATRIX_OS),)
$(warning GO_MATRIX_ARCH/GO_MATRIX_OS is deprecated, change to GO_MATRIX = $(_GO_BUILD_PLATFORM_MATRIX_ALL))
endif

# _GO_BUILD_MATRIX_xxx is the cartesian product of the platform matrix and the
# filenames of the binaries.
_GO_BUILD_MATRIX_NIX = $(foreach P,$(_GO_BUILD_PLATFORM_MATRIX_NIX),$(addprefix $(P)/,$(_GO_BINARIES_NIX)))
Expand Down

0 comments on commit 21eca49

Please sign in to comment.