-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuild_Linux.py
82 lines (74 loc) · 2.43 KB
/
Build_Linux.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/python3
from glob import glob
from os import system
from os import remove
import platform
import os
global incdir
incdir = ("../../Libs/Units/Headers","../../Libs/Kitty/Headers")
Units = ("SlyvAsk","SlyvDir","SlyvDirry","SlyvQCol","SlyvSTOI","SlyvStream","SlyvString","SlyvTime","SlyvVolumes")
def gcc(name,dir):
print("Building: ",name)
print("Dir: ",dir)
d=glob(dir+"/*.c")
for fp in d:
print("Compiling: ",fp)
sfp=fp.split("/")
o = sfp[len(sfp)-1]
o = o[:-1]+"o"
return_code = system("gcc -c -o Linux/Objects/%s \"%s\""%(o,fp))
if return_code>0:
print("Compilation failed! (%d)"%return_code)
quit()
def delf(file):
print("Deleting: ",file)
remove(file)
def gpp(name,dir,full=True,dirislist=False):
global incdir
print("Building: ",name)
if full: print("Include dirs:",incdir)
if dirislist:
print("%d specific files requested"%len(dir))
d=dir
else:
print("Dir: ",dir)
print("%d files found"%len(dir))
d=glob(dir+"/*.cpp")
for fp in d:
print("Compiling: ",fp)
sfp=fp.split("/")
o = sfp[len(sfp)-1]
o = o[:-3]+"o"
cmd = "g++ -Woverflow -c -o Linux/Objects/%s "%o
if full:
for id in incdir:
cmd+="\"-I%s\" "%id
cmd += " \"%s\""%fp
# print cmd # debug (Python 2)
return_code = system(cmd)
if return_code>0:
print("Compilation failed! (%d)"%return_code)
quit()
def glijst(dir,lst):
ret = []
for l in lst: ret.append("%s/%s.cpp"%(dir,l))
return ret
def newdir(d):
if not os.path.exists(d):
print("Creating directory: ",d)
os.makedirs(d)
print("Building Kitty for Linux")
print("OS: ",platform.system(),"; release: ",platform.release())
if platform.system()!="Linux":
print("I'm sorry, but this script has been designed for Linux Only!")
quit()
newdir("Linux")
newdir("Linux/Objects")
newdir("Linux/Exe")
gpp("Slyvina Units",glijst("../../Libs/Units/Source",Units),True,True)
gpp("Kitty Library","../../Libs/Kitty/Source")
gpp("Kitty Application","Kitty/src")
print("Linking: Linux/Exe/Kitty")
rc = system("g++ -o Linux/Exe/Kitty Linux/Objects/*.o")
if rc!=0:
print("Error in linking (%d): "%rc)