Skip to content
Snippets Groups Projects
Select Git revision
  • 7424b9aca56ec5f4d818b1bed9861856ecd9d859
  • master default protected
  • v1.16.5
  • v1.16.4
  • v1.16.3
  • v1.16.2
  • v1.16.1
  • v1.16.0
  • v1.15.0
  • v1.14.0
  • v1.13.2
  • v1.13.1
  • v1.13.0
  • v1.12.0
  • v1.11.0
  • v1.10.2
  • v1.10.1
  • v1.10.0
  • v1.9.0
  • v1.8.3
  • v1.8.2
  • v1.8.1
22 results

Makefile

Blame
  • Makefile 5.11 KiB
    PROJECT_ROOT:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
    THIS_MAKEFILE:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
    THIS_MAKEFILE_PATH:=$(PROJECT_ROOT)$(THIS_MAKEFILE) 
    
    # @see .PHONY https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
    .DEFAULT_GOAL := help
    
    .PHONY: print
    ## Print Path	
    print:
    	@echo "THIS_MAKEFILE:      $(THIS_MAKEFILE)"
    	@echo "THIS_MAKEFILE_PATH: $(THIS_MAKEFILE_PATH)"
    	@echo "PROJECT_ROOT:       $(PROJECT_ROOT)"
    
    # Add a comment to the public targets so that it appears
    # in this help Use two # characters for a help comment
    .PHONY: help
    help:
    	@printf "${COMMENT}Usage:${RESET}\n"
    	@printf " make [target] [arg=\"val\"...]\n\n"
    	@printf "${COMMENT}Available targets:${RESET}\n"
    	@awk '/^[a-zA-Z\-\\_0-9\.@]+:/ { \
    		helpMessage = match(lastLine, /^## (.*)/); \
    		if (helpMessage) { \
    			helpCommand = substr($$1, 0, index($$1, ":")); \
    			helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
    			printf " ${INFO}%-22s${RESET} %s\n", helpCommand, helpMessage; \
    		} \
    	} \
    	{ lastLine = $$0 }' $(MAKEFILE_LIST)
    	@printf "\n${COMMENT}Available arguments:${RESET}\n\n"
    	@awk '/^(([a-zA-Z\-\\_0-9\.@]+)\s[?:]?=)/ { \
    		helpMessage = match(lastLine, /^## (.*)/); \
    		if (helpMessage) { \
    			helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
    			printf " ${INFO}%-22s${RESET} %s (Default: %s)\n", $$1, helpMessage, $$3; \
    		} \
    	} \
    	{ lastLine = $$0 }' $(MAKEFILE_LIST)
    
    
    ## run tests
    test:
    	echo "Running tests"
    	go test -cover -v ./...
    
    ## run tests with fuzzing
    test-fuzz:
    	echo "Running fuzz tests"
    	go test -v -fuzztime=30s -fuzz=Fuzz ./...
    
    #### VERSION
    BIN_DIR ?= $(shell echo $$HOME)/.local/bin/
    VERSION_NAME 	     := version
    EXECUTABLES = $(EXECUTABLES:-) $(VERSION_NAME)
    VERSION_BIN_PATH := $(BIN_DIR)$(VERSION_NAME)
    
    VERSION_BIN := $(shell command -v $(VERSION_NAME) 2> /dev/null)
    
    ifndef VERSION_BIN
        $(shell curl -o $(VERSION_BIN_PATH) http://download.schukai.com/tools/version/version-$(shell uname -s | tr [:upper:] [:lower:])-$(shell echo `uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/`))
        $(shell chmod +x $(VERSION_BIN_PATH))
    endif
    
    GIT_CHGLOG_BIN := $(shell command -v git-chglog 2> /dev/null)
    
    ifeq ($(GIT_CHGLOG_BIN),)
        $(shell go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest)
    endif