-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDependenciesBuilder.py
More file actions
135 lines (99 loc) · 3.9 KB
/
Copy pathDependenciesBuilder.py
File metadata and controls
135 lines (99 loc) · 3.9 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import os
cwd = os.getcwd()
working_directory = 'build/Windows'
def compile_dep(process, config, external_folder):
j_config = config['compiler']
if 'groups' not in j_config:
print('Please specify groups!')
return
src_files = j_config['groups']
found_group = False
for group in src_files:
if group['name'] == 'MAIN':
src_files = group
found_group = True
break
files_to_compile = []
files_to_exclude = []
if found_group:
for file in src_files['src_files']:
if file.find('$RCV$') >= 0:
file = file.replace('$RCV$', '')
for subdir, dirs, files in os.walk(cwd + '/external/' + external_folder + '/' + file):
for file_ in files:
if file_.endswith('.cpp') or file_.endswith('.c') or file_.endswith('.cc'):
files_to_compile.append(subdir + '/' + file_)
elif file.find('$NOT$') >= 0:
file = file.replace('$NOT$', '')
files_to_exclude.append(file)
else:
files_to_compile.append(cwd + '/external/' + external_folder + '/' + file)
else:
print('Please specify files to compile!')
for i in range(len(files_to_compile)):
files_to_compile[i] = os.path.normpath(files_to_compile[i])
for i in range(len(files_to_exclude)):
files_to_exclude[i] = os.path.normpath(files_to_exclude[i])
files_to_compile_new = []
for file in files_to_compile:
found = False
for exclude in files_to_exclude:
if file.find(exclude) >= 0:
found = True
break
if not found:
files_to_compile_new.append(file)
files_to_compile.clear()
files_to_compile = files_to_compile_new
for file in files_to_compile:
print(file)
process.WriteInput('cd ' + cwd + '/' + working_directory)
process.Wait()
check_path = cwd + '/' + working_directory + '/' + external_folder
if os.path.isdir(check_path):
process.WriteInput('cd ' + external_folder)
process.Wait()
else:
os.mkdir(check_path)
process.WriteInput('cd ' + external_folder)
process.Wait()
flags = ''
defs = ''
includes = ''
external_libs = ''
obj_files = ''
for key in j_config['flags']:
flags += '/' + key + ' '
for key in j_config['definitions']:
defs += '/D' + key + ' '
for key in j_config['includes']:
key = key.replace('$CWD$', cwd)
includes += '/I' + key + ' '
for key in j_config['lib_paths']:
key = key.replace('$CWD$', cwd)
external_libs += '/LIBPATH:' + key + ' '
for key in j_config['libs']:
external_libs += key + ' '
for file_to_compile in files_to_compile:
process.WriteInput('cl ' + flags + ' ' + defs + ' ' + includes + ' /c ' + file_to_compile)
process.Wait()
if process.WasError():
print("Error while compiling:", process.GetErrorMessage())
file_to_compile = cwd + '/' + working_directory + '/' + external_folder + '/' + os.path.splitext(os.path.basename(file_to_compile))[0] + '.obj '
if os.path.isfile(file_to_compile):
obj_files += file_to_compile
if obj_files != '':
if config['out_type'] == 'lib':
process.WriteInput('lib ' + obj_files + '/OUT:' + cwd + '/bin/' + external_folder + '.lib')
process.Wait()
elif config['out_type'] == 'dll':
process.WriteInput('cl ' +
flags + ' ' +
defs + ' ' +
includes + ' ' +
' /Fe' + cwd + '/bin/' + external_folder + '.dll' + ' ' +
obj_files + '/link ' + external_libs
)
process.Wait()
if process.WasError():
print("Error while compiling:", process.GetErrorMessage())