.mypy_cache
.install/
.build/
+.build_doc/
poetry.lock
*.junit.xml
configure = { cmd = "scripts/poe-tasks/configure", help = "(Re)configure Meson build directory" }
run = { cmd = "scripts/poe-tasks/run", help = "Run Knot Resolver" }
run-debug = { cmd = "scripts/poe-tasks/run-debug", help = "Debug Knot Resolver with debugpy" }
-docs = { cmd = "scripts/poe-tasks/docs", help = "Create Knot Resolver HTML documentation" }
+doc = { cmd = "scripts/poe-tasks/doc", help = "Create Knot Resolver HTML documentation" }
test = { cmd = "scripts/poe-tasks/test", help = "Run pytest unit tests" }
check = { cmd = "scripts/poe-tasks/check", help = "Check that all dependencies are installed and run static code analysis" }
examples = { cmd = "scripts/poe-tasks/examples", help = "Validate all configuration examples using 'kresctl validate' utility" }
aggregate_rv=$(( $aggregate_rv + $1 ))
}
-kres_is_meson_configured
+is_buil_dir_configured
# stop failing early, because we wouldn't do anything else than fail
set +e
source $src_dir/utils/_env.sh
echo
+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 $install_dir build build_doc dist
+rm -vrf "$build_dir" "$KRES_INSTALL_DIR" "$build_doc_dir" build dist
echo
+echo ------------------------------------------
echo Removing __pycache__ directories and files
echo ------------------------------------------
find . -type d -name '__pycache__' -prune -exec rm -vrf {} +
+echo
\ No newline at end of file
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_configure
+meson_setup_configure
--- /dev/null
+#!/usr/bin/env bash
+
+# ensure consistent behaviour
+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
+echo ----------------------------------
+echo Building documentation using ninja
+echo ----------------------------------
+ninja -C $build_doc_dir doc
+echo
+++ /dev/null
-#!/usr/bin/env bash
-
-# ensure consistent behaviour
-src_dir="$(dirname "$(realpath "$0")")"
-source $src_dir/utils/_env.sh
-
-echo Building Knot Resolver documentation
-echo ------------------------------------
-meson build_doc -Ddoc=enabled
-ninja -C build_doc doc
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# validate all configuration examples
for example in $PWD/etc/config/config.example.*.yaml;
do
- poe kresctl validate --no-strict $example;
+ python3 -m knot_resolver.client validate --no-strict $example;
done
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# run knot-resolver client
-python3 -m knot_resolver.client $@
+python3 -m knot_resolver.client --config "$KRES_CONFIG_FILE" "$@"
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_build
+meson_setup_configure
+
+ninja_install
man -l .install/share/man/man8/$1*
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_meson_build
+ninja_install
echo
-echo Building Knot Resolver Python komponents
-echo ----------------------------------------
+echo ---------------------------------------
+echo Building Python komponents using Poetry
+echo ---------------------------------------
poetry build
# copy native modules from build directory to source directory
shopt -s globstar
shopt -u nullglob
echo
-echo The Knot Resolver API is accessible on http://localhost:5000
-echo ------------------------------------------------------------
-
-# run the knot-resolver manager
-python3 -m knot_resolver.manager $@
+echo --------------------------------------
+echo Starting Knot Resolver wit the Manager
+echo --------------------------------------
+python3 -m knot_resolver.manager --config "$KRES_CONFIG_FILE" "$@"
src_dir="$(dirname "$(realpath "$0")")"
source $src_dir/utils/_env.sh
-kres_is_meson_configured
+is_buil_dir_configured
# run pytest
env PYTHONPATH=. pytest --junitxml=unit.junit.xml --cov=python/knot_resolver --show-capture=all tests/manager
cd $gitroot
# build dirs
-build_dir=$gitroot/.build
-install_dir=$gitroot/.install
+build_dir="$gitroot/.build"
+build_doc_dir="$gitroot/.build_doc"
+install_dir="$gitroot/.install"
# ensure consistent environment with virtualenv
if test -z "$VIRTUAL_ENV" -a "$CI" != "true" -a -z "$KNOT_ENV"; then
# fail even on unbound variables
set -o nounset
-# create runtime directories
-if [ -z "${KRES_CONFIG_DIR:-}" ]; then
- KRES_CONFIG_DIR="$gitroot/etc/config"
+# Set enviromental variables if not
+if [ -z "${KRES_INSTALL_DIR:-}" ]; then
+ KRES_INSTALL_DIR="$install_dir"
fi
-mkdir -p "$KRES_CONFIG_DIR/runtime" "$KRES_CONFIG_DIR/cache"
-
-# env variables
if [ -z "${KRES_CONFIG_FILE:-}" ]; then
- KRES_CONFIG_FILE="$KRES_CONFIG_DIR/config.dev.yaml"
-fi
-
-if [ -z "${KRES_API_SOCK_FILE:-}" ]; then
- KRES_API_SOCK_FILE="$KRES_CONFIG_DIR/kres-api.sock"
+ KRES_CONFIG_FILE="$gitroot/etc/config/config.dev.yaml"
fi
+export KRES_INSTALL_DIR
export KRES_CONFIG_FILE
-export KRES_API_SOCK_FILE
-function kres_meson_configure {
+function meson_setup_configure {
reconfigure=''
- if [ -f .build/ninja.build ]; then
+ if [ -d .build ]; then
reconfigure='--reconfigure'
fi
echo
- echo Configuring Knot Resolver Meson
- echo -------------------------------
- echo -e "${blue}${reset}"
+ echo ---------------------------------------
+ echo Configuring build directory using Meson
+ echo ---------------------------------------
+ meson setup \
+ $build_dir \
+ $reconfigure \
+ --prefix=$KRES_INSTALL_DIR \
+ -D user=$(id -un) \
+ -D group=$(id -gn) \
+ "$@"
echo
- meson setup $build_dir $reconfigure --prefix=$install_dir -Duser=$(id -un) -Dgroup=$(id -gn) "$@"
- echo
- echo Copying Knot Resolver constants.py module
- 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 kres_is_meson_configured {
+function is_buil_dir_configured {
if [ ! -d .build ]; then
echo
- echo Knot Resolver is not configured for building.
+ echo Knot Resolver build directory is not configured by Meson.
echo "Please run './poe configure' (optionally with additional Meson arguments)".
echo
exit 2
fi
}
-function kres_meson_build {
+function ninja_install {
- kres_is_meson_configured
+ is_buil_dir_configured
echo
- echo Building Knot Resolver C komponents
- echo -----------------------------------
- echo -e "${blue}In case of an compilation error, run this command to try to fix it:${reset}"
- echo -e "\t${blue}rm -r $install_dir $build_dir${reset}"
- echo
+ echo --------------------------------------------
+ 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
}