From: Aleš Mrázek Date: Tue, 17 Sep 2024 22:05:11 +0000 (+0200) Subject: scripts/poe-tasks: _env.sh improvements and formatting X-Git-Tag: v6.0.9~9^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d940726d626d89f88ac7374a38cbc9c95dd28dcb;p=thirdparty%2Fknot-resolver.git scripts/poe-tasks: _env.sh improvements and formatting --- diff --git a/.gitignore b/.gitignore index 4464dcdd8..0d8138461 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +**/__pycache__/ *.6 *.Plo *.a @@ -8,6 +9,7 @@ *.gcno *.gcov *.info +*.junit.xml *.la *.lo *.log @@ -18,12 +20,15 @@ *.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 diff --git a/scripts/poe-tasks/clean b/scripts/poe-tasks/clean index a50044f0e..c8f596ca4 100755 --- a/scripts/poe-tasks/clean +++ b/scripts/poe-tasks/clean @@ -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 diff --git a/scripts/poe-tasks/configure b/scripts/poe-tasks/configure index f187cc501..8e4fff066 100755 --- a/scripts/poe-tasks/configure +++ b/scripts/poe-tasks/configure @@ -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 diff --git a/scripts/poe-tasks/doc b/scripts/poe-tasks/doc index aa1606e3a..ed01f4262 100755 --- a/scripts/poe-tasks/doc +++ b/scripts/poe-tasks/doc @@ -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 diff --git a/scripts/poe-tasks/doc-schema b/scripts/poe-tasks/doc-schema index 4cf5c1862..ff7dea469 100755 --- a/scripts/poe-tasks/doc-schema +++ b/scripts/poe-tasks/doc-schema @@ -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 diff --git a/scripts/poe-tasks/kresctl b/scripts/poe-tasks/kresctl index 52b8edd2c..87a96e304 100755 --- a/scripts/poe-tasks/kresctl +++ b/scripts/poe-tasks/kresctl @@ -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" "$@" diff --git a/scripts/poe-tasks/run b/scripts/poe-tasks/run index b137ecaf8..4d3ebc8cc 100755 --- a/scripts/poe-tasks/run +++ b/scripts/poe-tasks/run @@ -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" "$@" diff --git a/scripts/poe-tasks/utils/_env.sh b/scripts/poe-tasks/utils/_env.sh index 13ed2d5dd..66cece833 100644 --- a/scripts/poe-tasks/utils/_env.sh +++ b/scripts/poe-tasks/utils/_env.sh @@ -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 }