This repository has been archived by the owner on Feb 12, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
606 lines (560 loc) · 40.5 KB
/
install.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
//
// install.js - Windows Configuration
//
// (C) 2003-2013 Anope Team
// Contact us at [email protected]
//
// This program is free but copyrighted software; see the file COPYING for
// details.
//
// Based on the original code of Epona by Lara.
// Based on the original code of Services by Andy Church.
//
//
var anopeVersion = "Unknown";
var vMaj, vMin, vPat, vBuild, vExtra;
var drivesToCheck = ['C', 'D', 'E', 'F', 'G', 'H'];
var installerResponses = new Array();
var softwareVersions = {
'Compiler' : false,
'MySQLDB' : false
};
var installerQuestions = [
{
'question' : [
'Do you want to compile Anope with MySQL Support?',
'NOTE: You will need to have installed MySQL 3.23 or Above'
],
'short' : 'Enable MySQL Support?',
'options' : [
'yes',
'no'
],
'default_answer' : 'no',
'store_answer' : function (answer) {
if (answer == 'yes') {
if (!findMySQL()) {
WScript.Echo("\nERROR: Cannot find MySQL - See error messages above for details.\n");
return false;
}
}
installerResponses['MySQL DB Support'] = answer;
return true;
},
'commit_config' : function() {
if (installerResponses['MySQL DB Support'] == 'yes') {
f.WriteLine("USE_MYSQL=1");
f.WriteLine("MYSQL_LIB=\""+softwareVersions['MySQLDB'].installedDrive+":\\"+softwareVersions['MySQLDB'].libpaths[0]+"\"");
f.WriteLine("MYSQL_INC=\""+softwareVersions['MySQLDB'].installedDrive+":\\"+softwareVersions['MySQLDB'].incpaths[0]+"\"");
f.WriteLine("LIBS=$(LIBS) /LIBPATH:$(MYSQL_LIB)");
f.WriteLine("MYSQL_LIB_PATH=/LIBPATH:$(MYSQL_LIB)");
f.WriteLine("BASE_CFLAGS=$(BASE_CFLAGS) /I $(MYSQL_INC)");
f.WriteLine("MYSQL_INC_PATH=/I $(MYSQL_INC)");
f.WriteLine("RDB_C=rdb.c");
f.WriteLine("RDB_O=rdb.obj");
f.WriteLine("MYSQL_C=mysql.c");
f.WriteLine("MYSQL_O=mysql.obj");
f.WriteLine("BASE_CFLAGS=/D USE_MYSQL /D USE_RDB $(BASE_CFLAGS) /D HAVE_MYSQL_MYSQL_H");
f.WriteLine("MYPASQL_BUILD=$(CC) /LD $(MYSQL_INC_PATH) src\\mypasql.c /link $(MYSQL_LIB_PATH) $(LFLAGS) /DEF:src\mypasql.def libmysql.lib ws2_32.lib advapi32.lib /NODEFAULTLIB:LIBCMTD.lib");
f.WriteLine("LIBS=$(LIBS) libmysql.lib");
}
else {
f.WriteLine("USE_MYSQL=0");
}
}
},
];
var buildPackages = [
{
'name' : 'Microsoft Visual Studio 2012',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 11.0\\VC\\lib',
'Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Lib',
'Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0\\Lib',
],
'incpaths': [
'Program Files\\Microsoft Visual Studio 11.0\\VC\\include',
'Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\include',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Include',
'Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0\\Include',
],
'nmake' : [
'Program Files\\Microsoft Visual Studio 11.0\\VC\\bin',
'Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2010 (64bit)',
'libpaths' : [
'Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Lib',
'Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Lib'
],
'incpaths': [
'Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include',
'Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Include',
'Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Include'
],
'nmake' : [
'Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2010',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 10.0\\VC\\lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.1\\Lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Lib',
'Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 10.0\\VC\\include',
'Program Files\\Microsoft SDKs\\Windows\\v7.1\\Include',
'Program Files\\Microsoft SDKs\\Windows\\v7.0\\Include',
'Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Include'
],
'nmake' : [
'Program Files\\Microsoft Visual Studio 10.0\\VC\\bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2008',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 9.0\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 9.0\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2008 (64bit)',
'libpaths' : [
'Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
],
'additional_switches' : [ '/w' ],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2005',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Lib',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Include',
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Bin',
''
],
'additional_switches' : [
'/w'
],
'installedDrive' : 'C'
},
{
'name' : 'Microsoft Visual Studio 2005 (Old PSDK)',
'libpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Lib',
'Program Files\\Microsoft Platform SDK\\Lib'
],
'incpaths' : [
'Program Files\\Microsoft Visual Studio 8\\VC\\Include',
'Program Files\\Microsoft Platform SDK\\Include'
],
'nmake' : [
'Program Files\\Microsoft Platform SDK\\Bin',
''
],
'additional_switches' : [
'/w'
],
'installedDrive' : 'C'
}
];
var mysqlVersions = [
{
'name' : 'MySQL 5.5',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 5.5\\Lib'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 5.5\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 5.5\\bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 5.1',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 5.1\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 5.1\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 5.1\\bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 5.0',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 5.0\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 5.0\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 5.0\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 4.1',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 4.1\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 4.1\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 4.1\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 4.0',
'libpaths' : [
'Program Files\\MySQL\\MySQL Server 4.0\\Lib\\opt'
],
'incpaths' : [
'Program Files\\MySQL\\MySQL Server 4.0\\Include'
],
'dllfile' : 'Program Files\\MySQL\\MySQL Server 4.0\\Bin\\libmysql.dll',
'installedDrive' : 'C'
},
{
'name' : 'MySQL 3.23 or older (or other default path)',
'libpaths' : [
'mysql\\lib\\opt'
],
'incpaths' : [
'mysql\\include'
],
'dllfile' : 'mysql\\Bin\\libmysql.dll',
'installedDrive' : 'C'
}
];
var bannerReplacements = [
{
'findtext' : /CURVER/g,
'replacement' : function() { FindAnopeVersion(); return anopeVersion; }
},
{
'findtext' : / For more options type .\/Config --help/g,
'replacement' : function() { return ''; }
}
];
var fso = WScript.CreateObject("Scripting.FileSystemObject");
var x, y, z;
if (fso.FileExists('.BANNER')) {
var bannerStream = fso.OpenTextFile(".BANNER");
var bannerText = bannerStream.ReadAll();
bannerStream.close();
for (x in bannerReplacements) {
var thisReplacement = bannerReplacements[x];
bannerText = bannerText.replace(thisReplacement['findtext'], thisReplacement['replacement']);
}
WScript.Echo(bannerText+"\n");
}
else {
WScript.Echo("ERROR: Cannot find banner file!\n");
}
WScript.Echo("Press Enter to Begin...");
InstallerInput();
WScript.Echo("");
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
var validResponse = false;
var validOpts = new Array();
while (!validResponse) {
for (y in thisQuestion.question) {
var qLine = thisQuestion.question[y];
WScript.Echo(qLine);
}
WScript.Echo('');
var choiceLine = '';
for (y in thisQuestion.options) {
choiceLine += thisQuestion.options[y] + ', ';
validOpts[thisQuestion.options[y]] = true;
}
choiceLine = choiceLine.substring(0, choiceLine.length - 2);
WScript.Echo("Available Options: "+choiceLine);
WScript.Echo("Default Answer: "+thisQuestion.default_answer+"\n");
WScript.Echo(thisQuestion.short);
var inputValue = InstallerInput().toLowerCase();
if (!inputValue) {
inputValue = thisQuestion.default_answer;
}
if (!validOpts[inputValue]) {
WScript.Echo("ERROR: Invalid option '"+inputValue+"'\n");
}
else if (thisQuestion.store_answer(inputValue)) {
validResponse = true;
}
}
WScript.Echo("");
}
if (!findCompiler()) {
WScript.Echo("\nERROR: No suitable build tools were found!");
WScript.Echo("Please ensure you have downloaded and installed a version of Visual C++ and/or PlatformSDK.\n");
WScript.Echo("For more information on the tools needed to build Anope on Windows, see:\nhttp://wiki.anope.org/index.php/Windows:1.8#Compiling\n");
}
else {
WScript.Echo("\nBuild tools were found successfully!\n");
WScript.Echo("\nAnope will be compiled with the following options:\n");
for (x in installerResponses) {
var thisResponse = installerResponses[x];
WScript.Echo("\t"+x+":\t\t["+thisResponse.toUpperCase()+"]");
}
for (x in softwareVersions) {
var thisVer = softwareVersions[x];
if (!thisVer) {
WScript.Echo("\t"+x+" Version:\t\tNot Enabled");
}
else {
WScript.Echo("\t"+x+" Version:\t\t"+thisVer.name);
}
}
WScript.Echo("\tAnope Version:\t\t\t"+anopeVersion);
WScript.Echo("\nTo continue, please press Enter...");
InstallerInput();
var f = fso.OpenTextFile("Makefile.inc.win32", 2);
f.WriteLine("#");
f.WriteLine("# Generated by install.js");
f.WriteLine("#");
if (typeof(softwareVersions['Compiler'].additional_switches) !== 'boolean') {
var switch_line = '';
for (x in softwareVersions['Compiler'].additional_switches) {
switch_line += softwareVersions['Compiler'].additional_switches[x]+" ";
}
f.WriteLine("VC6="+switch_line);
}
var path_line = '';
for (x in softwareVersions['Compiler'].libpaths) {
path_line += "/LIBPATH:\""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].libpaths[x]+"\" ";
}
f.WriteLine("LIBPATH="+path_line);
path_line = '';
var path_line_rc = '';
for (x in softwareVersions['Compiler'].incpaths) {
path_line += "/I \""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].incpaths[x]+"\" ";
path_line_rc += "/i \""+softwareVersions['Compiler'].installedDrive+":\\"+softwareVersions['Compiler'].incpaths[x]+"\" ";
}
f.WriteLine("INCFLAGS="+path_line);
f.WriteLine("VERSION="+anopeVersion);
f.WriteLine("PROGRAM=anope.exe");
f.WriteLine("DATDEST=data");
f.WriteLine("CC=cl");
f.WriteLine("RC=rc");
f.WriteLine("MAKE=nmake -f Makefile.win32");
f.WriteLine("BASE_CFLAGS=$(VC6) /O2 /MD $(INCFLAGS)");
f.WriteLine("RC_FLAGS="+path_line_rc);
f.WriteLine("LIBS=wsock32.lib advapi32.lib /NODEFAULTLIB:libcmtd.lib");
f.WriteLine("LFLAGS=$(LIBPATH)");
for (x in installerQuestions) {
var thisQuestion = installerQuestions[x];
thisQuestion.commit_config();
}
f.WriteLine("MORE_CFLAGS = /I\"../include\"");
f.WriteLine("CFLAGS = /nologo $(CDEFS) $(BASE_CFLAGS) $(MORE_CFLAGS)");
f.close();
generateRC();
WScript.Echo("\nConfiguration Complete!");
WScript.Echo("-----------------------\n");
WScript.Echo("Anope has been configured to your system. To compile, simply type:");
WScript.Echo("nmake -f Makefile.win32\n");
WScript.Echo("If you update Anope, you should run this script again to ensure\nall available options are set.\n");
}
// Fin.
// -----------------------------------------------------------------
// Functions
function FindAnopeVersion() {
if (!fso.FileExists('version.log')) {
anopeVersion = 'Unknown';
return;
}
var versionLog = fso.OpenTextFile("version.log");
while (!versionLog.atEndOfStream) {
var versionLine = versionLog.readline();
var thisMatch = versionLine.replace('\n', '');
while (thisMatch.match(/\"/g)) {
thisMatch = thisMatch.replace('"', '');
}
versionLine = thisMatch;
if (versionLine.match(/VERSION_MAJOR=/g)) {
vMaj = versionLine.replace('VERSION_MAJOR=', '');
continue;
}
if (versionLine.match(/VERSION_MINOR=/g)) {
vMin = versionLine.replace('VERSION_MINOR=', '');
continue;
}
if (versionLine.match(/VERSION_PATCH=/g)) {
vPat = versionLine.replace('VERSION_PATCH=', '');
continue;
}
if (versionLine.match(/VERSION_EXTRA=/g)) {
vExtra = versionLine.replace('VERSION_EXTRA=', '');
continue;
}
if (versionLine.match(/VERSION_BUILD=/g)) {
vBuild = versionLine.replace('VERSION_BUILD=', '');
continue;
}
}
versionLog.close();
anopeVersion = vMaj+"."+vMin+"."+vPat+"."+vBuild+vExtra;
return;
}
function InstallerInput() {
var input = WScript.StdIn.Readline();
return input;
}
function findMySQL() {
WScript.Echo("\nLooking for MySQL...\n");
var installedDrive = "";
for (x in mysqlVersions) {
var thisSQLVer = mysqlVersions[x];
WScript.Echo("Looking for: "+thisSQLVer.name+"...");
if (!(installedDrive = findFile("libmysql.lib", thisSQLVer.libpaths))) {
WScript.Echo("ERROR: Cannot find libmysql.lib - This version is probably not installed...\n");
continue;
}
if (!findFile("mysql.h", thisSQLVer.incpaths)) {
WScript.Echo("ERROR: Cannot find mysql.h - Half of this version of MySQL is installed (strange)...\n");
continue;
}
WScript.Echo("SUCCESS: "+thisSQLVer.name+" is installed, and is complete!\n");
thisSQLVer.installedDrive = installedDrive;
softwareVersions.MySQLDB = thisSQLVer;
return true;
}
return false;
}
function findCompiler() {
WScript.Echo("\nLooking for a suitable compiler...\n");
var noPSDK = false;
var installedDrive = "";
for (x in buildPackages) {
var thisPack = buildPackages[x];
WScript.Echo("Looking for: "+thisPack.name+"...");
if (!(installedDrive = findFile("MSVCRT.lib", thisPack.libpaths))) {
WScript.Echo("ERROR: Cannot find MSVCRT.lib - This version is probably not installed...\n");
continue;
}
if (!findFile("wsock32.lib", thisPack.libpaths)) {
WScript.Echo("ERROR: Cannot find wsock32.lib - Probably missing PlatformSDK...\n");
noPSDK = true;
continue;
}
if (!findFile("advapi32.lib", thisPack.libpaths)) {
WScript.Echo("ERROR: Cannot find advapi32.lib - Probably missing PlatformSDK...\n");
noPSDK = true;
continue;
}
if (!findFile("stdio.h", thisPack.incpaths)) {
WScript.Echo("ERROR: Cannot find stdio.h - Missing core header files...\n");
continue;
}
if (!findFile("windows.h", thisPack.incpaths)) {
WScript.Echo("ERROR: Cannot find windows.h - Probably missing PlatformSDK headers...\n");
noPSDK = true;
continue;
}
if (!findFile("nmake.exe", thisPack.nmake)) {
WScript.Echo("ERROR: Cannot find a copy of nmake.exe...\n");
WScript.Echo("In order to compile Anope, you need a working copy of nmake.exe on your system.");
WScript.Echo("A freely available copy can be downloaded from the url below.");
WScript.Echo("nmake.exe is also available in the PlatformSDK which can be freely downloaded from Microsoft.\n");
WScript.Echo("nmake.exe:\nhttp://download.microsoft.com/download/vc15/patch/1.52/w95/en-us/nmake15.exe\n");
break;
}
WScript.Echo("SUCCESS: "+thisPack.name+" was found, and is complete!");
thisPack.installedDrive = installedDrive;
softwareVersions.Compiler = thisPack;
return true;
}
if (noPSDK) {
WScript.Echo("Some of the build tools were detected on your computer, but the essential PlatformSDK components were missing.");
WScript.Echo("You will need to download the PlatformSDK from the URL below, ensuring that the Core Windows files, and Debugging Tools are installed.");
WScript.Echo("For more details on installing the PlatformSDK, visit http://wiki.anope.org/index.php/Windows:1.8#Compiling\n");
}
return false;
}
function findFile(fileName, arrayOfPaths) {
for (z in arrayOfPaths) {
var thisPath = arrayOfPaths[z];
for (y in drivesToCheck) {
var thisDrive = drivesToCheck[y];
if (fso.FileExists(thisDrive+":\\"+thisPath+"\\"+fileName)) {
return thisDrive;
}
}
}
return false;
}
function generateRC() {
var version_matches = [
{
'find' : /VERSION_COMMA/g,
'replacement' : vMaj+","+vMin+","+vPat+","+vBuild
},
{
'find' : /VERSION_FULL/g,
'replacement' : anopeVersion
},
{
'find' : /VERSION_DOTTED/g,
'replacement' : vMaj+"."+vMin+"."+vPat+"."+vBuild
}
];
var template = fso.OpenTextFile("src/win32.rc.template", 1);
var output = fso.OpenTextFile("src/win32.rc", 2, true);
if (!template) {
WScript.Echo("ERROR: Unable to generate win32.rc file - Couldn't open source file..");
}
if (!output) {
WScript.Echo("ERROR: Unable to generate win32.rc file - Couldn't open output file..");
}
var templateText = template.ReadAll();
template.close();
for (x in version_matches) {
var thisVerStr = version_matches[x];
while (templateText.match(thisVerStr.find)) {
templateText = templateText.replace(thisVerStr.find, thisVerStr.replacement);
}
}
output.WriteLine(templateText);
output.close();
}