Skip to content

Commit

Permalink
Set private GOCACHE directory; blow it away before builds
Browse files Browse the repository at this point in the history
Some CGO-related environment variables don't seem to factor into cache
keys; this likely led to the cause for MacOSX builds being obscured.
  • Loading branch information
hillu committed Nov 21, 2024
1 parent eaed7fb commit 0ade08b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SED := $(firstword $(shell which gsed sed))
TAR := $(firstword $(shell which gtar tar))

export GOPATH=$(CURDIR)/_gopath
export GOCACHE=$(CURDIR)/_gopath/cache

# Do not accidentally uss GNU binutils from Homebrew on MacOSX.
export PATH := $(subst /usr/local/opt/binutils/bin:,,$(PATH))
Expand Down Expand Up @@ -89,6 +90,7 @@ unit-test: test_pathspec ?= $(NAMESPACE)/...
unit-test: test_flags ?= -v
unit-test: extldflags = $(if $(findstring darwin,$(shell $(GOROOT)/bin/go env GOOS)),,-static)
unit-test:
-find _gopath/cache -type f | xargs rm -f 2>/dev/null
$(info [+] Running tests...)
$(info [+] test_flags=$(test_flags) test_pathspec=$(test_pathspec))
$(info [+] GOROOT=$(GOROOT) GOOS=$(GOOS) GOARCH=$(GOARCH) CC=$(CC))
Expand All @@ -98,14 +100,14 @@ unit-test:
-ldflags '-w -s -linkmode=external -extldflags "$(extldflags)"' \
-tags yara_static \
$(test_pathspec)
find `go env GOCACHE)` -type f | xargs rm -f

$(EXE) unit-test: $(GOFILES) $(RCFILES) Makefile 3rdparty.mk 3rdparty-all.stamp

# If VERSIONSUFFIX is passed to Makefile, override spyre.Version iv linker flag
$(EXE): VERSIONDEF := $(if $(VERSIONSUFFIX),-X $(NAMESPACE).Version=$(VERSION)$(VERSIONSUFFIX))

$(EXE):
-find _gopath/cache -type f | xargs rm -f 2>/dev/null
$(info [+] Building spyre...)
$(info [+] GOROOT=$(GOROOT) GOOS=$(GOOS) GOARCH=$(GOARCH) CC=$(CC))
$(info [+] PKG_CONFIG_PATH=$(PKG_CONFIG_PATH))
Expand All @@ -116,7 +118,6 @@ $(EXE):
-ldflags '$(VERSIONDEF) -w -s -linkmode=external -extldflags "$(extldflags)"' \
-tags yara_static \
-o $@ $(NAMESPACE)/cmd/spyre
find `go env GOCACHE)` -type f | xargs rm -f

.PHONY: release
release: spyre-$(VERSION)$(VERSIONSUFFIX).zip
Expand Down

0 comments on commit 0ade08b

Please sign in to comment.