From: Oto Šťáva Date: Thu, 16 May 2024 12:17:12 +0000 (+0200) Subject: manager: configurable Meson directory X-Git-Tag: v6.0.8~15^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fenvironments%2Fdocs-develop-mana-oa16bs%2Fdeployments%2F4217;p=thirdparty%2Fknot-resolver.git manager: configurable Meson directory This commit makes it more convenient to change the configuration of the build directory of `kresd` when using Knot Resolver Manager. It adds a new `./poe configure` command, which optionally takes the same arguments as the standard `meson configure` command. The `./poe run` command now requires running `./poe configure` at least once to set up the build directory. If the directory has been configured before this commit (i.e. `./poe run` has been executed at least once), no extra action is required, as the directory structure remains the same. The commit also removes the `manager` configuration option from Meson as we were not using it and it was broken and potentially confusing to newcomers. --- diff --git a/doc/dev/build.rst b/doc/dev/build.rst index b6bfd9f43..8a08ed4ff 100644 --- a/doc/dev/build.rst +++ b/doc/dev/build.rst @@ -168,7 +168,7 @@ You can also configure some :ref:`build-options`, in this case enable ``manager` .. code-block:: bash - $ meson build_dir --prefix=/tmp/kr --default-library=static -Dmanager=enabled + $ meson build_dir --prefix=/tmp/kr After that it is possible to build and install Knot Resolver. @@ -275,7 +275,6 @@ Recommended build options for packagers: * ``-Dsystemd_files=enabled`` for systemd unit files * ``-Ddoc=enabled`` for offline documentation (see :ref:`build-html-doc`) * ``-Dinstall_kresd_conf=enabled`` to install default config file -* ``-Dmanager=enabled`` to force build of the manager and its features * ``-Dunit_tests=enabled`` to force build of unit tests Systemd diff --git a/manager/README.md b/manager/README.md index 805a563e3..7f3233374 100644 --- a/manager/README.md +++ b/manager/README.md @@ -32,9 +32,10 @@ Please note that Python's development files are also required, since the Manager ### Common tasks and interactions with the project -After setting up the environment, you should be able to interract with the project by using `./poe` script. Common actions are: +After setting up the environment, you should be able to interact with the project by using the `./poe` script. Common actions are: -* `poe run` - runs the manager from the source +* `poe configure` - configures Knot Resolver daemon for use with the manager +* `poe run` - runs the manager from the source (requires the daemon to be configured) * `poe docs` - creates HTML documentation * `poe test` - unit tests * `poe tox` - unit tests in all supported Python versions (must not be run outside of virtualenv, otherwise it fails to find multiple versions of Python) diff --git a/manager/pyproject.toml b/manager/pyproject.toml index 3b63350f5..1da53a489 100644 --- a/manager/pyproject.toml +++ b/manager/pyproject.toml @@ -58,6 +58,7 @@ kresctl = 'knot_resolver_manager.cli.main:main' knot-resolver = 'knot_resolver_manager.__main__:run' [tool.poe.tasks] +configure = { cmd = "scripts/meson-configure", help = "Configure Knot Resolver daemon" } run = { cmd = "scripts/run", help = "Run the manager" } run-debug = { cmd = "scripts/run-debug", help = "Run the manager under debugger" } docs = { cmd = "scripts/docs", help = "Create HTML documentation" } diff --git a/manager/scripts/_env.sh b/manager/scripts/_env.sh index ddbbcf552..cabc0025c 100644 --- a/manager/scripts/_env.sh +++ b/manager/scripts/_env.sh @@ -36,17 +36,23 @@ set -o nounset function build_kresd { - echo - echo Building Knot Resolver - 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 $(realpath .install_kresd) $(realpath .build_kresd)${reset}" - echo pushd .. - mkdir -p manager/.build_kresd manager/.install_kresd - meson manager/.build_kresd --prefix=$(realpath manager/.install_kresd) --default-library=static --buildtype=debug - ninja -C manager/.build_kresd - ninja install -C manager/.build_kresd - export PYTHONPATH="$(realpath manager/.build_kresd/python):${PYTHONPATH:-}" + if [ -d manager/.build_kresd ]; then + echo + echo Building Knot Resolver + 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 $(realpath .install_kresd) $(realpath .build_kresd)${reset}" + echo + ninja -C manager/.build_kresd + ninja install -C manager/.build_kresd + export PYTHONPATH="$(realpath manager/.build_kresd/python):${PYTHONPATH:-}" + else + echo + echo Knot Resolver daemon is not configured. + echo "Please run './poe configure' (optionally with additional Meson arguments)" + echo + exit 2 + fi popd } diff --git a/manager/scripts/meson-configure b/manager/scripts/meson-configure new file mode 100755 index 000000000..c99ddea7c --- /dev/null +++ b/manager/scripts/meson-configure @@ -0,0 +1,11 @@ +#!/bin/bash + +# ensure consistent behaviour +src_dir="$(dirname "$(realpath "$0")")" +source $src_dir/_env.sh + +pushd .. +meson setup manager/.build_kresd --reconfigure --prefix=$(realpath manager/.install_kresd) "$@" +popd + +build_kresd diff --git a/meson.build b/meson.build index 05f093c92..535c497cc 100644 --- a/meson.build +++ b/meson.build @@ -254,7 +254,6 @@ subdir('lib') ## Remaining code subdir('daemon') subdir('modules') -subdir('manager') subdir('python') subdir('utils') if get_option('bench') == 'enabled' @@ -340,7 +339,6 @@ run_target( # https://github.com/mesonbuild/meson/issues/2404 s_managed_ta = managed_ta ? 'enabled' : 'disabled' s_install_root_keys = install_root_keys ? 'enabled' : 'disabled' -s_build_manager = build_manager ? 'enabled' : 'disabled' s_build_utils = build_utils ? 'enabled' : 'disabled' s_build_dnstap = build_dnstap ? 'enabled' : 'disabled' s_build_unit_tests = build_unit_tests ? 'enabled' : 'disabled' @@ -375,7 +373,6 @@ message(''' cache_dir: @0@'''.format(systemd_cache_dir) + ''' optional components - manager: @0@'''.format(s_build_manager) + ''' utils: @0@'''.format(s_build_utils) + ''' dnstap: @0@'''.format(s_build_dnstap) + ''' unit_tests: @0@'''.format(s_build_unit_tests) + ''' diff --git a/meson_options.txt b/meson_options.txt index 428d5aaaa..0f4048503 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -125,18 +125,6 @@ option( description: 'build benchmarks', ) -option( - 'manager', - type: 'combo', - choices: [ - 'auto', - 'enabled', - 'disabled', - ], - value: 'disabled', - description: 'build manager and its features', -) - option( 'utils', type: 'combo',