From bc6fe83493d02c6bfc043852668297587ef1435a Mon Sep 17 00:00:00 2001 From: "Alex Munene (@enenumxela)" <62714471+enenumxela@users.noreply.github.com> Date: Mon, 27 Nov 2023 21:12:42 +0300 Subject: [PATCH] build: - --- .gitignore | 6 +----- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 84bd03b..77a98d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,3 @@ # Executable -cmd/xcrawl3r/xcrawl3r - -# Notes - -notes.txt \ No newline at end of file +bin \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d5cb06c --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +# Go(Golang) Options +GOCMD=go +GOMOD=$(GOCMD) mod +GOGET=$(GOCMD) get +GOFMT=$(GOCMD) fmt +GOTEST=$(GOCMD) test +GOBUILD=$(GOCMD) build +GOINSTALL=$(GOCMD) install +GOFLAGS := -v +LDFLAGS := -s -w + +# Golangci Options +GOLANGCILINTCMD=golangci-lint +GOLANGCILINTRUN=$(GOLANGCILINTCMD) run + +ifneq ($(shell go env GOOS),darwin) +LDFLAGS := -extldflags "-static" +endif + +all: build + +.PHONY: tidy +tidy: + $(GOMOD) tidy + +.PHONY: update-deps +update-deps: + $(GOGET) -f -t -u ./... + $(GOGET) -f -u ./... + +.PHONY: _gofmt +_gofmt: + $(GOFMT) ./... + +.PHONY: _golangci-lint +_golangci-lint: + $(GOLANGCILINTRUN) $(GOLANGCILINT) ./... + +.PHONY: lint +lint: _gofmt _golangci-lint + +.PHONY: test +test: + $(GOTEST) $(GOFLAGS) ./... + +.PHONY: build +build: + $(GOBUILD) $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/xcrawl3r cmd/xcrawl3r/main.go + +.PHONY: install +install: + $(GOINSTALL) $(GOFLAGS) ./...