]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
scripts/poe-tasks: created gen-constantspy script
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 17 Sep 2024 22:33:17 +0000 (00:33 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 30 Sep 2024 09:16:07 +0000 (11:16 +0200)
New script to build constants.py module using Meson. Also check that the module is the current one.

pyproject.toml
scripts/poe-tasks/check
scripts/poe-tasks/gen-constantspy [new file with mode: 0755]

index 780ba176899cd2efa28a183e7bdf44d3b0c92552..3b277fb5dca8419bb5868cbaa5a7d00f6fd2eea1 100644 (file)
@@ -79,6 +79,7 @@ doc-schema = { cmd = "scripts/poe-tasks/doc-schema", help = "Generate a JSON sch
 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" }
+gen-constantspy = { cmd = "scripts/poe-tasks/gen-constantspy", help = "Generate 'constants.py' module using Meson configured options" }
 gen-setuppy = { cmd = "scripts/poe-tasks/gen-setuppy", help = "Generate 'setup.py' file for backwards compatibility" }
 format = { cmd = "scripts/poe-tasks/format", help = "Run code formatter" }
 kresctl = { cmd = "scripts/poe-tasks/kresctl", help="Run kresctl utility" }
index d7766c200f8ec02594e8f90051fc41b61e8a2589..7acd65b717129ff8ce9e52e1d67e8db37b45a46f 100755 (executable)
@@ -68,6 +68,13 @@ python setup.py --help > /dev/null
 check_rv $?
 echo
 
+# check python/knot_resolver/constants.py
+echo -e "${yellow}python/knot_resolver/constants.py${reset}"
+meson_setup_configure > /dev/null
+diff python/knot_resolver/constants.py $build_dir/python/constants.py
+check_rv $?
+echo
+
 # check that doc/_static/config.schema.json is the latest
 echo -e "${yellow}Checking doc/_static/config.schema.json${reset}"
 python -m knot_resolver.client schema | diff - doc/_static/config.schema.json
@@ -82,6 +89,7 @@ else
        echo -e "${red}These commands might help you:${reset}"
        echo -e "${red}\tpoe format${reset}"
        echo -e "${red}\tpoe gen-setuppy${reset}"
+       echo -e "${red}\tpoe gen-constantspy${reset}"
        echo -e "${red}\tpoe doc-schema${reset}"
        echo -e "${red}That's not great. Could you please fix that?${reset} 😲😟"
 fi
diff --git a/scripts/poe-tasks/gen-constantspy b/scripts/poe-tasks/gen-constantspy
new file mode 100755 (executable)
index 0000000..f71f157
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+# ensure consistent behaviour
+src_dir="$(dirname "$(realpath "$0")")"
+source $src_dir/utils/_env.sh
+
+echo
+meson_setup_configure
+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
\ No newline at end of file