-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.py
60 lines (36 loc) · 1.29 KB
/
build.py
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
import os
import json
import importlib.util
path = os.path.dirname(os.path.abspath(__file__)).replace("\\", "/")
def main():
if not os.path.exists(path+"/build.json"):
print("\""+path+"build.json\" not found.")
return
data = None
with open(path+"/build.json") as f:
data = json.load(f)
if data is None or len(data) <= 0:
print("build.json is corrupted.")
return
builderDir = None
if "jarBuilder" in data and "path" in data["jarBuilder"]:
builderDir = os.path.abspath(data["builder"]["path"]).replace("\\", "/")
else:
builderDir = "jarBuilder"
buildScriptFile = builderDir+"/jarBuilder.py"
if not os.path.exists(buildScriptFile):
print("\""+buildScriptFile+"\" not found.")
return
jarCreatorFile = builderDir+"/jarCreator.py"
if not os.path.exists(buildScriptFile):
print("\""+jarCreatorFile+"\" not found.")
return
buildScript = loadModule("jarBuilder", buildScriptFile)
buildScript.build(path, data, loadModule("jarCreator", jarCreatorFile))
def loadModule(moduleName, moduleFile):
spec = importlib.util.spec_from_file_location(moduleName, moduleFile)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
if __name__ == "__main__":
main()