Skip to content

Commit

Permalink
Merge pull request #45 from wish/one-os-build
Browse files Browse the repository at this point in the history
update single build to cover linux and mac operating systems
  • Loading branch information
axia-wish authored May 16, 2022
2 parents 2282171 + f6c6cf0 commit 70f2336
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ GIT := $(shell git rev-parse --short HEAD)
DIRTY := $(shell git diff-index --quiet HEAD 2> /dev/null > /dev/null || echo "-dirty")


default: build/dev.${UNAME_S} build/dev ## Builds dev for your current operating system and runs tests
default: build/dev ## Builds dev for your current operating system and runs tests

.PHONY: help
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: all
all: build/dev.linux build/dev.darwin ## Builds dev binaries for linux and osx
all: build/dev ## Builds dev binaries for all operating systems

.PHONY: clean
clean: ## Removes all build artifacts
Expand All @@ -40,18 +40,12 @@ test:
.PHONY: checks
checks: lint vet test ## Run static analysis and tests

build/dev.linux: $(GOFILES_BUILD) ## Creates the linux binary
@GOOS=linux CGO_ENABLED=0 go build -ldflags \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(GIT)${DIRTY}" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)${V_DIRTY}"' \
-o build/dev.linux -mod=vendor cmd/dev/*

build/dev.darwin: $(GOFILES_BUILD) ## Creates the osx binary
@GOOS=darwin CGO_ENABLED=0 go build -ldflags \
build/dev: ## Make a link to the executable for this OS type for convenience
@CGO_ENABLED=0 go build -ldflags \
'-X "github.com/wish/dev/cmd.BuildDate=${DATE}" -X "github.com/wish/dev/cmd.BuildSha=$(GIT)${DIRTY}" -X "github.com/wish/dev/cmd.BuildVersion=$(VERSION)${V_DIRTY}"' \
-o build/dev.darwin -mod=vendor cmd/dev/*
-o build/dev -mod=vendor cmd/dev/*

build/dev: ## Make a link to the executable for this OS type for convenience
$(shell mkdir -p build; ln -s dev.${UNAME_S} build/dev)
$(shell mkdir -p build; ln -s build/dev)

.PHONY: watch
watch: ## Watch .go files for changes and rerun build (requires entr, see https://github.com/clibs/entr)
Expand Down

0 comments on commit 70f2336

Please sign in to comment.