generated from Chemaclass/bash-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (75 loc) · 2.1 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
SHELL=/bin/bash
-include .env
STATIC_ANALYSIS_CHECKER := $(shell which shellcheck 2> /dev/null)
LINTER_CHECKER := $(shell which ec 2> /dev/null)
GIT_DIR = $(shell git rev-parse --git-dir 2> /dev/null)
OS:=
ifeq ($(OS),Windows_NT)
OS +=WIN32
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
OS +=_AMD64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
OS +=_IA32
endif
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS+=LINUX
endif
ifeq ($(UNAME_S),Darwin)
OS+=OSX
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
OS +=_AMD64
endif
ifneq ($(filter %86,$(UNAME_P)),)
OS+=_IA32
endif
ifneq ($(filter arm%,$(UNAME_P)),)
OS+=_ARM
endif
endif
help:
@echo ""
@echo "Usage: make [command]"
@echo ""
@echo "Commands:"
@echo " test Run the tests"
@echo " pre_commit/install Install the pre-commit hook"
@echo " pre_commit/run Function that will be called when the pre-commit hook runs"
@echo " sa Run shellcheck static analysis tool"
@echo " lint Run editorconfig linter tool"
SRC_SCRIPTS_DIR=src
PRE_COMMIT_SCRIPTS_FILE=./bin/pre-commit
pre_commit/install:
@echo "Installing pre-commit hook"
cp $(PRE_COMMIT_SCRIPTS_FILE) $(GIT_DIR)/hooks/
pre_commit/run: test sa lint
sa:
ifndef STATIC_ANALYSIS_CHECKER
@printf "\e[1m\e[31m%s\e[0m\n" "Shellcheck not installed: Static analysis not performed!" && exit 1
else
@shellcheck ./**/**/*.sh -C && printf "\e[1m\e[32m%s\e[0m\n" "ShellCheck: OK!"
endif
lint:
ifndef LINTER_CHECKER
@printf "\e[1m\e[31m%s\e[0m\n" "Editorconfig not installed: Lint not performed!" && exit 1
else
@ec -config .editorconfig && printf "\e[1m\e[32m%s\e[0m\n" "editorconfig-check: OK!"
endif
install:
@./install-dependencies.sh
create-pr:
@if [ ! -f lib/create-pr ]; then \
echo "Error: lib/create-pr not found. Did you forgot to './install-dependencies.sh'?"; \
exit 1; \
fi
@lib/create-pr -e .env.tools
test:
@if [ ! -f lib/bashunit ]; then \
echo "Error: lib/bashunit not found. Did you forgot to './install-dependencies.sh'?"; \
exit 1; \
fi
@lib/bashunit -e .env.tools