Explicitly set TMPDIR to ensure that it is a path where go-installed utils (pe. easyjson-bootstrap) can be executed. Fixes #955

This commit is contained in:
Jean Kahrs 2025-04-01 15:33:22 +02:00
commit 934422d05e
2 changed files with 9 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
bin/
tmp/
vendor/
*.pem

View file

@ -7,6 +7,7 @@ GOFMT := "$(GODIR)/gofmt"
GOOS ?= linux
GOARCH ?= amd64
GOVERSION := $(shell "$(GO)" env GOVERSION | sed "s|go||" )
TMPDIR := $(CURDIR)/tmp
BINDIR := $(CURDIR)/bin
VENDORDIR := "$(CURDIR)/vendor"
VERSION := $(shell "$(CURDIR)/scripts/get-version.sh")
@ -76,7 +77,7 @@ endif
hook:
[ ! -d "$(CURDIR)/.git/hooks" ] || ln -sf "$(CURDIR)/scripts/pre-commit.hook" "$(CURDIR)/.git/hooks/pre-commit"
$(GOPATHBIN)/easyjson: go.mod go.sum
$(GOPATHBIN)/easyjson: go.mod go.sum | $(TMPDIR)
$(GO) install github.com/mailru/easyjson/...
$(GOPATHBIN)/protoc-gen-go: go.mod go.sum
@ -124,7 +125,7 @@ coverhtml: vet
%_easyjson.go: %.go $(GOPATHBIN)/easyjson | $(PROTO_GO_FILES)
rm -f easyjson-bootstrap*.go
PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go
TMPDIR=$(TMPDIR) PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $*.go
%.pb.go: %.proto $(GOPATHBIN)/protoc-gen-go $(GOPATHBIN)/protoc-gen-go-grpc
PATH="$(GODIR)":"$(GOPATHBIN)":$(PATH) protoc \
@ -142,12 +143,15 @@ common: $(EASYJSON_GO_FILES) $(PROTO_GO_FILES) $(GRPC_PROTO_GO_FILES)
# Optimize easyjson files that could call generated functions instead of duplicating code.
for file in $(EASYJSON_FILES); do \
rm -f easyjson-bootstrap*.go; \
PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $$file; \
TMPDIR=$(TMPDIR) PATH="$(GODIR)":$(PATH) "$(GOPATHBIN)/easyjson" -all $$file; \
done
$(BINDIR):
mkdir -p "$(BINDIR)"
$(TMPDIR):
mkdir -p "$(TMPDIR)"
client: $(BINDIR)/client
$(BINDIR)/client: go.mod go.sum $(CLIENT_GO_FILES) $(COMMON_GO_FILES) | $(BINDIR)
@ -168,6 +172,7 @@ clean:
rm -f "$(BINDIR)/client"
rm -f "$(BINDIR)/signaling"
rm -f "$(BINDIR)/proxy"
rm -rf "$(TMPDIR)"
clean-generated: clean
rm -f $(EASYJSON_GO_FILES) $(PROTO_GO_FILES) $(GRPC_PROTO_GO_FILES)