aboutsummaryrefslogtreecommitdiffstats
path: root/build/scripts/generate_win_vfs.py
blob: b6635aee7d8462f1c6ec4a4e102ff5804f957184 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import json
import os
import sys


def make_vfsoverlay(bin_dir, args):
    # args - list of paths in format: '/LIBPATH:"path_to_dir"'
    libpaths = [path[len('/LIBPATH:"'):-1] for path in args]
    overlay = {
        "version": 0,
        "case-sensitive": "false",
        "roots": []
    }
    for dir in libpaths:
        for file in os.listdir(dir):
            path_to_file = os.path.join(dir, file)
            root = {
                "type": "file",
                "name": path_to_file,
                "external-contents": path_to_file
            }
            overlay["roots"].append(root)

    with open(os.path.join(bin_dir, "vfsoverlay.yaml"), "w") as f:
        json.dump(overlay, f)


if __name__ == '__main__':
    bin_dir = sys.argv[1]
    args = sys.argv[2:]
    make_vfsoverlay(bin_dir, args)