]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Use os.walk, as Path.walk is not always available
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 9 May 2025 14:18:10 +0000 (16:18 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 12 May 2025 14:34:29 +0000 (16:34 +0200)
pdns/recursordist/rec-rust-lib/Makefile.am
pdns/recursordist/rec-rust-lib/generate.py

index 8d186d14aaed07bba0123f453a29c210c26ae437..f359a52b441408fcc8b2d77612d817f9b0cb3d67 100644 (file)
@@ -19,13 +19,13 @@ BUILT_SOURCES=cxxsettings-generated.cc rust/src/lib.rs
 
 # We need to clean in the Rust dir, as in some cases the Serde/CXX derive/generate code does not get
 # re-run by cargo after rust/src/lib.rs changed because of a generate.py run. In that case we end up
-# with an rust/src/lib.rs.h that does not contain e.g. field name or field type changes.
+# with an rust/src/lib.rs.h that does not contain e.g. field name or field type changes. This
+# cleanup is now done from generate.py itself.
 #
 # Use patterns to avoid having two instances of generate run simultaneously, a well-known hack for GNU make
 cxxsettings-generated%cc rust/src/lib%rs: table.py generate.py rust-preamble-in.rs rust-bridge-in.rs docs-old-preamble-in.rst docs-new-preamble-in.rst
        @if test "$(PYTHON)" = ":"; then echo "Settings table table.py has changed, python is needed to regenerate the related settings files but python was not found. Please install python and re-run configure"; exit 1; fi
        @if ! $(PYTHON) --version | grep -q "Python 3"; then echo $(PYTHON) should be at least version 3. Please install python 3 and re-run configure; exit 1; fi
-       $(MAKE) -C rust clean
        (cd ${srcdir} && $(PYTHON) generate.py)
 
 clean-local:
index 92e764bc1c9db0a1708f2e8df29169e253111600..6638e31aff6ebd7d96b88e8c2a06c91dac68c591 100644 (file)
@@ -839,18 +839,21 @@ def generate():
     if os.path.isdir('../docs'):
         gen_oldstyle_docs(srcdir, entries)
         gen_newstyle_docs(srcdir, entries)
-    # Remove rust generated files, they need to be re-generated after a table change and the rust dependency tracking does
-    # not do that in some cases. For the autotools case Makefile.am takes care.
+    # Remove cxx generated files, they need to be re-generated after a table change and the rust dependency tracking does
+    # not do that in some cases.
     Path(gendir, 'rust', 'librecrust.a').unlink(True)
     Path(gendir, 'rust', 'lib.rs.h').unlink(True)
     Path(gendir, 'rust', 'web.rs.h').unlink(True)
     Path(gendir, 'rust', 'cxx.h').unlink(True)
     Path(gendir, 'rust', 'misc.rs.h').unlink(True)
-    target = Path('target')
-    for root, dirs, files in target.walk(top_down=False):
+    # Path.walk exist only in very new versions of Python
+    # With meson, target is in toplevel build dir
+    for root, dirs, files in os.walk('target', topdown=False):
         for name in files:
-              (root / name).unlink()
-        for name in dirs:
-              (root / name).rmdir()
+            os.remove(os.path.join(root, name))
+    # With autotools, target exists in rec-rust-lib/rust and this Python script is executed with cwd rec-rust-lib
+    for root, dirs, files in os.walk('rust/target', topdown=False):
+        for name in files:
+            os.remove(os.path.join(root, name))
 
 generate()