This repository has been archived by the owner on May 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_includes
executable file
·74 lines (54 loc) · 1.55 KB
/
build_includes
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/python3
import sys
import json
import os
"""
TEMPORARY SOLUTION (this will be replaced by a proper dependency manager in the future):
Convert a json object representing the dependencies of a project into the binary format accepted by quinoa
FORMAT:
{
prefix? : str,
modules : { name -> path },
deps? : [ list of paths to qpk.json files ]
}
"""
def err(message : str):
print("error: " + message)
exit(1)
assert(len(sys.argv) == 2)
incl_file = sys.argv[1];
incl_file = os.path.abspath(incl_file)
def grab_modules(fpath : str):
fpath = os.path.abspath(fpath)
_dir = os.path.dirname(fpath)
f = open(fpath, "r")
incl_json = json.load(f)
f.close()
if not "modules" in incl_json:
err("Expected a 'modules' entry in " + incl_file);
modules = {}
if "prefix" in incl_json:
pfx = incl_json["prefix"]
for m in incl_json["modules"].items():
modules[f"{pfx}::{m[0]}"] = m[1]
else:
modules = incl_json["modules"]
if "deps" in incl_json:
for d in incl_json["deps"]:
path = os.path.abspath(d)
mods = grab_modules(path)
for k, v in mods.items():
modules[k] = v
for k,v in modules.items():
modules[k] = os.path.join(_dir, v)
return modules
mods = grab_modules(incl_file)
# Quinoa takes the format name#path;
output = []
null = chr(0x0)
for name, path in mods.items():
output.append(f"{name}#{path}")
res = ";".join(output)
# for k, v in mods.items():
# print(k, v)
print(res, end="")