diff options
author | Aleš Mrázek <ales.mrazek@nic.cz> | 2024-09-18 00:05:11 +0200 |
---|---|---|
committer | Aleš Mrázek <ales.mrazek@nic.cz> | 2024-09-30 11:16:07 +0200 |
commit | d940726d626d89f88ac7374a38cbc9c95dd28dcb (patch) | |
tree | 2b1c74eb050692828e5680d587a2cafef1b31270 /scripts | |
parent | scripts/poe-tasks: ./configure not required for some tasks (diff) | |
download | knot-resolver-d940726d626d89f88ac7374a38cbc9c95dd28dcb.tar.xz knot-resolver-d940726d626d89f88ac7374a38cbc9c95dd28dcb.zip |
scripts/poe-tasks: _env.sh improvements and formatting
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/poe-tasks/clean | 4 | ||||
-rwxr-xr-x | scripts/poe-tasks/configure | 9 | ||||
-rwxr-xr-x | scripts/poe-tasks/doc | 10 | ||||
-rwxr-xr-x | scripts/poe-tasks/doc-schema | 16 | ||||
-rwxr-xr-x | scripts/poe-tasks/kresctl | 6 | ||||
-rwxr-xr-x | scripts/poe-tasks/run | 10 | ||||
-rw-r--r-- | scripts/poe-tasks/utils/_env.sh | 62 |
7 files changed, 64 insertions, 53 deletions
diff --git a/scripts/poe-tasks/clean b/scripts/poe-tasks/clean index a50044f0..c8f596ca 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 f187cc50..8e4fff06 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 aa1606e3..ed01f426 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 4cf5c186..ff7dea46 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 52b8edd2..87a96e30 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 b137ecaf..4d3ebc8c 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 13ed2d5d..66cece83 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 } |