-
Notifications
You must be signed in to change notification settings - Fork 6
/
clean.py
executable file
·49 lines (38 loc) · 1.36 KB
/
clean.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
#!/usr/bin/python
import os;
import sys;
import argparse;
import shutil;
def main():
parser = argparse.ArgumentParser();
parser.add_argument("--rebuild", dest = "rebuild", action = "store_true");
parser.add_argument("--no-rebuild", dest = "rebuild", action = "store_false");
parser.set_defaults(rebuild = False);
args = parser.parse_args();
rebuild = args.rebuild;
# Recursivly clean all the binary directories.
list_clean = list();
path_cur = os.getcwd();
for path_dir, list_dir, list_file in os.walk(path_cur):
if path_dir.endswith("build"):
list_clean.append(path_dir);
elif path_dir.endswith("lib"):
list_clean.append(path_dir);
elif path_dir.endswith("bin"):
list_clean.append(path_dir);
elif path_dir.endswith("export"):
list_clean.append(path_dir);
for path_clean in list_clean:
if os.path.isdir(path_clean) == True:
shutil.rmtree(path_clean);
# Create the build folder if necessary.
if rebuild == False:
return;
for path_dir, list_dir, list_file in os.walk(path_cur):
if path_dir.endswith("engine"):
path_build = path_dir.replace("engine", "build");
if os.path.isdir(path_build) == False:
os.makedirs(path_build);
return;
if __name__ == "__main__":
main();