-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestbuild.js
296 lines (251 loc) · 8.62 KB
/
testbuild.js
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
290
291
292
293
294
295
296
/* testbuild.js */
/* JSexec script for nightly Synchronet test builds */
/* $Id: testbuild.js,v 1.33 2020/04/19 19:50:43 rswindell Exp $ */
require("smbdefs.js", 'SMB_PRIORITY_HIGHEST');
var keep = false;
for(i=0;i<argc;i++)
if(argv[i]=="-k")
keep=true;
var date_str = strftime("%b-%d-%y"); /* mmm-dd-yy */
var temp_dir = backslash(system.temp_path) + "sbbs-" + date_str;
if(!file_isdir(temp_dir) && !mkdir(temp_dir)) {
log(LOG_ERR,"!Failed to create temp directory: " + temp_dir);
exit(1);
}
log(LOG_INFO,"Using temp directory: " + temp_dir);
putenv("CVSROOT=:pserver:[email protected]:/cvsroot/sbbs");
var platform = system.platform.toLowerCase();
if(system.architecture=="x64")
platform += "-x64";
var make = (platform=="win32" ? "make":"gmake");
var build_output = "build_output.txt";
var archive;
var archive_cmd;
var lib_alias="lib";
var cleanup;
if(platform=="win32") {
archive="sbbs_src.zip";
archive_cmd="pkzip25 -exclude=*output.txt -add -dir -max " + archive;
cleanup="rmdir /s /q ";
lib_alias="lib-win32";
} else {
archive="sbbs_src.tgz";
archive_cmd="tar --exclude=*output.txt -czvf " + archive + " *";
cleanup="rm -r -f "
}
var builds
= [/* sub-dir */ /* cmd-line */ /* redirect */
["" ,"cvs co src-sbbs3" ,"2> " + build_output],
["" ,"cvs co "+lib_alias ,"2> " + build_output],
["" ,archive_cmd ,"2> " + build_output],
// ["3rdp" ,lib_cmd ,"2> " + build_output],
];
/* Platform-specific (or non-ported) projects */
if(platform=="win32") {
/* Requires Visual C++ 2019 */
builds.push(["src/sbbs3" ,'build.bat /v:m "/p:Configuration=Release"'
,"> " + build_output]);
/* Requires C++Builder */
builds.push(["src/xpdev" ,"make"
,"> " + build_output]);
builds.push(["src/sbbs3/ctrl" ,"makelibs.bat ..\\msvc.win32.dll.release"
,"> " + build_output]);
builds.push(["src/sbbs3/ctrl" ,"bpr2mak sbbsctrl.bpr & make -f sbbsctrl.mak"
,"> " + build_output]);
builds.push(["src/sbbs3/chat" ,"bpr2mak chat.bpr & make -f chat.mak"
,"> " + build_output]);
builds.push(["src/sbbs3/useredit" ,"build.bat"
,"> " + build_output]);
} else { /* Unix */
builds.push(["src/sbbs3" ,"gmake RELEASE=1" ,"2> " + build_output]);
}
var win32_dist
= [ "README.TXT",
"FILE_ID.DIZ",
"src/sbbs3/msvc.win32.exe.release/*.exe",
"src/sbbs3/msvc.win32.dll.release/*.dll",
"src/sbbs3/scfg/msvc.win32.exe.release/*.exe",
"src/sbbs3/scfg/msvc.win32.exe.release/scfghelp.*",
"src/sbbs3/chat/chat.exe",
"src/sbbs3/ctrl/sbbsctrl.exe",
"src/sbbs3/useredit/useredit.exe",
"3rdp/win32.release/mozjs/bin/*.dll",
"3rdp/win32.release/nspr/bin/*.dll",
"3rdp/win32.release/cryptlib/bin/*.dll",
"s:/sbbs/exec/dosxtrn.exe"
];
var nix_dist
= [ "README.TXT",
"FILE_ID.DIZ",
"src/sbbs3/gcc.*.exe.release/*",
"src/sbbs3/gcc.*.lib.release/*",
"src/sbbs3/*/gcc.*.exe.release/*",
];
chdir(temp_dir);
var system_description=system.local_host_name + " - " + system.os_version;
var file = new File("README.TXT");
if(file.open("wt")) {
file.writeln(format("Synchronet-%s C/C++ Source Code Archive (%s)\n"
,system.platform, system.datestr()));
file.writeln("This archive contains a snap-shot of all the source code and library files");
file.writeln("necessary for a successful " + system.platform
+ " build of the following Synchronet projects");
file.writeln("as of " + system.datestr() + ":");
file.writeln();
file.writeln(format("%-20s %s", "Project Directory", "Build Command"));
for(i in builds) {
if(builds[i][0].length)
file.writeln(format("%-20s %s", builds[i][0], builds[i][1]));
}
file.writeln();
file.writeln("Builds verified on " + system.timestr());
file.writeln(system_description);
file.writeln();
file.writeln("For more details, see http://wiki.synchro.net/dev:source");
file.writeln("and http://wiki.synchro.net/install:dev");
file.close();
}
var file = new File("FILE_ID.DIZ");
if(file.open("wt")) {
file.writeln(format("Synchronet-%s (%s) BBS Software",system.platform, system.architecture));
file.writeln(format("C/C++ source code archive (%s)",system.datestr()));
if(platform=="win32")
file.writeln("Unzip *with* directories!");
file.writeln("http://www.synchro.net");
file.close();
}
var start = time();
if(1) {
for(i = 0; i < builds.length; i++) {
var sub_dir = builds[i][0];
var build_dir = temp_dir + "/" + sub_dir;
var subject = system.platform + " build failure in " + sub_dir;
log(LOG_DEBUG,"Build " + i+1 + " of " + builds.length);
if(sub_dir.length)
log(LOG_INFO, "Build sub-directory: " + sub_dir);
if(!chdir(build_dir)) {
semd_email(subject, log(LOG_ERR,"!FAILED to chdir to: " + build_dir));
bail(1);
}
builds[i].start = time();
var cmd_line = builds[i][1];
if(builds[i][2])
cmd_line += " " + builds[i][2];
log(LOG_INFO, "Executing: " + cmd_line);
var retval=system.exec(cmd_line);
log(LOG_INFO, "Done: " + cmd_line);
if(retval) {
send_email(subject,
log(LOG_ERR,"!ERROR " + retval + " executing: '" + cmd_line + "' in " + sub_dir)
+ "\n\n" + file_contents(build_output)
,SMB_PRIORITY_HIGHEST);
bail(1);
}
builds[i].end = time();
}
var body = "System: " + system_description + "\n\n";
for(i in builds) {
body += elapsed_time(builds[i].end-builds[i].start) + " - ";
body += builds[i][0] + "\t" + builds[i][1];
body += "\n";
}
body += "-----\n";
body += elapsed_time(time()-start) + " - total\n";
send_email(system.platform + " builds successful in " + elapsed_time(time() - start), lfexpand(body));
chdir(temp_dir);
system.exec("cvs -d:pserver:[email protected]:/cvsroot/sbbs tag -RF goodbuild_" + platform);
var dest = file_area.dir["sbbs"].path+archive;
log(LOG_INFO,format("Copying %s to %s",archive,dest));
if(!file_copy(archive,dest))
log(LOG_ERR,format("!ERROR copying %s to %s",archive,dest));
var file = new File("README.TXT");
if(file.open("wt")) {
file.writeln(format("Synchronet-%s (%s) Version 3 Development Executable Archive (%s)\n"
,system.platform,system.architecture,system.datestr()));
file.writeln(format("This archive contains a snap-shot of Synchronet-%s executable files"
,system.platform));
file.writeln("created on " + system.timestr());
file.writeln();
file.writeln("The files in this archive are not necessarily well-tested, DO NOT");
file.writeln("constitute an official Synchronet release, and are NOT SUPPORTED!");
file.writeln();
file.writeln("USE THESE FILES AT YOUR OWN RISK");
file.writeln();
file.writeln("BACKUP YOUR WORKING EXECUTABLE FILES");
file.writeln("BEFORE over-writing them with the files in this archive!");
file.close();
}
var file = new File("FILE_ID.DIZ");
if(file.open("wt")) {
file.writeln(format("Synchronet-%s BBS Software",system.platform));
file.writeln(format("Development Executable Archive (%s)",system.datestr()));
file.writeln("Snapshot for experimental purposes only!");
file.writeln("http://www.synchro.net");
file.close();
}
}
var cmd_line;
if(platform=="win32") {
archive = "sbbs_dev.zip";
cmd_line = "pkzip25 -add " + archive
+ " -exclude=makehelp.exe -exclude=v4upgrade.exe " + win32_dist.join(" ");
} else {
archive = "sbbs_dev.tgz";
cmd_line = "pax -s :.*/makehelp.*::p -s :.*/::p -wzf " + archive + " " + nix_dist.join(" ");
}
log(LOG_INFO, "Executing: " + cmd_line);
system.exec(cmd_line);
dest = file_area.dir["sbbs"].path+archive;
log(LOG_INFO,format("Copying %s to %s",archive,dest));
if(!file_copy(archive,dest))
log(LOG_ERR,format("!ERROR copying %s to %s",archive,dest));
bail(0);
/* end */
function bail(code)
{
if(cleanup && !keep) {
chdir(temp_dir + "/..");
log(LOG_INFO, "Executing: " + cleanup + temp_dir);
var retval=system.exec(cleanup + temp_dir);
if(retval)
log(LOG_ERR,format("!ERROR %d executing %s", retval, cleanup + temp_dir));
}
exit(code);
}
function elapsed_time(t)
{
return format("%02u:%02u", t/60, t%60);
}
function file_contents(fname)
{
var file = new File(fname);
if(!file.open("rt")) {
return log(LOG_ERR, "!ERROR " + errno_str + " opening " + fname);
}
var msgtxt = lfexpand(file.read(file.length));
file.close();
delete file;
return(msgtxt);
}
function send_email(subject, body, priority)
{
var msgbase = new MsgBase("mail");
if(msgbase.open()==false) {
log(LOG_ERR,"!ERROR " + msgbase.last_error);
return(false);
}
var hdr = {
from: "Synchronet testbuild.js",
subject: subject,
priority: priority
};
var rcpt_list = [
{to: "Rob Swindell", to_ext: 1},
{to: "Stephen Hurd", to_net_addr: "[email protected]", to_net_type: NET_INTERNET }
];
if(!msgbase.save_msg(hdr, body, rcpt_list))
log(LOG_ERR, "!ERROR " + msgbase.last_error + " saving mail message");
else
log(LOG_INFO, "E-mail sent.");
msgbase.close();
}