]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts/poe-tasks: _env.sh improvements and formatting
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 17 Sep 2024 22:05:11 +0000 (00:05 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 30 Sep 2024 09:16:07 +0000 (11:16 +0200)
.gitignore
scripts/poe-tasks/clean
scripts/poe-tasks/configure
scripts/poe-tasks/doc
scripts/poe-tasks/doc-schema
scripts/poe-tasks/kresctl
scripts/poe-tasks/run
scripts/poe-tasks/utils/_env.sh

index 4464dcdd88285015b73ac6ffd597cc2260361833..0d81384617628a1f03852fb4638e616856db149e 100644 (file)
@@ -1,3 +1,4 @@
+**/__pycache__/
 *.6
 *.Plo
 *.a
@@ -8,6 +9,7 @@
 *.gcno
 *.gcov
 *.info
+*.junit.xml
 *.la
 *.lo
 *.log
 *.so.*
 *.swp
 *~
+.coverage
 .deps
 .dirstamp
 .libs
+.mypy_cache
 .pytest_cache
-/.build-depend
+/.build*/
 /.cache
+/.install_dev
 /aclocal.m4
 /ar-lib
 /autom4te.cache/*
@@ -44,6 +49,7 @@
 /daemon/lua/*.inc
 /daemon/lua/trust_anchors.lua
 /depcomp
+/dist
 /distro/tests/*/.vagrant
 /doc/**/.doctrees
 /doc/**/doxyxml
@@ -82,12 +88,4 @@ _obj
 kresd.amalg.c
 libkres.amalg.c
 luacov.*.out
-**/__pycache__/
-dist/
-.coverage
-.mypy_cache
-.install/
-.build/
-.build_doc/
 poetry.lock
-*.junit.xml
index a50044f0e2b43c6ebec3972c5d067578d90a2a47..c8f596ca445bf8a221c96bce94dec47cfe5a5478 100755 (executable)
@@ -9,13 +9,11 @@ echo --------------------------------------------
 echo Removing mypy, pytest and other cached files 
 echo --------------------------------------------
 rm -vrf .coverage .mypy_cache .pytest_cache
-
 echo
 echo ------------------------------------------
 echo Removing Meson build directories and files
 echo ------------------------------------------
-rm -vrf "$build_dir" "$KRES_INSTALL_DIR" "$build_schema_dir" "$build_doc_dir" build dist 
-
+rm -vrf "$build_dir" "$build_dev_dir" "$KRES_DEV_INSTALL_DIR" build dist 
 echo
 echo ------------------------------------------
 echo Removing __pycache__ directories and files
index f187cc5016e92b5f27430bb7df46f363a019e47d..8e4fff066b03c6db136eb65cadd15839e44ce68e 100755 (executable)
@@ -4,4 +4,11 @@
 src_dir="$(dirname "$(realpath "$0")")"
 source $src_dir/utils/_env.sh
 
-meson_setup_configure
+echo
+meson_setup_configure_dev
+echo
+echo -----------------------------------------------
+echo Copying constants.py module configured by Meson
+echo -----------------------------------------------
+cp -v $build_dev_dir/python/constants.py $gitroot/python/knot_resolver/constants.py
+echo
index aa1606e3aeb6c1ce45da279f362858fc4b850feb..ed01f4262bbf67d56589c0e5a9a4cb4a6b99806b 100755 (executable)
@@ -4,14 +4,10 @@
 src_dir="$(dirname "$(realpath "$0")")"
 source $src_dir/utils/_env.sh
 
-echo
-echo -----------------------------------------------------
-echo Configuring documentation build directory using Meson
-echo -----------------------------------------------------
-meson $build_doc_dir -Ddoc=enabled
-echo
+meson_setup_configure -Ddoc=enabled
+
 echo ----------------------------------
 echo Building documentation using ninja
 echo ----------------------------------
-ninja -C $build_doc_dir doc
+ninja -C $build_dir doc
 echo
index 4cf5c186295ed85a3354864747a041b71b0885e6..ff7dea46973c4c53365b2a56fe07a5ff25835c4d 100755 (executable)
@@ -4,12 +4,10 @@
 src_dir="$(dirname "$(realpath "$0")")"
 source $src_dir/utils/_env.sh
 
-rm -rf $build_schema_dir > /dev/null
-meson setup \
-    $build_schema_dir \
-    --buildtype=release \
-    --prefix=/usr > /dev/null
-cp -v $build_schema_dir/python/constants.py $gitroot/python/knot_resolver/constants.py
-
-python -m knot_resolver.client schema > $gitroot/doc/_static/config.schema.json
-rm -rf $build_schema_dir
+schema_file="$gitroot/doc/_static/config.schema.json"
+
+meson_setup_configure > /dev/null
+cp $build_dir/python/constants.py $gitroot/python/knot_resolver/constants.py
+python -m knot_resolver.client schema > $schema_file
+
+echo New configuration JSON schem saved to $schema_file
\ No newline at end of file
index 52b8edd2c3098d8ebeeb91fb6da412f2b56fb380..87a96e3040963f39870599a29efb0bc31ed36d21 100755 (executable)
@@ -4,7 +4,9 @@
 src_dir="$(dirname "$(realpath "$0")")"
 source $src_dir/utils/_env.sh
 
-is_buil_dir_configured
+echo
+is_build_dev_dir_configured
+echo
 
 # run knot-resolver client
-python3 -m knot_resolver.client --config "$KRES_CONFIG_FILE" "$@"
+python3 -m knot_resolver.client --config "$KRES_DEV_CONFIG_FILE" "$@"
index b137ecaf862c421fdc44ffb4bb5bcb02790c67d5..4d3ebc8cc15e8d84914948f53e81a9260947a2ff 100755 (executable)
@@ -4,8 +4,14 @@
 src_dir="$(dirname "$(realpath "$0")")"
 source $src_dir/utils/_env.sh
 
-ninja_install
+echo
+ninja_dev_install
+echo
 
+echo ------------------------------------
+echo Creating missing runtime directories
+echo ------------------------------------
+mkdir -vp $KRES_DEV_INSTALL_DIR/run/knot-resolver $KRES_DEV_INSTALL_DIR/var/cache/knot-resolver
 echo
 echo ---------------------------------------
 echo Building Python komponents using Poetry
@@ -26,4 +32,4 @@ echo
 echo --------------------------------------
 echo Starting Knot Resolver wit the Manager
 echo --------------------------------------
-python3 -m knot_resolver.manager --config "$KRES_CONFIG_FILE" "$@"
+python3 -m knot_resolver.manager --config "$KRES_DEV_CONFIG_FILE" "$@"
index 13ed2d5dd5061830c24af74d765c4b8fff102dda..66cece833168b167d477d5f2ed85d8009d5952e2 100644 (file)
@@ -19,9 +19,8 @@ cd $gitroot
 
 # build dirs
 build_dir="$gitroot/.build"
-build_doc_dir="$gitroot/.build_doc"
-build_schema_dir="$gitroot/.build_schema"
-install_dir="$gitroot/.install"
+build_dev_dir="$gitroot/.build_dev"
+install_dev_dir="$gitroot/.install_dev"
 
 # ensure consistent environment with virtualenv
 if test -z "$VIRTUAL_ENV" -a "$CI" != "true" -a -z "$KNOT_ENV"; then
@@ -41,41 +40,49 @@ PATH="$PATH:$gitroot/node_modules/.bin"
 set -o nounset
 
 # Set enviromental variables if not
-if [ -z "${KRES_INSTALL_DIR:-}" ]; then
-       KRES_INSTALL_DIR="$install_dir"
+if [ -z "${KRES_DEV_INSTALL_DIR:-}" ]; then
+       KRES_DEV_INSTALL_DIR="$install_dev_dir"
 fi
-if [ -z "${KRES_CONFIG_FILE:-}" ]; then
-    KRES_CONFIG_FILE="$gitroot/etc/config/config.dev.yaml"
+if [ -z "${KRES_DEV_CONFIG_FILE:-}" ]; then
+    KRES_DEV_CONFIG_FILE="$gitroot/etc/config/config.dev.yaml"
 fi
-export KRES_INSTALL_DIR
-export KRES_CONFIG_FILE
+export KRES_DEV_INSTALL_DIR
+export KRES_DEV_CONFIG_FILE
 
 function meson_setup_configure {
-       reconfigure=''
-       if [ -d .build ]; then
+       local reconfigure=''
+       if [ -d $build_dir ]; then
                reconfigure='--reconfigure'
        fi
-       echo
        echo ---------------------------------------
        echo Configuring build directory using Meson
        echo ---------------------------------------
        meson setup \
                $build_dir \
                $reconfigure \
-               --prefix=$KRES_INSTALL_DIR \
+               --prefix=/usr \
+               "$@"
+}
+
+function meson_setup_configure_dev {
+       local reconfigure=''
+       if [ -d $build_dev_dir ]; then
+               reconfigure='--reconfigure'
+       fi
+       echo ---------------------------------------
+       echo Configuring build directory using Meson
+       echo ---------------------------------------
+       meson setup \
+               $build_dev_dir \
+               $reconfigure \
+               --prefix=$KRES_DEV_INSTALL_DIR \
                -D user=$(id -un) \
                -D group=$(id -gn) \
                "$@"
-       echo
-       echo -----------------------------------------------
-       echo Copying constants.py module configured by Meson
-       echo -----------------------------------------------
-       cp -v $build_dir/python/constants.py $gitroot/python/knot_resolver/constants.py
-       echo
 }
 
-function is_buil_dir_configured {
-       if [ ! -d .build ]; then
+function is_build_dev_dir_configured {
+       if [ ! -d $build_dev_dir ]; then
                echo
                echo Knot Resolver build directory is not configured by Meson.
                echo "Please run './poe configure' (optionally with additional Meson arguments)".
@@ -84,17 +91,14 @@ function is_buil_dir_configured {
        fi
 }
 
-function ninja_install {
+function ninja_dev_install {
 
-       is_buil_dir_configured
+       is_build_dev_dir_configured
 
        echo
        echo --------------------------------------------
-       echo Building/installing C komponents using ninja
+       echo Building/installing C komponents using Ninja
        echo --------------------------------------------
-       ninja -C $build_dir
-       ninja install -C $build_dir
-
-       mkdir -vp $KRES_INSTALL_DIR/run/knot-resolver $KRES_INSTALL_DIR/var/cache/knot-resolver
-       echo
+       ninja -C $build_dev_dir
+       ninja install -C $build_dev_dir
 }