From d3f6ead7b0c80e4a3bb5e077db1c678353f32fa4 Mon Sep 17 00:00:00 2001 From: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:52:38 +0300 Subject: [PATCH] feat: added Makefile with build and install targets (#131) --- .gitignore | 5 +---- Makefile | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index f75bab66..a99b0bf2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ /.vscode -* -!*/ -!*.* +build/ *.exe -\.* /.vscode \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..62b9e127 --- /dev/null +++ b/Makefile @@ -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) .