-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.vbs
2340 lines (2003 loc) · 74.5 KB
/
configure.vbs
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
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
' $Id: configure.vbs $
'' @file
' The purpose of this script is to check for all external tools, headers, and
' libraries VBox OSE depends on.
'
' The script generates the build configuration file 'AutoConfig.kmk' and the
' environment setup script 'env.bat'. A log of what has been done is
' written to 'configure.log'.
'
'
' Copyright (C) 2006-2012 Oracle Corporation
'
' This file is part of VirtualBox Open Source Edition (OSE), as
' available from http://www.virtualbox.org. This file is free software;
' you can redistribute it and/or modify it under the terms of the GNU
' General Public License (GPL) as published by the Free Software
' Foundation, in version 2 as it comes in the "COPYING" file of the
' VirtualBox OSE distribution. VirtualBox OSE is distributed in the
' hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
'
'*****************************************************************************
'* Global Variables *
'*****************************************************************************
dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile, g_strShellOutput
g_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs"))
g_strEnvFile = g_strPath & "\env.bat"
g_strCfgFile = g_strPath & "\AutoConfig.kmk"
g_strLogFile = g_strPath & "\configure.log"
'g_strTmpFile = g_strPath & "\configure.tmp"
dim g_objShell, g_objFileSys
Set g_objShell = WScript.CreateObject("WScript.Shell")
Set g_objFileSys = WScript.CreateObject("Scripting.FileSystemObject")
dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev, g_strPathVCC, g_strPathPSDK, g_strVerPSDK, g_strPathDDK, g_strSubOutput
g_strPathkBuild = ""
g_strPathDev = ""
g_strPathVCC = ""
g_strPathPSDK = ""
g_strPathDDK = ""
dim g_strTargetArch
g_strTargetArch = "x86"
dim g_blnDisableCOM, g_strDisableCOM
g_blnDisableCOM = False
g_strDisableCOM = ""
' The internal mode is primarily for skipping some large libraries.
dim g_blnInternalMode
g_blnInternalMode = False
' Whether to try the internal stuff first or last.
dim g_blnInternalFirst
g_blnInternalFirst = True
''
' Converts to unix slashes
function UnixSlashes(str)
UnixSlashes = replace(str, "\", "/")
end function
''
' Converts to dos slashes
function DosSlashes(str)
DosSlashes = replace(str, "/", "\")
end function
''
' Read a file (typically the tmp file) into a string.
function FileToString(strFilename)
const ForReading = 1, TristateFalse = 0
dim objLogFile, str
set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForReading, False, TristateFalse)
str = objFile.ReadAll()
objFile.Close()
FileToString = str
end function
''
' Deletes a file
sub FileDelete(strFilename)
if g_objFileSys.FileExists(DosSlashes(strFilename)) then
g_objFileSys.DeleteFile(DosSlashes(strFilename))
end if
end sub
''
' Appends a line to an ascii file.
sub FileAppendLine(strFilename, str)
const ForAppending = 8, TristateFalse = 0
dim objFile
set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForAppending, True, TristateFalse)
objFile.WriteLine(str)
objFile.Close()
end sub
''
' Checks if the file exists.
function FileExists(strFilename)
FileExists = g_objFileSys.FileExists(DosSlashes(strFilename))
end function
''
' Checks if the directory exists.
function DirExists(strDirectory)
DirExists = g_objFileSys.FolderExists(DosSlashes(strDirectory))
end function
''
' Checks if this is a WOW64 process.
function IsWow64()
if g_objShell.Environment("PROCESS")("PROCESSOR_ARCHITEW6432") <> "" then
IsWow64 = 1
else
IsWow64 = 0
end if
end function
''
' Returns a reverse sorted array (strings).
function ArraySortStrings(arrStrings)
for i = LBound(arrStrings) to UBound(arrStrings)
str1 = arrStrings(i)
for j = i + 1 to UBound(arrStrings)
str2 = arrStrings(j)
if StrComp(str2, str1) < 0 then
arrStrings(j) = str1
str1 = str2
end if
next
arrStrings(i) = str1
next
ArraySortStrings = arrStrings
end function
''
' Prints a string array.
sub ArrayPrintStrings(arrStrings, strPrefix)
for i = LBound(arrStrings) to UBound(arrStrings)
Print strPrefix & "arrStrings(" & i & ") = '" & arrStrings(i) & "'"
next
end sub
''
' Returns a reverse sorted array (strings).
function ArrayRSortStrings(arrStrings)
' Sort it.
arrStrings = ArraySortStrings(arrStrings)
' Reverse the array.
cnt = UBound(arrStrings) - LBound(arrStrings) + 1
if cnt > 0 then
j = UBound(arrStrings)
iHalf = Fix(LBound(arrStrings) + cnt / 2)
for i = LBound(arrStrings) to iHalf - 1
strTmp = arrStrings(i)
arrStrings(i) = arrStrings(j)
arrStrings(j) = strTmp
j = j - 1
next
end if
ArrayRSortStrings = arrStrings
end function
''
' Returns the input array with the string appended.
' Note! There must be some better way of doing this...
function ArrayAppend(arr, str)
dim i, cnt
cnt = UBound(arr) - LBound(arr) + 1
redim arrRet(cnt)
for i = LBound(arr) to UBound(arr)
arrRet(i) = arr(i)
next
arrRet(UBound(arr) + 1) = str
ArrayAppend = arrRet
end function
''
' Translates a register root name to a value
function RegTransRoot(strRoot)
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
select case strRoot
case "HKLM"
RegTransRoot = HKEY_LOCAL_MACHINE
case "HKCU"
RegTransRoot = HKEY_CURRENT_USER
case else
MsgFatal "RegTransRoot: Unknown root: '" & strRoot & "'"
RegTransRoot = 0
end select
end function
'' The registry globals
dim g_objReg, g_objRegCtx
dim g_blnRegistry
g_blnRegistry = false
''
' Init the register provider globals.
function RegInit()
RegInit = false
On Error Resume Next
if g_blnRegistry = false then
set g_objRegCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
' Comment out the following for lines if the cause trouble on your windows version.
if IsWow64() then
g_objRegCtx.Add "__ProviderArchitecture", 64
g_objRegCtx.Add "__RequiredArchitecture", true
end if
set objLocator = CreateObject("Wbemscripting.SWbemLocator")
set objServices = objLocator.ConnectServer("", "root\default", "", "", , , , g_objRegCtx)
set g_objReg = objServices.Get("StdRegProv")
g_blnRegistry = true
end if
RegInit = true
end function
''
' Gets a value from the registry. Returns "" if string wasn't found / valid.
function RegGetString(strName)
RegGetString = ""
if RegInit() then
dim strRoot, strKey, strValue
dim iRoot
' split up into root, key and value parts.
strRoot = left(strName, instr(strName, "\") - 1)
strKey = mid(strName, instr(strName, "\") + 1, instrrev(strName, "\") - instr(strName, "\"))
strValue = mid(strName, instrrev(strName, "\") + 1)
' Must use ExecMethod to call the GetStringValue method because of the context.
Set InParms = g_objReg.Methods_("GetStringValue").Inparameters
InParms.hDefKey = RegTransRoot(strRoot)
InParms.sSubKeyName = strKey
InParms.sValueName = strValue
On Error Resume Next
set OutParms = g_objReg.ExecMethod_("GetStringValue", InParms, , g_objRegCtx)
if OutParms.ReturnValue = 0 then
RegGetString = OutParms.sValue
end if
else
' fallback mode
On Error Resume Next
RegGetString = g_objShell.RegRead(strName)
end if
end function
''
' Returns an array of subkey strings.
function RegEnumSubKeys(strRoot, strKeyPath)
dim iRoot
iRoot = RegTransRoot(strRoot)
RegEnumSubKeys = Array()
if RegInit() then
' Must use ExecMethod to call the EnumKey method because of the context.
Set InParms = g_objReg.Methods_("EnumKey").Inparameters
InParms.hDefKey = RegTransRoot(strRoot)
InParms.sSubKeyName = strKeyPath
On Error Resume Next
set OutParms = g_objReg.ExecMethod_("EnumKey", InParms, , g_objRegCtx)
if OutParms.ReturnValue = 0 then
RegEnumSubKeys = OutParms.sNames
end if
else
' fallback mode
dim objReg, rc, arrSubKeys
set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
On Error Resume Next
rc = objReg.EnumKey(iRoot, strKeyPath, arrSubKeys)
if rc = 0 then
RegEnumSubKeys = arrSubKeys
end if
end if
end function
''
' Returns an array of full path subkey strings.
function RegEnumSubKeysFull(strRoot, strKeyPath)
dim arrTmp
arrTmp = RegEnumSubKeys(strRoot, strKeyPath)
for i = LBound(arrTmp) to UBound(arrTmp)
arrTmp(i) = strKeyPath & "\" & arrTmp(i)
next
RegEnumSubKeysFull = arrTmp
end function
''
' Returns an rsorted array of subkey strings.
function RegEnumSubKeysRSort(strRoot, strKeyPath)
RegEnumSubKeysRSort = ArrayRSortStrings(RegEnumSubKeys(strRoot, strKeyPath))
end function
''
' Returns an rsorted array of subkey strings.
function RegEnumSubKeysFullRSort(strRoot, strKeyPath)
RegEnumSubKeysFullRSort = ArrayRSortStrings(RegEnumSubKeysFull(strRoot, strKeyPath))
end function
''
' Gets the commandline used to invoke the script.
function GetCommandline()
dim str, i
'' @todo find an api for querying it instead of reconstructing it like this...
GetCommandline = "cscript configure.vbs"
for i = 1 to WScript.Arguments.Count
str = WScript.Arguments.Item(i - 1)
if str = "" then
str = """"""
elseif (InStr(1, str, " ")) then
str = """" & str & """"
end if
GetCommandline = GetCommandline & " " & str
next
end function
''
' Gets an environment variable.
function EnvGet(strName)
EnvGet = g_objShell.Environment("PROCESS")(strName)
end function
''
' Sets an environment variable.
sub EnvSet(strName, strValue)
g_objShell.Environment("PROCESS")(strName) = strValue
LogPrint "EnvSet: " & strName & "=" & strValue
end sub
''
' Appends a string to an environment variable
sub EnvAppend(strName, strValue)
dim str
str = g_objShell.Environment("PROCESS")(strName)
g_objShell.Environment("PROCESS")(strName) = str & strValue
LogPrint "EnvAppend: " & strName & "=" & str & strValue
end sub
''
' Prepends a string to an environment variable
sub EnvPrepend(strName, strValue)
dim str
str = g_objShell.Environment("PROCESS")(strName)
g_objShell.Environment("PROCESS")(strName) = strValue & str
LogPrint "EnvPrepend: " & strName & "=" & strValue & str
end sub
''
' Gets the first non-empty environment variable of the given two.
function EnvGetFirst(strName1, strName2)
EnvGetFirst = g_objShell.Environment("PROCESS")(strName1)
if EnvGetFirst = "" then
EnvGetFirst = g_objShell.Environment("PROCESS")(strName2)
end if
end function
''
' Get the path of the parent directory. Returns root if root was specified.
' Expects abs path.
function PathParent(str)
PathParent = g_objFileSys.GetParentFolderName(DosSlashes(str))
end function
''
' Strips the filename from at path.
function PathStripFilename(str)
PathStripFilename = g_objFileSys.GetParentFolderName(DosSlashes(str))
end function
''
' Get the abs path, use the short version if necessary.
function PathAbs(str)
strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))
strParent = g_objFileSys.GetParentFolderName(strAbs)
if strParent = "" then
PathAbs = strAbs
else
strParent = PathAbs(strParent) ' Recurse to resolve parent paths.
PathAbs = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))
dim obj
set obj = Nothing
if FileExists(PathAbs) then
set obj = g_objFileSys.GetFile(PathAbs)
elseif DirExists(PathAbs) then
set obj = g_objFileSys.GetFolder(PathAbs)
end if
if not (obj is nothing) then
for each objSub in obj.ParentFolder.SubFolders
if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then
if InStr(1, objSub.Name, " ") > 0 _
Or InStr(1, objSub.Name, "&") > 0 _
Or InStr(1, objSub.Name, "$") > 0 _
then
PathAbs = g_objFileSys.BuildPath(strParent, objSub.ShortName)
if InStr(1, PathAbs, " ") > 0 _
Or InStr(1, PathAbs, "&") > 0 _
Or InStr(1, PathAbs, "$") > 0 _
then
MsgFatal "PathAbs(" & str & ") attempted to return filename with problematic " _
& "characters in it (" & PathAbs & "). The tool/sdk referenced will probably " _
& "need to be copied or reinstalled to a location without 'spaces', '$', ';' " _
& "or '&' in the path name. (Unless it's a problem with this script of course...)"
end if
else
PathAbs = g_objFileSys.BuildPath(strParent, objSub.Name)
end if
exit for
end if
next
end if
end if
end function
''
' Get the abs path, use the long version.
function PathAbsLong(str)
strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))
strParent = g_objFileSys.GetParentFolderName(strAbs)
if strParent = "" then
PathAbsLong = strAbs
else
strParent = PathAbsLong(strParent) ' Recurse to resolve parent paths.
PathAbsLong = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))
dim obj
set obj = Nothing
if FileExists(PathAbsLong) then
set obj = g_objFileSys.GetFile(PathAbsLong)
elseif DirExists(PathAbsLong) then
set obj = g_objFileSys.GetFolder(PathAbsLong)
end if
if not (obj is nothing) then
for each objSub in obj.ParentFolder.SubFolders
if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then
PathAbsLong = g_objFileSys.BuildPath(strParent, objSub.Name)
exit for
end if
next
end if
end if
end function
''
' Executes a command in the shell catching output in g_strShellOutput
function Shell(strCommand, blnBoth)
dim strShell, strCmdline, objExec, str
strShell = g_objShell.ExpandEnvironmentStrings("%ComSpec%")
if blnBoth = true then
strCmdline = strShell & " /c " & strCommand & " 2>&1"
else
strCmdline = strShell & " /c " & strCommand & " 2>nul"
end if
LogPrint "# Shell: " & strCmdline
Set objExec = g_objShell.Exec(strCmdLine)
g_strShellOutput = objExec.StdOut.ReadAll()
objExec.StdErr.ReadAll()
do while objExec.Status = 0
Wscript.Sleep 20
g_strShellOutput = g_strShellOutput & objExec.StdOut.ReadAll()
objExec.StdErr.ReadAll()
loop
LogPrint "# Status: " & objExec.ExitCode
LogPrint "# Start of Output"
LogPrint g_strShellOutput
LogPrint "# End of Output"
Shell = objExec.ExitCode
end function
''
' Try find the specified file in the path.
function Which(strFile)
dim strPath, iStart, iEnd, str
' the path
strPath = EnvGet("Path")
iStart = 1
do while iStart <= Len(strPath)
iEnd = InStr(iStart, strPath, ";")
if iEnd <= 0 then iEnd = Len(strPath) + 1
if iEnd > iStart then
str = Mid(strPath, iStart, iEnd - iStart) & "/" & strFile
if FileExists(str) then
Which = str
exit function
end if
end if
iStart = iEnd + 1
loop
' registry or somewhere?
Which = ""
end function
''
' Append text to the log file and echo it to stdout
sub Print(str)
LogPrint str
Wscript.Echo str
end sub
''
' Prints a test header
sub PrintHdr(strTest)
LogPrint "***** Checking for " & strTest & " *****"
Wscript.Echo "Checking for " & StrTest & "..."
end sub
''
' Prints a success message
sub PrintResultMsg(strTest, strResult)
LogPrint "** " & strTest & ": " & strResult
Wscript.Echo " Found "& strTest & ": " & strResult
end sub
''
' Prints a successfully detected path
sub PrintResult(strTest, strPath)
strLongPath = PathAbsLong(strPath)
if PathAbs(strPath) <> strLongPath then
LogPrint "** " & strTest & ": " & strPath & " (" & UnixSlashes(strLongPath) & ")"
Wscript.Echo " Found " & strTest & ": " & strPath & " (" & UnixSlashes(strLongPath) & ")"
else
LogPrint "** " & strTest & ": " & strPath
Wscript.Echo " Found " & strTest & ": " & strPath
end if
end sub
''
' Warning message.
sub MsgWarning(strMsg)
Print "warning: " & strMsg
end sub
''
' Fatal error.
sub MsgFatal(strMsg)
Print "fatal error: " & strMsg
Wscript.Quit
end sub
''
' Error message, fatal unless flag to ignore errors is given.
sub MsgError(strMsg)
Print "error: " & strMsg
if g_blnInternalMode = False then
Wscript.Quit
end if
end sub
''
' Write a log header with some basic info.
sub LogInit
FileDelete g_strLogFile
LogPrint "# Log file generated by " & Wscript.ScriptFullName
for i = 1 to WScript.Arguments.Count
LogPrint "# Arg #" & i & ": " & WScript.Arguments.Item(i - 1)
next
if Wscript.Arguments.Count = 0 then
LogPrint "# No arguments given"
end if
LogPrint "# Reconstructed command line: " & GetCommandline()
' some Wscript stuff
LogPrint "# Wscript properties:"
LogPrint "# ScriptName: " & Wscript.ScriptName
LogPrint "# Version: " & Wscript.Version
LogPrint "# Build: " & Wscript.BuildVersion
LogPrint "# Name: " & Wscript.Name
LogPrint "# Full Name: " & Wscript.FullName
LogPrint "# Path: " & Wscript.Path
LogPrint "#"
' the environment
LogPrint "# Environment:"
dim objEnv
for each strVar in g_objShell.Environment("PROCESS")
LogPrint "# " & strVar
next
LogPrint "#"
end sub
''
' Append text to the log file.
sub LogPrint(str)
FileAppendLine g_strLogFile, str
'Wscript.Echo "dbg: " & str
end sub
''
' Checks if the file exists and logs failures.
function LogFileExists(strPath, strFilename)
LogFileExists = FileExists(strPath & "/" & strFilename)
if LogFileExists = False then
LogPrint "Testing '" & strPath & "': " & strFilename & " not found"
end if
end function
''
' Finds the first file matching the pattern.
' If no file is found, log the failure.
function LogFindFile(strPath, strPattern)
dim str
'
' Yes, there are some facy database kinda interface to the filesystem
' however, breaking down the path and constructing a usable query is
' too much hassle. So, we'll do it the unix way...
'
if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _
And InStr(1, g_strShellOutput, Chr(13)) > 1 _
then
' return the first word.
LogFindFile = Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)
else
LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
LogFindFile = ""
end if
end function
''
' Finds the first directory matching the pattern.
' If no directory is found, log the failure,
' else return the complete path to the found directory.
function LogFindDir(strPath, strPattern)
dim str
'
' Yes, there are some facy database kinda interface to the filesystem
' however, breaking down the path and constructing a usable query is
' too much hassle. So, we'll do it the unix way...
'
' List the alphabetically last names as first entries (with /O-N).
if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _
And InStr(1, g_strShellOutput, Chr(13)) > 1 _
then
' return the first word.
LogFindDir = strPath & "/" & Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)
else
LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
LogFindDir = ""
end if
end function
''
' Initializes the config file.
sub CfgInit
FileDelete g_strCfgFile
CfgPrint "# -*- Makefile -*-"
CfgPrint "#"
CfgPrint "# Build configuration generated by " & GetCommandline()
CfgPrint "#"
if g_blnInternalMode = False then
CfgPrint "VBOX_OSE := 1"
end if
end sub
''
' Prints a string to the config file.
sub CfgPrint(str)
FileAppendLine g_strCfgFile, str
end sub
''
' Initializes the environment batch script.
sub EnvInit
FileDelete g_strEnvFile
EnvPrint "@echo off"
EnvPrint "rem"
EnvPrint "rem Environment setup script generated by " & GetCommandline()
EnvPrint "rem"
end sub
''
' Prints a string to the environment batch script.
sub EnvPrint(str)
FileAppendLine g_strEnvFile, str
end sub
''
' No COM
sub DisableCOM(strReason)
if g_blnDisableCOM = False then
LogPrint "Disabled COM components: " & strReason
g_blnDisableCOM = True
g_strDisableCOM = strReason
CfgPrint "VBOX_WITH_MAIN="
CfgPrint "VBOX_WITH_QTGUI="
CfgPrint "VBOX_WITH_VBOXSDL="
CfgPrint "VBOX_WITH_DEBUGGER_GUI="
CfgPrint "VBOX_WITHOUT_COM=1"
end if
end sub
''
' No UDPTunnel
sub DisableUDPTunnel(strReason)
if g_blnDisableUDPTunnel = False then
LogPrint "Disabled UDPTunnel network transport: " & strReason
g_blnDisableUDPTunnel = True
g_strDisableUDPTunnel = strReason
CfgPrint "VBOX_WITH_UDPTUNNEL="
end if
end sub
''
' Checks the the path doesn't contain characters the tools cannot deal with.
sub CheckSourcePath
dim sPwd
sPwd = PathAbs(g_strPath)
if InStr(1, sPwd, " ") > 0 then
MsgError "Source path contains spaces! Please move it. (" & sPwd & ")"
end if
if InStr(1, sPwd, "$") > 0 then
MsgError "Source path contains the '$' char! Please move it. (" & sPwd & ")"
end if
if InStr(1, sPwd, "%") > 0 then
MsgError "Source path contains the '%' char! Please move it. (" & sPwd & ")"
end if
if InStr(1, sPwd, Chr(10)) > 0 _
Or InStr(1, sPwd, Chr(13)) > 0 _
Or InStr(1, sPwd, Chr(9)) > 0 _
then
MsgError "Source path contains control characters! Please move it. (" & sPwd & ")"
end if
Print "Source path: OK"
end sub
''
' Checks for kBuild - very simple :)
sub CheckForkBuild(strOptkBuild)
PrintHdr "kBuild"
'
' Check if there is a 'kmk' in the path somewhere without
' any KBUILD_*PATH stuff around.
'
blnNeedEnvVars = True
g_strPathkBuild = strOptkBuild
g_strPathkBuildBin = ""
if (g_strPathkBuild = "") _
And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _
And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _
And (Shell("kmk.exe --version", True) = 0) _
And (InStr(1,g_strShellOutput, "kBuild Make 0.1") > 0) _
And (InStr(1,g_strShellOutput, "KBUILD_PATH") > 0) _
And (InStr(1,g_strShellOutput, "KBUILD_BIN_PATH") > 0) then
'' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.
'blnNeedEnvVars = False
MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _
& "deal with that yet and will use the one it ships with. Sorry."
end if
'
' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.
'
if g_strPathkBuild = "" then
g_strPathkBuild = EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")
if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then
MsgWarning "Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild & ")"
g_strPathkBuild = ""
end if
if g_strPathkBuild = "" then
g_strPathkBuild = g_strPath & "/kBuild"
end if
end if
g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))
'
' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).
'
str = EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")
if (str <> "") _
And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then
EnvPrint "set KBUILD_TYPE=release"
EnvSet "KBUILD_TYPE", "release"
MsgWarning "Found unknown KBUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."
end if
str = EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")
if (str <> "") _
And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
EnvPrint "set KBUILD_TARGET=win"
EnvSet "KBUILD_TARGET", "win"
MsgWarning "Found unknown KBUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."
end if
str = EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")
if (str <> "") _
And (InStr(1, "x86|amd64", str) <= 0) then
EnvPrint "set KBUILD_TARGET_ARCH=x86"
EnvSet "KBUILD_TARGET_ARCH", "x86"
MsgWarning "Found unknown KBUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
str = "x86"
end if
if str <> "" then
g_strTargetArch = str
elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
g_strTargetArch = "amd64"
else
g_strTargetArch = "x86"
end if
str = EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")
' perhaps a bit pedantic this since this isn't clearly define nor used much...
if (str <> "") _
And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
EnvPrint "set BUILD_TARGET_CPU=i386"
EnvSet "KBUILD_TARGET_CPU", "i386"
MsgWarning "Found unknown KBUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."
end if
str = EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")
if (str <> "") _
And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
EnvPrint "set KBUILD_HOST=win"
EnvSet "KBUILD_HOST", "win"
MsgWarning "Found unknown KBUILD_HOST value '" & str &"' in your environment. Setting it to 'win32'."
end if
str = EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")
if (str <> "") _
And (InStr(1, "x86|amd64", str) <= 0) then
EnvPrint "set KBUILD_HOST_ARCH=x86"
EnvSet "KBUILD_HOST_ARCH", "x86"
MsgWarning "Found unknown KBUILD_HOST_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
end if
str = EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")
' perhaps a bit pedantic this since this isn't clearly define nor used much...
if (str <> "") _
And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
EnvPrint "set KBUILD_HOST_CPU=i386"
EnvSet "KBUILD_HOST_CPU", "i386"
MsgWarning "Found unknown KBUILD_HOST_CPU value '" & str &"' in your environment. Setting it to 'i386'."
end if
'
' Determin the location of the kBuild binaries.
'
if g_strPathkBuildBin = "" then
g_strPathkBuildBin = g_strPathkBuild & "/bin/win." & g_strTargetArch
if FileExists(g_strPathkBuild & "/kmk.exe") = False then
g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
end if
end if
'
' Perform basic validations of the kBuild installation.
'
if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _
Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _
Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then
MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _
& "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
exit sub
end if
if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _
Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then
MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _
& "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
exit sub
end if
if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True) <> 0) Then
MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."
exit sub
end if
'
' If PATH_DEV is set, check that it's pointing to something useful.
'
str = EnvGet("PATH_DEV")
g_strPathDev = str
if (str <> "") _
And False then '' @todo add some proper tests here.
strNew = UnixSlashes(g_strPath & "/tools")
EnvPrint "set PATH_DEV=" & strNew
EnvSet "PATH_DEV", strNew
MsgWarning "Found PATH_DEV='" & str &"' in your environment. Setting it to '" & strNew & "'."
g_strPathDev = strNew
end if
if g_strPathDev = "" then g_strPathDev = UnixSlashes(g_strPath & "/tools")
'
' Write KBUILD_PATH to the environment script if necessary.
'
if blnNeedEnvVars = True then
EnvPrint "set KBUILD_PATH=" & g_strPathkBuild
EnvSet "KBUILD_PATH", g_strPathkBuild
EnvPrint "set PATH=" & g_strPathkBuildBin & ";%PATH%"
EnvPrepend "PATH", g_strPathkBuildBin & ";"
end if
PrintResult "kBuild", g_strPathkBuild
PrintResult "kBuild binaries", g_strPathkBuildBin
end sub
''
' Checks for Visual C++ version 10 (2010).
sub CheckForVisualCPP(strOptVC, strOptVCCommon, blnOptVCExpressEdition)
dim strPathVC, strPathVCCommon, str, str2, blnNeedMsPDB
PrintHdr "Visual C++"
'
' Try find it...
'
strPathVC = ""
strPathVCCommon = ""
if (strPathVC = "") And (strOptVC <> "") then
if CheckForVisualCPPSub(strOptVC, strOptVCCommon, blnOptVCExpressEdition) then
strPathVC = strOptVC
strPathVCCommon = strOptVCCommon
end if
end if
if (strPathVC = "") And (g_blnInternalFirst = True) Then
strPathVC = g_strPathDev & "/win.x86/vcc/v10sp1"
if CheckForVisualCPPSub(strPathVC, "", blnOptVCExpressEdition) = False then
strPathVC = ""
end if
end if