mirror of
				https://github.com/taigrr/wtf
				synced 2025-01-18 04:03:14 -08:00 
			
		
		
		
	Improve the Makefile
Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
		
							parent
							
								
									b8c87c7dd8
								
							
						
					
					
						commit
						5a6424839d
					
				
							
								
								
									
										40
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								Makefile
									
									
									
									
									
								
							| @ -1,10 +1,11 @@ | |||||||
| .PHONY: build contrib_check coverage install isntall binary_msg lint run size test uninstall | .PHONY: build clean contrib_check coverage help install isntall binary_msg lint run size test uninstall | ||||||
| 
 | 
 | ||||||
| # detect GOPATH if not set
 | # detect GOPATH if not set
 | ||||||
| ifndef $(GOPATH) | ifndef $(GOPATH) | ||||||
| 	$(info GOPATH is not set, autodetecting..) | 	$(info GOPATH is not set, autodetecting..) | ||||||
| 	TESTPATH := $(dir $(abspath ../../..)) | 	TESTPATH := $(dir $(abspath ../../..)) | ||||||
| 	DIRS := bin pkg src | 	DIRS := bin pkg src | ||||||
|  | 
 | ||||||
| 	# create a ; separated line of tests and pass it to shell | 	# create a ; separated line of tests and pass it to shell | ||||||
| 	MISSING_DIRS := $(shell $(foreach entry,$(DIRS),test -d "$(TESTPATH)$(entry)" || echo "$(entry)";)) | 	MISSING_DIRS := $(shell $(foreach entry,$(DIRS),test -d "$(TESTPATH)$(entry)" || echo "$(entry)";)) | ||||||
| 	ifeq ($(MISSING_DIRS),) | 	ifeq ($(MISSING_DIRS),) | ||||||
| @ -23,43 +24,68 @@ export GOPROXY = https://proxy.golang.org,direct | |||||||
| # Determines the path to this Makefile
 | # Determines the path to this Makefile
 | ||||||
| THIS_FILE := $(lastword $(MAKEFILE_LIST)) | THIS_FILE := $(lastword $(MAKEFILE_LIST)) | ||||||
| 
 | 
 | ||||||
|  | APP=wtfutil | ||||||
|  | 
 | ||||||
| binary_msg: | binary_msg: | ||||||
| 	@echo "Install path: " | 	@echo "Install path: " | ||||||
| 
 | 
 | ||||||
|  | # -------------------- Actions -------------------- # 
 | ||||||
|  | 
 | ||||||
|  | ## build: builds a local version
 | ||||||
| build: | build: | ||||||
| 	go build -o bin/wtfutil | 	go build -o bin/${APP} | ||||||
| 	@$(MAKE) -f $(THIS_FILE) binary_msg | 	@$(MAKE) -f $(THIS_FILE) binary_msg | ||||||
| 
 | 
 | ||||||
|  | ## clean: removes old build cruft
 | ||||||
|  | clean: | ||||||
|  | 	rm -rf ./dist | ||||||
|  | 	rm -rf ./bin/${APP} | ||||||
|  | 
 | ||||||
|  | ## contrib-check: checks for any contributors who have not been given due credit
 | ||||||
| contrib_check: | contrib_check: | ||||||
| 	npx all-contributors-cli check | 	npx all-contributors-cli check | ||||||
| 
 | 
 | ||||||
|  | ## coverage: figures out and displays test code coverage
 | ||||||
| coverage: | coverage: | ||||||
| 	go test -coverprofile=coverage.out ./... | 	go test -coverprofile=coverage.out ./... | ||||||
| 	go tool cover -html=coverage.out | 	go tool cover -html=coverage.out | ||||||
| 
 | 
 | ||||||
|  | ## help: prints this help message
 | ||||||
|  | help: | ||||||
|  | 	@echo "Usage: \n" | ||||||
|  | 	@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' |  sed -e 's/^/ /' | ||||||
|  | 
 | ||||||
|  | ## isntall: an alias for 'install'
 | ||||||
| isntall: | isntall: | ||||||
| 	@$(MAKE) -f $(THIS_FILE) install | 	@$(MAKE) -f $(THIS_FILE) install | ||||||
| 
 | 
 | ||||||
|  | ## install: installs a local version of the app
 | ||||||
| install: | install: | ||||||
| 	@echo "Installing wtfutil..." | 	@echo "Installing ${APP}..." | ||||||
| 	@go clean | 	@go clean | ||||||
| 	@go install -ldflags="-s -w -X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)" | 	@go install -ldflags="-s -w -X main.version=$(shell git describe --always --abbrev=6) -X main.date=$(shell date +%FT%T%z)" | ||||||
| 	@mv ~/go/bin/wtf ~/go/bin/wtfutil | 	@mv ~/go/bin/wtf ~/go/bin/${APP} | ||||||
| 	@$(MAKE) -f $(THIS_FILE) binary_msg | 	@$(MAKE) -f $(THIS_FILE) binary_msg | ||||||
| 	@which wtfutil || echo "Could not find wtfutil in PATH" && exit 0 | 	@which ${APP} || echo "Could not find ${APP} in PATH" && exit 0 | ||||||
| 
 | 
 | ||||||
|  | ## lint: runs a number of code quality checks against the source code
 | ||||||
| lint: | lint: | ||||||
|  | 	go vet ./... | ||||||
| 	structcheck ./... | 	structcheck ./... | ||||||
| 	varcheck ./... | 	varcheck ./... | ||||||
| 
 | 
 | ||||||
|  | ## run: executes the locally-installed version
 | ||||||
| run: build | run: build | ||||||
| 	bin/wtfutil | 	bin/${APP} | ||||||
| 
 | 
 | ||||||
|  | ## size: displays the lines of code (LoC) count
 | ||||||
| size: | size: | ||||||
| 	loc --exclude _sample_configs/ _site/ docs/ Makefile *.md | 	loc --exclude _sample_configs/ _site/ docs/ Makefile *.md | ||||||
| 
 | 
 | ||||||
|  | ## test: runs the test suite
 | ||||||
| test: build | test: build | ||||||
| 	go test ./... | 	go test ./... | ||||||
| 
 | 
 | ||||||
|  | ## uninstall: uninstals a locally-installed version
 | ||||||
| uninstall: | uninstall: | ||||||
| 	@rm ~/go/bin/wtfutil | 	@rm ~/go/bin/${APP} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user