generate_win_vfs.py 816 B

12345678910111213141516171819202122232425262728293031
  1. import json
  2. import os
  3. import sys
  4. def make_vfsoverlay(bin_dir, args):
  5. # args - list of paths in format: '/LIBPATH:"path_to_dir"'
  6. libpaths = [path[len('/LIBPATH:"'):-1] for path in args]
  7. overlay = {
  8. "version": 0,
  9. "case-sensitive": "false",
  10. "roots": []
  11. }
  12. for dir in libpaths:
  13. for file in os.listdir(dir):
  14. path_to_file = os.path.join(dir, file)
  15. root = {
  16. "type": "file",
  17. "name": path_to_file,
  18. "external-contents": path_to_file
  19. }
  20. overlay["roots"].append(root)
  21. with open(os.path.join(bin_dir, "vfsoverlay.yaml"), "w") as f:
  22. json.dump(overlay, f)
  23. if __name__ == '__main__':
  24. bin_dir = sys.argv[1]
  25. args = sys.argv[2:]
  26. make_vfsoverlay(bin_dir, args)