-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTOOLS
72 lines (52 loc) · 1.81 KB
/
TOOLS
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
#!/usr/bin/python3
import json
import os
import subprocess
import sys
import shutil
import sys
sys.path.insert(0, os.path.join(os.getcwd(), "scripts"))
import project
def get_projects(location):
"""
Get all projects in a directory.
Parameters
----------
location: location of the directorie (str).
Return
------
A list of all projects.
"""
projects = {}
for file in os.listdir(location):
# Get project's paths
project_path = os.path.join(location, file)
json_path = os.path.join(project_path, "project.json")
if os.path.isdir(project_path) and os.path.exists(json_path):
# Load project's json.
data = json.loads(open(json_path).read())
projects[data["id"]] = project.Project(project_path, data)
return projects
# --- Build Script ----------------------------------------------------------- #
if __name__ == "__main__":
projects = get_projects(".")
if len(sys.argv) == 3 and sys.argv[1] == "info":
projects[sys.argv[2]].info()
if len(sys.argv) == 2 and sys.argv[1] == "list":
for project in projects:
print(project, end=' ')
print('')
if len(sys.argv) == 3 and sys.argv[1] == "clean":
projects[sys.argv[2]].clean()
if len(sys.argv) == 2 and sys.argv[1] == "cleanall":
for id in projects:
projects[id].clean()
if len(sys.argv) == 3 and sys.argv[1] == "build":
projects[sys.argv[2]].build(projects)
if len(sys.argv) == 2 and sys.argv[1] == "buildall":
for id in projects:
if not projects[id].build(projects):
print("Building %s failed!" % id)
exit()
if (len(sys.argv) == 1) or (len(sys.argv) == 2 and sys.argv[1] == "help"):
print("CarrotOS build system.")