forked from danieleteti/delphimvcframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdodo.py
More file actions
289 lines (250 loc) · 9.19 KB
/
Copy pathdodo.py
File metadata and controls
289 lines (250 loc) · 9.19 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
import glob
import os
import subprocess
from shutil import copy2, rmtree
from datetime import datetime
from colorama import *
init() # colorama initialization
# task setup env
DOIT_CONFIG = {'verbosity': 2, 'default_tasks': ['build']}
##########################################################################
############## CONFIGURATION #############################################
##########################################################################
projects = glob.glob("ideexpert\*.dproj")
projects += glob.glob("unittests\**\*.dproj")
projects += glob.glob("samples\**\*.dproj")
failed = []
#projects += glob.glob("*\**\**\*.dproj")
releases_path = "releases"
output = "bin"
output_folder = "" # defined at runtime
##########################################################################
############## END CONFIGURATION #########################################
##########################################################################
# if we are building an actual release, this will be replaced
GlobalBuildVersion = 'DEV'
def header(headers):
elements = None
if type(headers).__name__ == 'str':
elements = [headers]
else:
elements = headers
print(Style.BRIGHT + Back.WHITE + Fore.RED + "*" * 78 + Style.RESET_ALL)
for txt in elements:
s = '{:^78}'.format(txt)
print(Style.BRIGHT + Back.WHITE + Fore.RED + s + Style.RESET_ALL)
print(Style.BRIGHT + Back.WHITE + Fore.RED + "*" * 78 + Style.RESET_ALL)
def buildProject(project, config='DEBUG'):
header(["Building", project, "(config " + config + ")"])
p = project.replace('.dproj', '.cfg')
if os.path.isfile(p):
if os.path.isfile(p + '.unused'):
os.remove(p + '.unused')
os.rename(p, p + '.unused')
rsvars_path = 'C:\\Program Files (x86)\\Embarcadero\\Studio\\19.0\\bin\\rsvars.bat'
if not os.path.isfile(rsvars_path):
rsvars_path = 'D:\\Program Files (x86)\\Embarcadero\\Studio\\19.0\\bin\\rsvars.bat'
if not os.path.isfile(rsvars_path):
return False
cmdline = '"' + rsvars_path + '"' + " & msbuild /t:Build /p:Config=" + config + " /p:Platform=Win32 \"" + project + "\""
print("Running: " + cmdline)
return subprocess.call(cmdline, shell=True) == 0
def buildProjects(config='RELEASE'):
global failed
failed = list()
allres = True
for project in projects:
res = buildProject(project, config)
allres &= res
if not res:
failed.append(project)
if not allres:
print(failed)
return allres
def run_unit_tests():
import os
apppath = os.path.dirname(os.path.realpath(__file__))
res = True
tests = [
"unittests\serializer\jsondataobjects\TestSerializerJsonDataObjects.dproj"
]
testsexe = [
"unittests\serializer\jsondataobjects\Win32\CI\TestSerializerJsonDataObjects.exe"
]
i = 0
for test_project in tests:
res = buildProject(test_project, 'CI') and res
if res:
exename = apppath + "\\" + testsexe[i]
print("Running: " + exename)
retcode = subprocess.call(exename)
print("ExitCode = " + str(retcode))
res = retcode == 0
if not res:
print("UnitTest execution failed!")
return False
i = i + 1
return res
def copy_sources():
global output_folder
os.makedirs(output_folder + "\\sources", exist_ok=True)
os.makedirs(output_folder + "\\ideexpert", exist_ok=True)
# copying main sources
header("Copying DMVCFramework Sources...")
src = glob.glob("sources\\*.pas") + glob.glob("sources\\*.inc")
for file in src:
print("Copying " + file + " to " + output_folder + "\\sources")
copy2(file, output_folder + "\\sources\\")
# copy2("lib\\jsondataobjects\\Source\\JsonDataObjects.pas",
# output_folder + "\\sources\\")
# copying ideexperts
header("Copying DMVCFramework IDEExpert...")
print("Copying ideexpert")
src = glob.glob("ideexpert\\*.pas") + \
glob.glob("ideexpert\\*.dfm") + \
glob.glob("ideexpert\\*.ico") + \
glob.glob("ideexpert\\*.bmp") + \
glob.glob("ideexpert\\*.dpk") + \
glob.glob("ideexpert\\*.dproj")
for file in src:
print("Copying " + file + " to " + output_folder + "\\ideexpert")
copy2(file, output_folder + "\\ideexpert\\")
def copy_libs(ctx):
global output_folder
# loggerpro
header("Copying libraries: LoggerPro...")
curr_folder = output_folder + "\\lib\\loggerpro"
os.makedirs(curr_folder, exist_ok=True)
if not ctx.run(rf"xcopy lib\loggerpro\*.* {curr_folder}\*.* /E /Y /R /V /F"):
raise Exception("Cannot copy loggerpro")
header("Copying libraries: dmustache...")
curr_folder = output_folder + "\\lib\\dmustache"
os.makedirs(curr_folder, exist_ok=True)
if not ctx.run(rf"xcopy lib\dmustache\*.* {curr_folder}\*.* /E /Y /R /V /F"):
raise Exception("Cannot copy dmustache")
# src = glob.glob("lib\\loggerpro\\*.pas")
# for file in src:
# print("Copying " + file + " to " + curr_folder)
# copy2(file, curr_folder)
# copy2("lib\\loggerpro\\LICENSE", curr_folder)
# copy2("lib\\loggerpro\\VERSION.TXT", curr_folder)
#
# # dmustache
# header("Copying libraries: dmustache...")
# curr_folder = output_folder + "\\lib\\dmustache"
# os.makedirs(curr_folder, exist_ok=True)
# src = glob.glob("lib\\dmustache\\*.pas") + \
# glob.glob("lib\\dmustache\\*.inc")
# for file in src:
# print("Copying " + file + " to " + curr_folder)
# copy2(file, curr_folder)
# copy2("lib\\dmustache\\README.md", curr_folder)
def init_build(version):
'''Required by all tasks'''
global GlobalBuildVersion
global output_folder
global releases_path
GlobalBuildVersion = version
output_folder = releases_path + "\\" + version
print('Output path: ' + output_folder)
header("BUILD VERSION: " + GlobalBuildVersion)
rmtree(output_folder, True)
os.makedirs(output_folder, exist_ok=True)
f = open(output_folder + "\\version.txt", "w")
f.write("VERSION " + GlobalBuildVersion + "\n")
f.write("BUILD DATETIME " + datetime.now().isoformat() + "\n")
f.close()
copy2("README.md", output_folder)
copy2("3_0_0_breaking_changes.md", output_folder)
copy2("roadmap.md", output_folder)
copy2("LICENSE", output_folder)
def zip_samples(version):
global output_folder
cmdline = "7z a " + output_folder + "\\dmvcframeworksamples.zip -r -i@7ziplistfile.txt"
return subprocess.call(cmdline, shell=True) == 0
def create_zip(version):
global output_folder
header("CREATING ZIP")
archivename = "..\\dmvcframework_" + version + ".zip"
#switches = " -o.\\" + releases_path + " -w.\\" + output_folder
switches = ""
#switches = " -oD:\\DEV\\dmvcframework\\releases\\" + " -w " + output_folder
#filenames = output_folder + "\\*"
filenames = "*"
cmdline = "cd " + output_folder + " & 7z.exe a " + \
switches + " " + archivename + " " + filenames
print(cmdline)
return subprocess.call(cmdline, shell=True) == 0
##########################################################################
def task_build():
'''Use: doit build -v <VERSION>.'''
return {
'actions': [
run_unit_tests,
buildProjects,
init_build,
copy_sources,
copy_libs,
zip_samples,
create_zip],
'params': [{'name': 'version',
'short': 'v',
'long': 'version',
'type': str,
'default': 'DEVELOPMENT'},
{'name': 'config',
'short': 'c',
'long': 'config',
'type': str,
'default': 'DEBUG'}
],
'verbosity': 2
}
def task_tests():
'''Use: doit tests'''
return {
'actions': [
run_unit_tests
],
'verbosity': 2
}
def task_zip():
'''Use: doit zip -v <VERSION>.'''
return {
'actions': [
create_zip],
'params': [{'name': 'version',
'short': 'v',
'long': 'version',
'type': str,
'default': 'DEVELOPMENT'},
{'name': 'config',
'short': 'c',
'long': 'config',
'type': str,
'default': 'DEBUG'}
],
'verbosity': 2
}
def task_buildlight():
'''Use: doit buildlight -> Builds all the projects.'''
return {
'actions': [
#'echo off && touch bin\\x.exe && del bin\\*.exe',
buildProjects],
'verbosity': 2
}
def task_samples():
'''creates the samples zip file'''
return {
'actions': [init_build, zip_samples],
'params': [
{
'name': 'version',
'short': 'v',
'long': 'version',
'type': str,
'default': 'DEVELOPMENT'
}
]
}