From f22d1e04559236f2b5dba1ea6b0db02dcd2d5d01 Mon Sep 17 00:00:00 2001 From: Lifailon Date: Tue, 9 Sep 2025 11:51:48 +0300 Subject: [PATCH] updated to multithreaded build --- Makefile | 79 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 81a7963..6a38afc 100644 --- a/Makefile +++ b/Makefile @@ -7,24 +7,24 @@ prep: @go build -o /dev/null -v ./... clean: - @go clean -cache -modcache -testcache + go clean -cache -modcache -testcache update: prep go get -u ./... -install-lint: +lint-install: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest go install github.com/go-critic/go-critic/cmd/gocritic@latest go install github.com/securego/gosec/v2/cmd/gosec@latest -lint: prep install-lint +lint-check: prep lint-install golangci-lint run ./main.go gocritic check -enableAll ./main.go gosec -severity=high ./... -list: +test-list: @go test -list . ./... - @echo To run the selected test: make test n=TestMain + @echo "\nTo run the selected test: \033[32mmake test n=TestMain\033[0m\n" test: prep go test -v -cover --run $(n) ./... @@ -32,6 +32,49 @@ test: prep test-all: prep go test -v -cover ./... +VERSION := $(shell go run main.go -v) + +build-clear: + @rm -rf bin + +build-linux-amd64: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/lazyjournal-$(VERSION)-linux-amd64 + +build-linux-arm64: + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o bin/lazyjournal-$(VERSION)-linux-arm64 + +build-darwin-amd64: + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o bin/lazyjournal-$(VERSION)-darwin-amd64 + +build-darwin-arm64: + CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o bin/lazyjournal-$(VERSION)-darwin-arm64 + +build-openbsd-amd64: + CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -o bin/lazyjournal-$(VERSION)-openbsd-amd64 + +build-openbsd-arm64: + CGO_ENABLED=0 GOOS=openbsd GOARCH=arm64 go build -o bin/lazyjournal-$(VERSION)-openbsd-arm64 + +build-freebsd-amd64: + CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o bin/lazyjournal-$(VERSION)-freebsd-amd64 + +build-freebsd-arm64: + CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -o bin/lazyjournal-$(VERSION)-freebsd-arm64 + +build-windows-amd64: + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/lazyjournal-$(VERSION)-windows-amd64.exe + +build-windows-arm64: + CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -o bin/lazyjournal-$(VERSION)-windows-arm64.exe + +build-all-amd64: build-linux-amd64 build-darwin-amd64 build-openbsd-amd64 build-freebsd-amd64 build-windows-amd64 + +build-all-arm64: build-linux-arm64 build-darwin-arm64 build-openbsd-arm64 build-freebsd-arm64 build-windows-arm64 + +build-all: build-clear + @make -j 10 build-all-amd64 build-all-arm64 + @ls -lh bin + OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') ARCH := $(shell uname -m) ifeq ($(ARCH),x86_64) @@ -40,34 +83,18 @@ else ifeq ($(ARCH),aarch64) ARCH := arm64 endif -build: +build-local: @CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o lazyjournal -run: build +run: build-local @./lazyjournal @rm ./lazyjournal BINPATH := $(HOME)/.local/bin -install: build +install: build-local @mkdir -p $(BINPATH) @mv ./lazyjournal $(BINPATH)/lazyjournal -VERSION := $(shell go run main.go -v) -OS_LIST := linux darwin openbsd freebsd windows -ARCH_LIST := amd64 arm64 - -build-all: prep - @rm -rf bin - @echo "Build version: $(VERSION)" - @for os in $(OS_LIST); do \ - for arch in $(ARCH_LIST); do \ - ext=""; \ - if [ "$$os" = "windows" ]; then \ - ext=".exe"; \ - fi; \ - echo "Build lazyjournal-$(VERSION)-$$os-$$arch$$ext"; \ - CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o bin/lazyjournal-$(VERSION)-$$os-$$arch$$ext || exit 1; \ - done; \ - done - @ls -lh bin \ No newline at end of file +uninstall: + rm -f $(shell which lazyjournal) \ No newline at end of file