Skip to content

Commit

Permalink
feat: add make install
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincenzo authored and Vincenzo committed Sep 29, 2024
1 parent b2c5551 commit 487991a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
56 changes: 47 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ USER=$(shell id -u -n)
TIME=$(shell date)
JR_HOME=jr

GOLANCI_LINT_VERSION ?= v1.61.0
GOVULNCHECK_VERSION ?= latest

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
LOCALBIN := $(PROJECT_PATH)/bin

ifndef XDG_DATA_DIRS
ifeq ($(OS), Windows_NT)
detectedOS := Windows
Expand All @@ -12,16 +19,16 @@ else
endif

ifeq ($(detectedOS), Darwin)
JR_SYSTEM_DIR="$(HOME)/Library/Application Support"
JR_SYSTEM_DIR=/Library/Application Support
endif
ifeq ($(detectedOS), Linux)
JR_SYSTEM_DIR="$(HOME)/.config"
JR_SYSTEM_DIR=/usr/local/share
endif
ifeq ($(detectedOS), Windows_NT)
JR_SYSTEM_DIR="$(LOCALAPPDATA)"
JR_SYSTEM_DIR=$(APPDATA)
endif
else
JR_SYSTEM_DIR=$(XDG_DATA_DIRS)
JR_SYSTEM_DIR=$(XDG_DATA_DIRS[0])
endif

ifndef XDG_DATA_HOME
Expand All @@ -32,13 +39,13 @@ else
endif

ifeq ($(detectedOS), Darwin)
JR_USER_DIR="$(HOME)/.local/share"
JR_USER_DIR=$(HOME)/Library/Application Support
endif
ifeq ($(detectedOS), Linux)
JR_USER_DIR="$(HOME)/.local/share"
JR_USER_DIR=$(HOME)/.local/share
endif
ifeq ($(detectedOS), Windows_NT)
JR_USER_DIR="$(LOCALAPPDATA)" //@TODO
JR_USER_DIR=$(LOCALAPPDATA)
endif
else
JR_USER_DIR=$(XDG_DATA_HOME)
Expand Down Expand Up @@ -104,15 +111,46 @@ dep:
vet:
go vet

lint:
golangci-lint run --config .localci/lint/golangci.yml
.PHONY: lint
lint: golangci-lint
$(LOCALBIN)/golangci-lint cache clean
$(LOCALBIN)/golangci-lint run --config .localci/lint/golangci.yml

.PHONY: vuln
vuln: govulncheck
$(LOCALBIN)/govulncheck -show verbose ./...

.PHONY: check
check: vet lint vuln

help: hello
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}all${RESET}'
@echo ''

install: pluginsdir
for plugin in $(PLUGINS); do \
echo "installing plugin jr-$$plugin"; \
install build/jr-$$plugin "$(JR_SYSTEM_DIR)/jr/plugins/"; \
done

all: hello compile
all_offline: hello compile


$(LOCALBIN):
mkdir -p $(LOCALBIN)

.PHONY: golangci-lint
golangci-lint: $(LOCALBIN)
@test -s $(LOCALBIN)/golangci-lint || \
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANCI_LINT_VERSION)

.PHONY: govulncheck
govulncheck: $(LOCALBIN)
@test -s $(LOCALBIN)/govulncheck || \
GOBIN=$(LOCALBIN) go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION)

pluginsdir:
mkdir -p "$(JR_SYSTEM_DIR)/jr/plugins"
2 changes: 2 additions & 0 deletions make_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
make all
sudo make install

0 comments on commit 487991a

Please sign in to comment.