Makefile added with new status and init concept
This commit is contained in:
parent
d540958e7e
commit
dd45f657ae
79
Makefile
Normal file
79
Makefile
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# Version 1.1 (2025-08-05)
|
||||||
|
default: help
|
||||||
|
|
||||||
|
.ONESHELL:
|
||||||
|
SHELL = /usr/bin/bash
|
||||||
|
.SILENT:
|
||||||
|
|
||||||
|
GIT_FLAG = ./.git
|
||||||
|
VENV_FLAG = ./.venv_required
|
||||||
|
VENV_FOLDER = ./venv
|
||||||
|
INIT_FILE = ./init
|
||||||
|
|
||||||
|
help:
|
||||||
|
echo "Possible options are: init, status, venv_flag, clean, cleanall"
|
||||||
|
|
||||||
|
init: print_head
|
||||||
|
# Init git repo
|
||||||
|
if [[ -e $(GIT_FLAG) ]]; then
|
||||||
|
git submodule init
|
||||||
|
git submodule update
|
||||||
|
fi
|
||||||
|
# Create venv if needed
|
||||||
|
if [[ -e $(VENV_FLAG) ]]; then
|
||||||
|
if [[ ! -e $(VENV_FOLDER) ]]; then
|
||||||
|
mkvenv
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [[ -x $(INIT_FILE) ]]; then
|
||||||
|
$(INIT_FILE)
|
||||||
|
fi
|
||||||
|
|
||||||
|
initall:
|
||||||
|
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
|
||||||
|
$(MAKE) --no-print-directory -C $$(dirname $$subdir) init
|
||||||
|
done
|
||||||
|
|
||||||
|
status: print_head
|
||||||
|
giti
|
||||||
|
echo "Submodules:"
|
||||||
|
echo "-----------"
|
||||||
|
git submodule --quiet foreach giti
|
||||||
|
|
||||||
|
statusall:
|
||||||
|
for subdir in $$(find . -maxdepth 2 -mindepth 2 -name Makefile | sort); do
|
||||||
|
$(MAKE) --no-print-directory -C $$(dirname $$subdir) status
|
||||||
|
done
|
||||||
|
|
||||||
|
clean:
|
||||||
|
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"
|
||||||
|
|
12
init
Executable file
12
init
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
echo "* Linking pylibs to venv"
|
||||||
|
for path in `find pylibs/ -maxdepth 1 -type d`; do
|
||||||
|
if [[ $path != "pylibs/" ]];then
|
||||||
|
lib=${path#*/}
|
||||||
|
echo Creating symbolic link for library $lib
|
||||||
|
rm -f venv/lib/python*/site-packages/$lib
|
||||||
|
ln -s ../../../../$path venv/lib/python*/site-packages/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
2
pylibs
2
pylibs
@ -1 +1 @@
|
|||||||
Subproject commit b5a1574560194abe1c7cb8fb213747461e1553c5
|
Subproject commit b38e3fd01559286eb5241d952ba9035f09955957
|
28
reposinit
28
reposinit
@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
echo "* Initialising Submodules"
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
pushd pylibs
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
popd
|
|
||||||
|
|
||||||
echo "* Creating virtual env"
|
|
||||||
BASEPATH=`realpath $(dirname $0)`
|
|
||||||
|
|
||||||
python3 -m venv $BASEPATH/venv
|
|
||||||
$BASEPATH/venv/bin/pip install --upgrade pip
|
|
||||||
find $BASEPATH -name requirements.txt | xargs -L 1 $BASEPATH/venv/bin/pip install -r
|
|
||||||
$BASEPATH/venv/bin/pip list --outdated --format=json | jq -r '.[] | .name'|xargs -n1 $BASEPATH/venv/bin/pip install -U
|
|
||||||
|
|
||||||
echo "* Linking pylibs to venv"
|
|
||||||
for path in `find pylibs/ -maxdepth 1 -type d`; do
|
|
||||||
if [[ $path != "pylibs/" ]];then
|
|
||||||
lib=${path#*/}
|
|
||||||
echo Creating symbolic link for library $lib
|
|
||||||
rm -f venv/lib/python*/site-packages/$lib
|
|
||||||
ln -s ../../../../$path venv/lib/python*/site-packages/
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user