From 9d07bc6e15850b7f74555c97b9d2995a0573c8db Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Mon, 11 Aug 2025 22:20:29 +0200 Subject: [PATCH] Adaption of rspec to new Makefile concept --- requirements/.venv_required | 0 requirements/Makefile | 134 ++++++++++++++++++++++++++++++- requirements/__make.d__/rspec.mk | 1 + requirements/rspec | 2 +- 4 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 requirements/.venv_required mode change 120000 => 100644 requirements/Makefile create mode 120000 requirements/__make.d__/rspec.mk diff --git a/requirements/.venv_required b/requirements/.venv_required new file mode 100644 index 0000000..e69de29 diff --git a/requirements/Makefile b/requirements/Makefile deleted file mode 120000 index 6d12a84..0000000 --- a/requirements/Makefile +++ /dev/null @@ -1 +0,0 @@ -rspec/Makefile \ No newline at end of file diff --git a/requirements/Makefile b/requirements/Makefile new file mode 100644 index 0000000..9f48de2 --- /dev/null +++ b/requirements/Makefile @@ -0,0 +1,133 @@ +# git helper Makefile: Version 2.4 (2025-08-11) +default: help + +.ONESHELL: +SHELL = /usr/bin/bash +MAKEFLAGS += --no-print-directory +.SILENT: + +-include __make.d__/*.mk + +GIT_FLAG = ./.git +VENV_FLAG = ./.venv_required +VENV_FOLDER = ./venv + +localhelp: + +help: + echo "Possible common options are:" + echo " - init - Initialise the repository and all folders below with a Makefile" + echo " - giti - Get the git status of all submodules including their submodules" + echo " - update_submodules - Set all submodules to remote master" + echo " - venv_flag - Set the venev flag for the base folder. A venv will be generated" + echo " - clean - clean up" + echo " - deepclean - clean up this and all Makefiles below" + $(MAKE) localhelp + echo "You are able to create files make.d/*.mk and add local rules there. " + echo " - localinit: print_head - Will be executed as last step in the init process." + echo " - localhelp: print_head - Will be executed in th middle of the help text generation" + echo " - localclean:print_head - Will be executed before the clean rule" + +localinit: + +init: print_head + # Init git repo + if [[ -e $(GIT_FLAG) ]]; then + echo -e "\033[1;33mInitialising git submodules...\e[0m" + git submodule init + git submodule update + echo + fi + # Init submodules + SUBDIRS=$$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort) + for subdir in $$SUBDIRS; do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) init + done + if [[ $$SUBDIRS = *[![:space:]]* ]]; then + $(MAKE) print_head + fi + # Create venv if needed + if [[ -e $(VENV_FLAG) ]]; then + BASEPATH=$$(pwd -P) + # + # Create venv + # + if [ ! -e venv ];then + echo -e "\033[1;33mCreating venv in $$BASEPATH...\e[0m" + python3 -m venv $$BASEPATH/venv > /dev/null 2>&1 + else + echo -e "\033[1;33mVirtualenv already exists in $$BASEPATH...\e[0m" + fi + echo + + # + # Install modules + # + echo -e "\033[1;33mInstalling modules to venv in $$BASEPATH...\e[0m" + for req_file in $$(find $$BASEPATH -name requirements.txt); do + # echo " $$req_file" + while read req_mod; do + if [[ $$req_mod = *[![:space:]]* ]]; then + # req_mod is not empty + OUT=$$($$BASEPATH/venv/bin/pip install -U $$req_mod 2>&1 ) + if [[ $$OUT =~ "Successfully installed" ]]; then + echo -e " * \033[1;32m$$req_mod installed.\e[0m" + elif [[ $$OUT =~ "already satisfied" ]]; then + echo -e " * \033[1;36m$$req_mod already installed.\e[0m" + else + echo -e " * \033[1;31m$$req_mod installation FAILED!\e[0m" + #echo $$OUT + fi + fi + done < $$req_file + done + echo + fi + # Start local init + echo -e "\033[1;33mDoing localinit...\e[0m" + $(MAKE) localinit + +update_submodules: + git submodule foreach "git fetch && git checkout master && git pull && git submodule init && git submodule update" + +giti_this: print_head + giti + echo " Submodules:" + git submodule --quiet foreach "echo -n ' ' && giti" + +giti: + git submodule --quiet foreach "[ -e Makefile ] && make --no-print-directory giti_this || :" + +localclean: + +clean: localclean + if [[ ! -e $(VENV_FLAG) ]]; then + if [[ -d $(VENV_FOLDER) ]]; then + rm -rf $(VENV_FOLDER) + fi + fi + +cleanall: clean + for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do + $(MAKE) --no-print-directory -C $$(dirname $$subdir) cleanall + done + + +venv_flag: + if [[ ! -e $(VENV_FLAG) ]]; then + touch $(VENV_FLAG) + if [[ -e $(GIT_FLAG) ]]; then + git add $(VENV_FLAG) + fi + fi + +print_head: + DIRNAME=$$(basename $$(pwd)) + DIRLENGTH=$${#DIRNAME} + echo -ne "\n\n\033[1;34m╔═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╗" + echo -e "║ $$DIRNAME ║" + echo -ne "╚═" + for i in $$(seq 1 $$DIRLENGTH); do echo -n "═"; done + echo -e "═╝\033[00m" diff --git a/requirements/__make.d__/rspec.mk b/requirements/__make.d__/rspec.mk new file mode 120000 index 0000000..e8419c8 --- /dev/null +++ b/requirements/__make.d__/rspec.mk @@ -0,0 +1 @@ +../rspec/rspec.mk \ No newline at end of file diff --git a/requirements/rspec b/requirements/rspec index 48030f2..1c1e526 160000 --- a/requirements/rspec +++ b/requirements/rspec @@ -1 +1 @@ -Subproject commit 48030f24a35bcb89bd43b4ed66078a2ba9c16b1b +Subproject commit 1c1e5267a35301cdddb9d4505327991d7d6a00b3