-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (123 loc) · 5.46 KB
/
Copy pathMakefile
File metadata and controls
142 lines (123 loc) · 5.46 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
SHELL := /usr/bin/bash
.SHELLFLAGS := -ec
BLUE := $(shell printf '\033[0;34m')
GREEN := $(shell printf '\033[0;32m')
YELLOW := $(shell printf '\033[0;33m')
RESET := $(shell printf '\033[0m')
CYAN := $(shell printf '\033[0;36m')
ORANGE := $(shell printf '\033[0;31m')
RED := $(shell printf '\033[0;31m')
SUCCESS := $(GREEN)✓
FAIL := $(RED)✗
INFO := $(CYAN)ℹ
WARN := $(YELLOW)⚠
# * Top row (╭━━━╮) - round corners, full-span
# * Bottom row (╰━━━╯) - round corners, full-span
# * Merge row (┣━━━┫) - full-span, left/right T junctions
# * Merge-bottom (╰━━━╯) - alias for kind 3
# * Column cross (┣━╋━┫) - cross junctions (columns above/below)
# * Column open (┣━┳━┫) - T-down (columns start below)
# * Column close (┣━┻━┫) - T-up (columns end above)
TOP_LEFT_CORNER := $(ORANGE)╭$(RESET)
TOP_RIGHT_CORNER := $(ORANGE)╮$(RESET)
BOTTOM_LEFT_CORNER := $(ORANGE)╰$(RESET)
BOTTOM_RIGHT_CORNER := $(ORANGE)╯$(RESET)
HORIZONTAL_LINE := $(ORANGE)━$(RESET)
VERTICAL_LINE := $(ORANGE)┃$(RESET)
LEFT_JUNCTION := $(ORANGE)┣$(RESET)
RIGHT_JUNCTION := $(ORANGE)┫$(RESET)
CROSS_JUNCTION := $(ORANGE)┣$(RESET)$(ORANGE)━$(RESET)$(ORANGE)┫$(RESET)
OPEN_JUNCTION := $(ORANGE)┣$(RESET)$(ORANGE)━$(RESET)$(ORANGE)┫$(RESET)
CLOSE_JUNCTION := $(ORANGE)┣$(RESET)$(ORANGE)━$(RESET)$(ORANGE)┫$(RESET)
.DEFAULT_GOAL := help
# Reusable text banner: $(call print_banner,Your message)
define print_banner
box_width=50; \
inner_width=$$((box_width - 2)); \
message="$(1)"; \
message_length=$${#message}; \
padding=$$((inner_width - message_length)); \
left_padding=$$((padding / 2)); \
right_padding=$$((padding - left_padding)); \
top_border="$(TOP_LEFT_CORNER)"; \
bottom_border="$(BOTTOM_LEFT_CORNER)"; \
horizontal_line="$(HORIZONTAL_LINE)"; \
vertical_line="$(VERTICAL_LINE)"; \
for ((i=0; i<box_width-2; i++)); do top_border="$$top_border$$horizontal_line"; bottom_border="$$bottom_border$$horizontal_line"; done; \
top_border="$$top_border$(TOP_RIGHT_CORNER)"; \
bottom_border="$$bottom_border$(BOTTOM_RIGHT_CORNER)"; \
printf "%s\n" "$$top_border"; \
printf "%s%*s%s%*s%s\n" "$$vertical_line" "$$left_padding" '' "$$message" "$$right_padding" '' "$$vertical_line"; \
printf "%s\n" "$$bottom_border"
endef
define print_error
echo -e "$(FAIL) $(1)$(RESET)"
endef
define print_success
echo -e "$(SUCCESS) $(1)$(RESET)"
endef
.PHONY: help
help: ## Show available targets
@$(call print_banner,Available Makefile Targets)
@echo ""
@grep -hE '^[a-zA-Z_-]+:.*## .*$$' Makefile | \
awk 'BEGIN {FS = ":.*## "}; {printf " $(CYAN)%-35s$(RESET) %s\n", $$1, $$2}'
@echo ""
# ── Utils ────────────────────────────────────────────────────────────────
.PHONY: update-submodules
update-submodules: ## Update git submodules
@$(call print_banner,Updating Git Submodules)
@./update_submodules.sh
@$(call print_success,Git submodules updated successfully!)
.PHONY: clone-scripts-submodule
clone-scripts-submodule: ## Clone the scripts submodule
@$(call print_banner,Cloning Scripts Submodule)
@git submodule add https://github.com/danielfdez17/scripts.git ./vendor/scripts
@$(call print_success,Scripts submodule cloned successfully!)
.PHONY: remove-scripts-submodule
remove-scripts-submodule: ## Remove the scripts submodule
@$(call print_banner,Removing Scripts Submodule)
@./remove_submodule.sh vendor/scripts
@$(call print_success,Scripts submodule removed successfully!)
.PHONY: merge-to-dev
merge-to-dev: ## Merge the current branch into 'develop'
@$(call print_banner,Merging Current Branch into 'dev')
@./merge_to_dev.sh
@$(call print_success,Current branch merged into 'dev' successfully!)
.PHONY: merge-dev-to-main
merge-dev-to-main: ## Merge 'develop' into 'main'
@$(call print_banner,Merging 'develop' into 'main')
@./merge_dev_to_main.sh
@$(call print_success,'develop' merged into 'main' successfully!)
.PHONY: push-to-origin
push-to-origin: ## Push the current branch to 'origin'
@$(call print_banner,Pushing Current Branch to 'origin')
@./push_to_origin.sh
@$(call print_success,Current branch pushed to 'origin' successfully!)
.PHONY: clone-transcendence-repositories
clone-transcendence-repositories: ## Clone all Transcendence repositories listed in transcendence_local.txt
@$(call print_banner,Cloning Transcendence Repositories)
@./42/transcendence/clone_transcendence_repos.sh
@$(call print_success,Transcendence repositories cloned successfully!)
.PHONY: collect-git-commit-history
collect-git-commit-history: ## Collect git commit history into a file
@$(MAKE) -s clone-transcendence-repositories
@$(call print_banner,Collecting Git Commit History)
@./42/transcendence/create_commit_history.sh
@$(call print_success,Git commit history collected successfully!)
.PHONY: lint-bash-scripts
lint-bash-scripts: ## Lint all bash scripts in the repository
@$(call print_banner,Linting Bash Scripts)
@./lint_bash_scripts.sh
@$(call print_success,Bash scripts linted successfully!)
.PHONY: lint-python-scripts
lint-python-scripts: ## Lint all Python scripts in the repository
@$(call print_banner,Linting Python Scripts)
@./lint_python_scripts.py
@$(call print_success,Python scripts linted successfully!)
.PHONY: lint
lint: ## Lint all bash and Python scripts
@$(call print_banner,Linting All Scripts)
@$(MAKE) -s lint-bash-scripts
@$(MAKE) -s lint-python-scripts
@$(call print_success,All scripts linted successfully!)