check_get_file_list.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. api_filepath,
  17. use_template_get_node=False,
  18. bits=bits,
  19. precision=precision,
  20. output_dir=output_dir,
  21. )
  22. flist = _get_file_list(api, output_dir, headers=True, sources=True)
  23. p = Path(output_dir) / "gen"
  24. allfiles = [str(f.as_posix()) for f in p.glob("**/*.*")]
  25. missing = list(filter((lambda f: f not in flist), allfiles))
  26. extras = list(filter((lambda f: f not in allfiles), flist))
  27. if len(missing) > 0 or len(extras) > 0:
  28. print("Error!")
  29. for f in missing:
  30. print("MISSING: " + str(f))
  31. for f in extras:
  32. print("EXTRA: " + str(f))
  33. sys.exit(1)
  34. else:
  35. print("OK!")
  36. test()
  37. test("test/build_profile.json")