Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -race flag for dev builds #10

Merged
merged 1 commit into from
Mar 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

export GO111MODULE ?= on
export GOARCH ?= amd64
export CGO_ENABLED ?= 0

PROJECT ?= rakkess
REPOPATH ?= github.com/corneliusweig/$(PROJECT)
COMMIT := $(shell git rev-parse HEAD)
Expand All @@ -22,8 +26,8 @@ GOPATH ?= $(shell go env GOPATH)
BUILDDIR := out
PLATFORMS ?= linux windows darwin
DISTFILE := $(BUILDDIR)/$(VERSION).tar.gz
TARGETS := $(patsubst %,$(BUILDDIR)/$(PROJECT)-%-amd64,$(PLATFORMS))
ASSETS := $(BUILDDIR)/rakkess-linux-amd64.gz $(BUILDDIR)/rakkess-darwin-amd64.gz $(BUILDDIR)/rakkess-windows-amd64.zip
TARGETS := $(patsubst %,$(BUILDDIR)/$(PROJECT)-%-$(GOARCH),$(PLATFORMS))
ASSETS := $(BUILDDIR)/rakkess-linux-$(GOARCH).gz $(BUILDDIR)/rakkess-darwin-$(GOARCH).gz $(BUILDDIR)/rakkess-windows-$(GOARCH).zip
BUNDLE := $(BUILDDIR)/bundle.tar.gz
CHECKSUMS := $(patsubst %,%.sha256,$(ASSETS))
CHECKSUMS += $(BUNDLE).sha256
Expand All @@ -40,7 +44,7 @@ GO_FILES := $(shell find . -type f -name '*.go')

.PHONY: test
test:
GO111MODULE=on go test ./...
go test ./...

.PHONY: help
help:
Expand All @@ -57,19 +61,21 @@ help:

.PHONY: coverage
coverage: $(BUILDDIR)
GO111MODULE=on go test -coverprofile=$(BUILDDIR)/coverage.txt -covermode=atomic ./...
go test -coverprofile=$(BUILDDIR)/coverage.txt -covermode=atomic ./...

.PHONY: all
all: $(TARGETS)

.PHONY: dev
dev: $(BUILDDIR)/rakkess-linux-amd64
dev: GO_FLAGS := -race
dev: CGO_ENABLED := 1
dev: $(BUILDDIR)/rakkess-linux-$(GOARCH)
@mv $< $(PROJECT)

$(BUILDDIR)/$(PROJECT)-%-amd64: $(GO_FILES) $(BUILDDIR)
GO111MODULE=on GOARCH=amd64 CGO_ENABLED=0 GOOS=$* go build -ldflags $(GO_LDFLAGS) -o $@ main.go
$(BUILDDIR)/$(PROJECT)-%-$(GOARCH): $(GO_FILES) $(BUILDDIR)
GOOS=$* go build $(GO_FLAGS) -ldflags $(GO_LDFLAGS) -o $@ main.go

install: $(BUILDDIR)/$(PROJECT)-$(GOOS)-amd64
install: $(BUILDDIR)/$(PROJECT)-$(GOOS)-$(GOARCH)
@mv -i $< $(GOPATH)/bin/$(PROJECT)

.PHONY: lint
Expand Down