check_get_file_list.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. import os
  3. import sys
  4. from pathlib import Path
  5. sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", ".."))
  6. from binding_generator import _generate_bindings, _get_file_list
  7. from build_profile import generate_trimmed_api
  8. api_filepath = "gdextension/extension_api.json"
  9. bits = "64"
  10. precision = "single"
  11. output_dir = "self_test"
  12. def test(profile_filepath=""):
  13. api = generate_trimmed_api(api_filepath, profile_filepath)
  14. _generate_bindings(
  15. api,
  16. use_template_get_node=False,
  17. bits=bits,
  18. precision=precision,
  19. output_dir=output_dir,
  20. )
  21. flist = _get_file_list(api, output_dir, headers=True, sources=True)
  22. p = Path(output_dir) / "gen"
  23. allfiles = [str(f.as_posix()) for f in p.glob("**/*.*")]
  24. missing = list(filter((lambda f: f not in flist), allfiles))
  25. extras = list(filter((lambda f: f not in allfiles), flist))
  26. if len(missing) > 0 or len(extras) > 0:
  27. print("Error!")
  28. for f in missing:
  29. print("MISSING: " + str(f))
  30. for f in extras:
  31. print("EXTRA: " + str(f))
  32. sys.exit(1)
  33. else:
  34. print("OK!")
  35. test()
  36. test("test/build_profile.json")