Skip to content

Commit 2bb09fc

Browse files
committed
fix: handle paths containing spaces in Makefiles
1 parent 372878d commit 2bb09fc

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

‎Makefile‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ VERSION=$(shell cat VERSION)
2929
RELEASE=$(shell cat RELEASE)
3030

3131
# Current directory
32-
CURRENTDIR=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
32+
CURRENTDIR=$(CURDIR)/
3333

3434
# Target directory
35-
TARGETDIR=$(CURRENTDIR)target
35+
TARGETDIR=target
3636

3737
# Directory where to store binary utility tools
3838
BINUTIL=$(TARGETDIR)/binutil
@@ -46,7 +46,7 @@ endif
4646
# GO lang path
4747
ifeq ($(GOPATH),)
4848
# extract the GOPATH
49-
GOPATH=$(firstword $(subst /src/, ,$(CURRENTDIR)))
49+
GOPATH=$(shell echo "$(CURDIR)" | sed 's|/src/.*||')
5050
endif
5151

5252
# Add the GO binary dir in the PATH
@@ -61,11 +61,11 @@ ifeq ($(DOCKER),)
6161
endif
6262

6363
# Common commands
64-
GO=GOPATH=$(GOPATH) GOPRIVATE=$(CVSPATH) $(shell which go)
64+
GO=GOPATH="$(GOPATH)" GOPRIVATE=$(CVSPATH) $(shell which go)
6565
GOVERSION=${shell go version | grep -Eo '(go[0-9]+.[0-9]+)'}
6666
GOFMT=$(shell which gofmt)
6767
GOTEST=$(GO) test
68-
GODOC=GOPATH=$(GOPATH) $(shell which godoc)
68+
GODOC=GOPATH="$(GOPATH)" $(shell which godoc)
6969
GOLANGCILINT=$(BINUTIL)/golangci-lint
7070
GOLANGCILINTVERSION=v2.12.2
7171

@@ -79,7 +79,7 @@ GOPKGS=$(shell $(GO) list $(SRCDIR)/...)
7979
ifeq ($(strip $(DEVMODE)),LOCAL)
8080
TESTEXTRACMD=&& $(GO) tool cover -func=$(TARGETDIR)/report/coverage.out
8181
else
82-
TESTEXTRACMD=2>&1 | tee >(PATH=$(GOPATH)/bin:$(PATH) go-junit-report > $(TARGETDIR)/test/report.xml); test $${PIPESTATUS[0]} -eq 0
82+
TESTEXTRACMD=2>&1 | tee >(PATH="$(GOPATH)/bin:$(PATH)" go-junit-report > $(TARGETDIR)/test/report.xml); test $${PIPESTATUS[0]} -eq 0
8383
endif
8484

8585

@@ -129,55 +129,55 @@ x:
129129
# Remove any build artifact
130130
.PHONY: clean
131131
clean:
132-
rm -rf $(TARGETDIR)
132+
rm -rf "$(TARGETDIR)"
133133

134134
# Generate the coverage report
135135
.PHONY: coverage
136136
coverage: ensuretarget
137-
$(GO) tool cover -html=$(TARGETDIR)/report/coverage.out -o $(TARGETDIR)/report/coverage.html
137+
$(GO) tool cover -html="$(TARGETDIR)/report/coverage.out" -o "$(TARGETDIR)/report/coverage.html"
138138

139139
# Build everything inside a Docker container
140140
.PHONY: dbuild
141141
dbuild: dockerdev
142-
@mkdir -p $(TARGETDIR)
143-
@rm -rf $(TARGETDIR)/*
144-
@echo 0 > $(TARGETDIR)/make.exit
145-
CVSPATH=$(CVSPATH) VENDOR=$(LCVENDOR) PROJECT=$(PROJECT) MAKETARGET='$(MAKETARGET)' DOCKERTAG='$(DOCKERTAG)' $(CURRENTDIR)dockerbuild.sh
142+
@mkdir -p "$(TARGETDIR)"
143+
@rm -rf "$(TARGETDIR)/"*
144+
@echo 0 > "$(TARGETDIR)/make.exit"
145+
CVSPATH=$(CVSPATH) VENDOR=$(LCVENDOR) PROJECT=$(PROJECT) MAKETARGET='$(MAKETARGET)' DOCKERTAG='$(DOCKERTAG)' "$(CURRENTDIR)dockerbuild.sh"
146146
@exit `cat $(TARGETDIR)/make.exit`
147147

148148
# Get the test dependencies
149149
.PHONY: deps
150150
deps: ensuretarget
151-
curl --silent --show-error --fail --location "https://golangci-lint.run/install.sh" | sh -s -- -b $(BINUTIL) $(GOLANGCILINTVERSION)
151+
curl --silent --show-error --fail --location "https://golangci-lint.run/install.sh" | sh -s -- -b "$(BINUTIL)" $(GOLANGCILINTVERSION)
152152

153153
# Build a base development Docker image
154154
.PHONY: dockerdev
155155
dockerdev:
156-
$(DOCKER) build --pull --tag ${LCVENDOR}/dev_${PROJECT} --file ./resources/docker/Dockerfile.dev ./resources/docker/
156+
$(DOCKER) build --pull --tag "${LCVENDOR}/dev_${PROJECT}" --file ./resources/docker/Dockerfile.dev ./resources/docker/
157157

158158
# Create the trget directories if missing
159159
.PHONY: ensuretarget
160160
ensuretarget:
161-
@mkdir -p $(TARGETDIR)/test
162-
@mkdir -p $(TARGETDIR)/report
163-
@mkdir -p $(TARGETDIR)/binutil
161+
@mkdir -p "$(TARGETDIR)/test"
162+
@mkdir -p "$(TARGETDIR)/report"
163+
@mkdir -p "$(TARGETDIR)/binutil"
164164

165165
# Format the source code
166166
.PHONY: format
167167
format:
168-
@find $(SRCDIR) -type f -name "*.go" -exec $(GOFMT) -s -w {} \;
168+
@find "$(SRCDIR)" -type f -name "*.go" -exec $(GOFMT) -s -w {} \;
169169

170170
# Generate test mocks
171171
.PHONY: generate
172172
generate:
173-
@find $(SRCDIR) -type f -name "*mock_test.go" -exec rm {} \;
173+
@find "$(SRCDIR)" -type f -name "*mock_test.go" -exec rm {} \;
174174
$(GO) generate $(GOPKGS)
175175

176176
# Execute multiple linter tools
177177
.PHONY: linter
178178
linter:
179179
@echo -e "\n\n>>> START: Static code analysis <<<\n\n"
180-
$(GOLANGCILINT) run --max-issues-per-linter 0 --max-same-issues 0 $(SRCDIR)/...
180+
$(GOLANGCILINT) run --max-issues-per-linter 0 --max-same-issues 0 "$(SRCDIR)/..."
181181
@echo -e "\n\n>>> END: Static code analysis <<<\n\n"
182182

183183
# Download dependencies

‎VERSION‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.1
1+
1.1.2

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/tecnickcom/statsd
22

33
go 1.26
44

5-
toolchain go1.26.4
5+
toolchain go1.26.5
66

77
retract v2.0.6+incompatible // Published in error - v1 is the current version
88

0 commit comments

Comments
 (0)