-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Makefile with build and install targets (#131)
- Loading branch information
Showing
2 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
/.vscode | ||
* | ||
!*/ | ||
!*.* | ||
build/ | ||
*.exe | ||
\.* | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/make -f | ||
BRANCH := $(shell git rev-parse --abbrev-ref HEAD) | ||
COMMIT := $(shell git log -1 --format='%H') | ||
TIME ?= $(shell date +%Y-%m-%dT%H:%M:%S%z) | ||
|
||
# don't override user values | ||
ifeq (,$(VERSION)) | ||
VERSION := $(shell git describe --tags) | ||
# if VERSION is empty, then populate it with branch's name and raw commit hash | ||
ifeq (,$(VERSION)) | ||
VERSION := $(BRANCH)-$(COMMIT) | ||
endif | ||
endif | ||
|
||
|
||
ldflags = -X github.com/dymensionxyz/roller/cmd/version.BuildVersion=$(VERSION) \ | ||
-X github.com/dymensionxyz/roller/cmd/version.BuildCommit=$(COMMIT) \ | ||
-X github.com/dymensionxyz/roller/cmd/version.BuildTime=$(TIME)" | ||
|
||
BUILD_FLAGS := -ldflags '$(ldflags)' | ||
# ---------------------------------------------------------------------------- # | ||
# Make targets # | ||
# ---------------------------------------------------------------------------- # | ||
.PHONY: install | ||
install: go.sum ## Installs the roller binary | ||
go install -mod=readonly $(BUILD_FLAGS) . | ||
|
||
|
||
.PHONY: build | ||
build: ## Compiles the roller binary | ||
go build -o build/roller $(BUILD_FLAGS) . |