From df5d407380980cd8b3c1d0e95e2d67380b2fe106 Mon Sep 17 00:00:00 2001 From: Paulo Janotti Date: Mon, 30 Oct 2023 10:30:12 -0700 Subject: [PATCH] Run make binaries-windows_amd64 clean on Windows (#3847) * Run make binaries-windows_amd64 clean on Windows * nit: delete extra white line Revert "nit: delete extra white line" This reverts commit 80a5526727dd663f8c601ac292ff5318b3f5b6ce. nit: delete extra white line --- Makefile.Common | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Makefile.Common b/Makefile.Common index 7d745e7342..365dd10ae5 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -1,6 +1,22 @@ # Explicitly define the shell we will use for commands. SHELL?=/bin/bash +# Add support to use Makefile on Windows +SHELL_CASE_EXP = case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) echo "true";; esac; +UNIX_SHELL_ON_WINDOWS := $(shell $(SHELL_CASE_EXP)) + +ifeq ($(UNIX_SHELL_ON_WINDOWS),true) + # The "sed" transformation below is needed on Windows, since commands like `go list -f '{{ .Dir }}'` + # return Windows paths and such paths are incompatible with other *nix tools, like `find`, + # used by the Makefile shell. + # The backslash needs to be doubled so its passed correctly to the shell. + NORMALIZE_DIRS = sed -e 's/^/\\//' -e 's/://' -e 's/\\\\/\\//g' | sort + NUM_CORES := ${NUMBER_OF_PROCESSORS} +else + NORMALIZE_DIRS = sort + NUM_CORES := $(shell getconf _NPROCESSORS_ONLN) +endif + # SRC_ROOT is the top of the source tree. SRC_ROOT := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) @@ -19,9 +35,8 @@ LINT=golangci-lint IMPI=impi # BUILD_TYPE should be one of (dev, release). BUILD_TYPE?=release -NUM_CORES := $(shell getconf _NPROCESSORS_ONLN) -ALL_PKG_DIRS := $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | sort) +ALL_PKG_DIRS := $(shell $(GOCMD) list -f '{{ .Dir }}' ./... | $(NORMALIZE_DIRS)) ALL_SRC := $(shell find $(ALL_PKG_DIRS) -name '*.go' \ -not -path '*/third_party/*' \