check_get_file_list.py 1.3 KB

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