# 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:
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()