From: Otto Moerbeek Date: Fri, 9 May 2025 14:18:10 +0000 (+0200) Subject: Use os.walk, as Path.walk is not always available X-Git-Tag: dnsdist-2.0.0-alpha2~17^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56dd5386caf2fedd8ac3d232ac2db29f5e9deb34;p=thirdparty%2Fpdns.git Use os.walk, as Path.walk is not always available --- diff --git a/pdns/recursordist/rec-rust-lib/Makefile.am b/pdns/recursordist/rec-rust-lib/Makefile.am index 8d186d14aa..f359a52b44 100644 --- a/pdns/recursordist/rec-rust-lib/Makefile.am +++ b/pdns/recursordist/rec-rust-lib/Makefile.am @@ -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: diff --git a/pdns/recursordist/rec-rust-lib/generate.py b/pdns/recursordist/rec-rust-lib/generate.py index 92e764bc1c..6638e31aff 100644 --- a/pdns/recursordist/rec-rust-lib/generate.py +++ b/pdns/recursordist/rec-rust-lib/generate.py @@ -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()