|
| 1 | +##################### CARAVELA's MAKEFILE ######################### |
| 2 | +GOCMD=go |
| 3 | + |
| 4 | +######### Builtin GO tools ######### |
| 5 | +GOBUILD=$(GOCMD) build |
| 6 | +GOINSTALL=$(GOCMD) install |
| 7 | +GOCLEAN=$(GOCMD) clean |
| 8 | +GOTEST=$(GOCMD) test |
| 9 | +GOVET=$(GOCMD) vet |
| 10 | + |
| 11 | +GOGET=$(GOCMD) get |
| 12 | + |
| 13 | +######### External GO tools ######### |
| 14 | +GOLINT=golint |
| 15 | +GOCOV=gocov |
| 16 | +GOCOVHTML=gocov-html |
| 17 | +GODEPGRAPH=godepgraph |
| 18 | + |
| 19 | +############ Output Files ########### |
| 20 | +EXE=.exe |
| 21 | +BINARY_NAME=caravela$(EXE) |
| 22 | +BINARY_NAME_LINUX=$(BINARY_NAME)_linux$(EXE) |
| 23 | +BINARY_NAME_WIN=$(BINARY_NAME)_win$(EXE) |
| 24 | + |
| 25 | +############################## COMMANDS ############################ |
| 26 | + |
| 27 | +all: test build |
| 28 | + |
| 29 | +build: |
| 30 | +@echo Building for the current machine settings... |
| 31 | +$(GOBUILD) -o $(BINARY_NAME) -v |
| 32 | + |
| 33 | +build-linux: |
| 34 | +@echo Building for linux... |
| 35 | +env GOOS=linux $(GOBUILD) -o $(BINARY_NAME) -v |
| 36 | + |
| 37 | +build-windows: |
| 38 | +@echo Building for windows... |
| 39 | +env GOOS=windows $(GOBUILD) -o $(BINARY_NAME) -v |
| 40 | + |
| 41 | +clean: |
| 42 | +@echo Cleaning project... |
| 43 | +$(GOCLEAN) |
| 44 | +rm -f $(BINARY_NAME) |
| 45 | +rm -f $(BINARY_NAME_LINUX) |
| 46 | +rm -f $(BINARY_NAME_WIN) |
| 47 | + |
| 48 | +install: |
| 49 | +@echo Installing CARAVELA in the local GO environment... |
| 50 | +$(GOINSTALL) -v -gcflags "-N -l" . |
| 51 | + |
| 52 | +test: |
| 53 | +@echo Testing... |
| 54 | +$(GOTEST) -v ./... |
| 55 | + |
| 56 | +test-cov: |
| 57 | +@echo Testing and coverage report generation... |
| 58 | +$(GOCOV) test ./... | $(GOCOVHTML) > coverage.html |
| 59 | + |
| 60 | +test-verify: |
| 61 | +$(MAKE) test |
| 62 | +@echo Running vet tool to static analyze the code |
| 63 | +$(GOVET) -v ./... |
| 64 | +@echo Running lint tool to static analyze the code style |
| 65 | + |
| 66 | +dep-graph: |
| 67 | +@echo Generating package import dependency graph... |
| 68 | +$(GODEPGRAPH) -s -p github.com/docker github.com/strabox/caravela | dot -Tpng -o importsGraph.png |
| 69 | + |
| 70 | +docker-build: |
| 71 | +@echo Building Docker container... |
| 72 | +docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest . |
| 73 | + |
| 74 | +docker-upload: |
| 75 | +@echo Building Docker container and uploading to DockerHub... |
| 76 | +docker build --build-arg exec_file=$(BINARY_NAME) --rm -t strabox/caravela:latest . |
| 77 | +docker push strabox/caravela:latest |
| 78 | + |
| 79 | +install-external-tools: |
| 80 | +@echo Installing external tools... |
| 81 | +@echo Installing lint - Code style analyzer (from google) |
| 82 | +$(GOGET) github.com/golang/lint |
| 83 | +@echo Installing gocov - Code coverage generator |
| 84 | +$(GOGET) github.com/axw/gocov/gocov |
| 85 | +@echo Installing gocov-html - Code coverage html generator |
| 86 | +$(GOGET) -u gopkg.in/matm/v1/gocov-html |
| 87 | +@echo Installing godepgraph - Code package dependency graph generator |
| 88 | +$(GOGET) github.com/kisielk/godepgraph |
| 89 | + |
0 commit comments