Skip to content

Commit eaa843a

Browse files
Add makefile (#25)
* Add makefile Adds makefile. * Fixing gocmd --------- Co-authored-by: juanito87 <juancruz.f87@gmail.com>
1 parent 0aa9733 commit eaa843a

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22

33
go-carbites-commp
4+
cmd/data-prep/data-prep

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
GOCMD=go
2+
GOBUILD=$(GOCMD) build
3+
GOCLEAN=$(GOCMD) clean
4+
GOTEST=$(GOCMD) test
5+
GOGET=$(GOCMD) get
6+
GOINSTALL=$(GOCMD) install
7+
8+
# These are the values we want to pass for VERSION and BUILD
9+
# git tag 1.0.1
10+
# git commit -am "One more change after the tags"
11+
VERSION=`git describe --tags`
12+
BRANCH=`git rev-parse --abbrev-ref HEAD`
13+
REVISION=`git rev-parse HEAD`
14+
BUILD=`date +%FT%T%z`
15+
16+
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD} -X main.Branch=${BRANCH} -X main.Revision=${REVISION}"
17+
BINDIR=.
18+
19+
all: build install
20+
21+
build:
22+
cd cmd/data-prep; \
23+
$(GOBUILD) $(LDFLAGS)
24+
25+
install:
26+
cd cmd/data-prep; \
27+
$(GOINSTALL) $(LDFLAGS)
28+
29+
clean:
30+
if [ -f ./cmd/data-prep/data-prep ] ; then rm ./cmd/data-prep/data-prep ; fi
31+
32+
.PHONY: clean install
33+

cmd/data-prep/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,21 @@ import (
88
"os"
99
)
1010

11+
var (
12+
Version = ""
13+
Revision = ""
14+
Build = ""
15+
Branch = ""
16+
)
17+
1118
func main() {
19+
cli.VersionPrinter = func(cCtx *cli.Context) {
20+
fmt.Printf("version=%s revision=%s build=%s branch=%s\n", cCtx.App.Version, Revision, Build, Branch)
21+
}
22+
1223
app := cli.NewApp()
1324
app.Name = "fil-dataprep"
25+
app.Version = Version
1426
app.Usage = "Chunking for CAR files + calculating commP. Splits a CAR file into smaller CAR files and at the same time also calculates commP for the smaller CAR files."
1527
app.Commands = []*cli.Command{
1628
split_and_commp.Cmd,

0 commit comments

Comments
 (0)