Skip to content

Commit

Permalink
feat: added Makefile with build and install targets (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jun 29, 2023
1 parent d025248 commit d3f6ead
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/.vscode
*
!*/
!*.*
build/
*.exe
\.*
/.vscode
31 changes: 31 additions & 0 deletions Makefile
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) .

0 comments on commit d3f6ead

Please sign in to comment.