Changeset 85809 in vbox
- Timestamp:
- Aug 18, 2020 8:56:54 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.vbs
r85807 r85809 22 22 23 23 24 '***************************************************************************** 25 '* Global Variables * 26 '***************************************************************************** 27 dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile, g_strShellOutput 24 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 25 ' Header Files 26 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 27 28 '' 29 ' Includes a vbscript file relative to the script. 30 sub IncludeFile(strFilename) 31 dim objFile, objFileSys 32 set objFileSys = WScript.CreateObject("Scripting.FileSystemObject") 33 dim strPath : strPath = objFileSys.BuildPath(objFileSys.GetParentFolderName(Wscript.ScriptFullName), strFilename) 34 set objFile = objFileSys.openTextFile(strPath) 35 executeglobal objFile.readAll() 36 objFile.close 37 set objFileSys = nothing 38 end sub 39 40 IncludeFile "tools\win\vbscript\helpers.vbs" 41 42 43 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 44 ' Global Variables ' 45 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 46 dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile 28 47 g_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs")) 29 48 g_strEnvFile = g_strPath & "\env.bat" … … 32 51 'g_strTmpFile = g_strPath & "\configure.tmp" 33 52 34 dim g_objShell, g_objFileSys35 Set g_objShell = WScript.CreateObject("WScript.Shell")36 Set g_objFileSys = WScript.CreateObject("Scripting.FileSystemObject")37 53 38 54 ' kBuild stuff. … … 87 103 end if 88 104 89 90 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''91 ' Helpers: Paths '92 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''93 94 ''95 ' Converts to unix slashes96 function UnixSlashes(str)97 UnixSlashes = replace(str, "\", "/")98 end function99 100 101 ''102 ' Converts to dos slashes103 function DosSlashes(str)104 DosSlashes = replace(str, "/", "\")105 end function106 107 108 ''109 ' Get the path of the parent directory. Returns root if root was specified.110 ' Expects abs path.111 function PathParent(str)112 PathParent = g_objFileSys.GetParentFolderName(DosSlashes(str))113 end function114 115 116 ''117 ' Strips the filename from at path.118 function PathStripFilename(str)119 PathStripFilename = g_objFileSys.GetParentFolderName(DosSlashes(str))120 end function121 122 123 ''124 ' Get the abs path, use the short version if necessary.125 function PathAbs(str)126 strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))127 strParent = g_objFileSys.GetParentFolderName(strAbs)128 if strParent = "" then129 PathAbs = strAbs130 else131 strParent = PathAbs(strParent) ' Recurse to resolve parent paths.132 PathAbs = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))133 134 dim obj135 set obj = Nothing136 if FileExists(PathAbs) then137 set obj = g_objFileSys.GetFile(PathAbs)138 elseif DirExists(PathAbs) then139 set obj = g_objFileSys.GetFolder(PathAbs)140 end if141 142 if not (obj is nothing) then143 for each objSub in obj.ParentFolder.SubFolders144 if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then145 if InStr(1, objSub.Name, " ") > 0 _146 Or InStr(1, objSub.Name, "&") > 0 _147 Or InStr(1, objSub.Name, "$") > 0 _148 then149 PathAbs = g_objFileSys.BuildPath(strParent, objSub.ShortName)150 if InStr(1, PathAbs, " ") > 0 _151 Or InStr(1, PathAbs, "&") > 0 _152 Or InStr(1, PathAbs, "$") > 0 _153 then154 MsgFatal "PathAbs(" & str & ") attempted to return filename with problematic " _155 & "characters in it (" & PathAbs & "). The tool/sdk referenced will probably " _156 & "need to be copied or reinstalled to a location without 'spaces', '$', ';' " _157 & "or '&' in the path name. (Unless it's a problem with this script of course...)"158 end if159 else160 PathAbs = g_objFileSys.BuildPath(strParent, objSub.Name)161 end if162 exit for163 end if164 next165 end if166 end if167 end function168 169 170 ''171 ' Get the abs path, use the long version.172 function PathAbsLong(str)173 strAbs = g_objFileSys.GetAbsolutePathName(DosSlashes(str))174 strParent = g_objFileSys.GetParentFolderName(strAbs)175 if strParent = "" then176 PathAbsLong = strAbs177 else178 strParent = PathAbsLong(strParent) ' Recurse to resolve parent paths.179 PathAbsLong = g_objFileSys.BuildPath(strParent, g_objFileSys.GetFileName(strAbs))180 181 dim obj182 set obj = Nothing183 if FileExists(PathAbsLong) then184 set obj = g_objFileSys.GetFile(PathAbsLong)185 elseif DirExists(PathAbsLong) then186 set obj = g_objFileSys.GetFolder(PathAbsLong)187 end if188 189 if not (obj is nothing) then190 for each objSub in obj.ParentFolder.SubFolders191 if obj.Name = objSub.Name or obj.ShortName = objSub.ShortName then192 PathAbsLong = g_objFileSys.BuildPath(strParent, objSub.Name)193 exit for194 end if195 next196 end if197 end if198 end function199 200 201 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''202 ' Helpers: Files and Dirs '203 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''204 205 ''206 ' Read a file (typically the tmp file) into a string.207 function FileToString(strFilename)208 const ForReading = 1, TristateFalse = 0209 dim objLogFile, str210 211 set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForReading, False, TristateFalse)212 str = objFile.ReadAll()213 objFile.Close()214 215 FileToString = str216 end function217 218 219 ''220 ' Deletes a file221 sub FileDelete(strFilename)222 if g_objFileSys.FileExists(DosSlashes(strFilename)) then223 g_objFileSys.DeleteFile(DosSlashes(strFilename))224 end if225 end sub226 227 228 ''229 ' Appends a line to an ascii file.230 sub FileAppendLine(strFilename, str)231 const ForAppending = 8, TristateFalse = 0232 dim objFile233 234 set objFile = g_objFileSys.OpenTextFile(DosSlashes(strFilename), ForAppending, True, TristateFalse)235 objFile.WriteLine(str)236 objFile.Close()237 end sub238 239 240 ''241 ' Checks if the file exists.242 function FileExists(strFilename)243 FileExists = g_objFileSys.FileExists(DosSlashes(strFilename))244 end function245 246 247 ''248 ' Checks if the directory exists.249 function DirExists(strDirectory)250 DirExists = g_objFileSys.FolderExists(DosSlashes(strDirectory))251 end function252 253 254 ''255 ' Returns true if there are subfolders starting with the given string.256 function HasSubdirsStartingWith(strFolder, strStartingWith)257 HasSubdirsStartingWith = False258 if DirExists(strFolder) then259 dim obj260 set obj = g_objFileSys.GetFolder(strFolder)261 for each objSub in obj.SubFolders262 if StrComp(Left(objSub.Name, Len(strStartingWith)), strStartingWith) = 0 then263 HasSubdirsStartingWith = True264 LogPrint "# HasSubdirsStartingWith(" & strFolder & "," & strStartingWith & ") found " & objSub.Name265 exit for266 end if267 next268 end if269 end function270 271 272 ''273 ' Returns a sorted array of subfolder names that starts with the given string.274 function GetSubdirsStartingWith(strFolder, strStartingWith)275 if DirExists(strFolder) then276 dim obj, i277 set obj = g_objFileSys.GetFolder(strFolder)278 i = 0279 for each objSub in obj.SubFolders280 if StrComp(Left(objSub.Name, Len(strStartingWith)), strStartingWith) = 0 then281 i = i + 1282 end if283 next284 if i > 0 then285 redim arrResult(i - 1)286 i = 0287 for each objSub in obj.SubFolders288 if StrComp(Left(objSub.Name, Len(strStartingWith)), strStartingWith) = 0 then289 arrResult(i) = objSub.Name290 i = i + 1291 end if292 next293 GetSubdirsStartingWith = arrResult294 else295 GetSubdirsStartingWith = Array()296 end if297 else298 GetSubdirsStartingWith = Array()299 end if300 end function301 302 303 ''304 ' Returns a sorted array of subfolder names that starts with the given string.305 function GetSubdirsStartingWithVerSorted(strFolder, strStartingWith)306 GetSubdirsStartingWithVerSorted = ArrayVerSortStrings(GetSubdirsStartingWith(strFolder, strStartingWith))307 end function308 309 310 ''311 ' Returns a reverse version sorted array of subfolder names that starts with the given string.312 function GetSubdirsStartingWithRVerSorted(strFolder, strStartingWith)313 GetSubdirsStartingWithRSortedVersion = ArrayRVerSortStrings(GetSubdirsStartingWith(strFolder, strStartingWith))314 end function315 316 317 ''318 ' Try find the specified file in the specified path variable.319 function WhichEx(strEnvVar, strFile)320 dim strPath, iStart, iEnd, str321 322 ' the path323 strPath = EnvGet(strEnvVar)324 iStart = 1325 do while iStart <= Len(strPath)326 iEnd = InStr(iStart, strPath, ";")327 if iEnd <= 0 then iEnd = Len(strPath) + 1328 if iEnd > iStart then329 str = Mid(strPath, iStart, iEnd - iStart) & "/" & strFile330 if FileExists(str) then331 WhichEx = str332 exit function333 end if334 end if335 iStart = iEnd + 1336 loop337 338 ' registry or somewhere?339 340 WhichEx = ""341 end function342 343 344 ''345 ' Try find the specified file in the path.346 function Which(strFile)347 Which = WhichEx("Path", strFile)348 end function349 350 351 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''352 ' Helpers: Processes '353 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''354 355 ''356 ' Checks if this is a WOW64 process.357 function IsWow64()358 if g_objShell.Environment("PROCESS")("PROCESSOR_ARCHITEW6432") <> "" then359 IsWow64 = 1360 else361 IsWow64 = 0362 end if363 end function364 365 366 ''367 ' Executes a command in the shell catching output in g_strShellOutput368 function Shell(strCommand, blnBoth)369 dim strShell, strCmdline, objExec, str370 371 strShell = g_objShell.ExpandEnvironmentStrings("%ComSpec%")372 if blnBoth = true then373 strCmdline = strShell & " /c " & strCommand & " 2>&1"374 else375 strCmdline = strShell & " /c " & strCommand & " 2>nul"376 end if377 378 LogPrint "# Shell: " & strCmdline379 Set objExec = g_objShell.Exec(strCmdLine)380 g_strShellOutput = objExec.StdOut.ReadAll()381 objExec.StdErr.ReadAll()382 do while objExec.Status = 0383 Wscript.Sleep 20384 g_strShellOutput = g_strShellOutput & objExec.StdOut.ReadAll()385 objExec.StdErr.ReadAll()386 loop387 388 LogPrint "# Status: " & objExec.ExitCode389 LogPrint "# Start of Output"390 LogPrint g_strShellOutput391 LogPrint "# End of Output"392 393 Shell = objExec.ExitCode394 end function395 396 397 ''398 ' Gets the SID of the current user.399 function GetSid()400 dim objNet, strUser, strDomain, offSlash, objWmiUser401 GetSid = ""402 403 ' Figure the user + domain404 set objNet = CreateObject("WScript.Network")405 strUser = objNet.UserName406 strDomain = objNet.UserDomain407 offSlash = InStr(1, strUser, "\")408 if offSlash > 0 then409 strDomain = Left(strUser, offSlash - 1)410 strUser = Right(strUser, Len(strUser) - offSlash)411 end if412 413 ' Lookup the user.414 on error resume next415 set objWmiUser = GetObject("winmgmts:{impersonationlevel=impersonate}!/root/cimv2:Win32_UserAccount." _416 & "Domain='" & strDomain &"',Name='" & strUser & "'")417 if err.number = 0 then418 GetSid = objWmiUser.SID419 end if420 end function421 422 423 ''424 ' Gets the commandline used to invoke the script.425 function GetCommandline()426 dim str, i427 428 '' @todo find an api for querying it instead of reconstructing it like this...429 GetCommandline = "cscript configure.vbs"430 for i = 1 to WScript.Arguments.Count431 str = WScript.Arguments.Item(i - 1)432 if str = "" then433 str = """"""434 elseif (InStr(1, str, " ")) then435 str = """" & str & """"436 end if437 GetCommandline = GetCommandline & " " & str438 next439 end function440 441 442 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''443 ' Helpers: Environment '444 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''445 446 ''447 ' Gets an environment variable.448 function EnvGet(strName)449 EnvGet = g_objShell.Environment("PROCESS")(strName)450 end function451 452 453 ''454 ' Sets an environment variable.455 sub EnvSet(strName, strValue)456 g_objShell.Environment("PROCESS")(strName) = strValue457 LogPrint "EnvSet: " & strName & "=" & strValue458 end sub459 460 461 ''462 ' Appends a string to an environment variable463 sub EnvAppend(strName, strValue)464 dim str465 str = g_objShell.Environment("PROCESS")(strName)466 g_objShell.Environment("PROCESS")(strName) = str & strValue467 LogPrint "EnvAppend: " & strName & "=" & str & strValue468 end sub469 470 471 ''472 ' Prepends a string to an environment variable473 sub EnvPrepend(strName, strValue)474 dim str475 str = g_objShell.Environment("PROCESS")(strName)476 g_objShell.Environment("PROCESS")(strName) = strValue & str477 LogPrint "EnvPrepend: " & strName & "=" & strValue & str478 end sub479 480 ''481 ' Gets the first non-empty environment variable of the given two.482 function EnvGetFirst(strName1, strName2)483 EnvGetFirst = g_objShell.Environment("PROCESS")(strName1)484 if EnvGetFirst = "" then485 EnvGetFirst = g_objShell.Environment("PROCESS")(strName2)486 end if487 end function488 489 490 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''491 ' Helpers: Strings '492 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''493 494 ''495 ' Right pads a string with spaces to the given length496 function RightPad(str, cch)497 if Len(str) < cch then498 RightPad = str & String(cch - Len(str), " ")499 else500 RightPad = str501 end if502 end function503 504 505 ''506 ' Checks if the given character is a decimal digit507 function CharIsDigit(ch)508 CharIsDigit = (InStr(1, "0123456789", ch) > 0)509 end function510 511 ''512 ' Worker for StrVersionCompare513 ' The offset is updated to point to the first non-digit character.514 function CountDigitsIgnoreLeadingZeros(ByRef str, ByRef off)515 dim cntDigits, blnLeadingZeros, ch, offInt516 cntDigits = 0517 if CharIsDigit(Mid(str, off, 1)) then518 ' Rewind to start of digest sequence.519 do while off > 1520 if not CharIsDigit(Mid(str, off - 1, 1)) then exit do521 off = off - 1522 loop523 ' Count digits, ignoring leading zeros.524 blnLeadingZeros = True525 for off = off to Len(str)526 ch = Mid(str, off, 1)527 if CharIsDigit(ch) then528 if ch <> "0" or blnLeadingZeros = False then529 cntDigits = cntDigits + 1530 blnLeadingZeros = False531 end if532 else533 exit for534 end if535 next536 ' If all zeros, count one of them.537 if cntDigits = 0 then cntDigits = 1538 end if539 CountDigitsIgnoreLeadingZeros = cntDigits540 end function541 542 ''543 ' Very simple version string compare function.544 ' @returns < 0 if str1 is smaller than str2545 ' @returns 0 if str1 and str2 are equal546 ' @returns > 1 if str2 is larger than str1547 function StrVersionCompare(str1, str2)548 ' Compare the strings. We can rely on StrComp if equal or one is empty.549 'LogPrint "StrVersionCompare("&str1&","&str2&"):"550 StrVersionCompare = StrComp(str2, str1)551 if StrVersionCompare <> 0 then552 dim cch1, cch2, off1, off2, ch1, ch2, chPrev1, chPrev2, intDiff, cchDigits553 cch1 = Len(str1)554 cch2 = Len(str2)555 if cch1 > 0 and cch2 > 0 then556 ' Compare the common portion557 off1 = 1558 off2 = 1559 chPrev1 = "x"560 chPrev2 = "x"561 do while off1 <= cch1 and off2 <= cch2562 ch1 = Mid(str1, off1, 1)563 ch2 = Mid(str2, off2, 1)564 if ch1 = ch2 then565 off1 = off1 + 1566 off2 = off2 + 1567 chPrev1 = ch1568 chPrev2 = ch2569 else570 ' Is there a digest sequence in play. This includes the scenario where one of the571 ' string ran out of digests.572 dim blnDigest1 : blnDigest1 = CharIsDigit(ch1)573 dim blnDigest2 : blnDigest2 = CharIsDigit(ch2)574 if (blnDigest1 = True or blnDigest2 = True) _575 and (blnDigest1 = True or CharIsDigit(chPrev1) = True) _576 and (blnDigest2 = True or CharIsDigit(chPrev2) = True) _577 then578 'LogPrint "StrVersionCompare: off1="&off1&" off2="&off2&" ch1="&ch1&" chPrev1="&chPrev1&" ch2="&ch2&" chPrev2="&chPrev2579 if blnDigest1 = False then off1 = off1 - 1580 if blnDigest2 = False then off2 = off2 - 1581 ' The one with the fewer digits comes first.582 ' Note! off1 and off2 are adjusted to next non-digit character in the strings.583 cchDigits = CountDigitsIgnoreLeadingZeros(str1, off1)584 intDiff = cchDigits - CountDigitsIgnoreLeadingZeros(str2, off2)585 'LogPrint "StrVersionCompare: off1="&off1&" off2="&off2&" cchDigits="&cchDigits586 if intDiff <> 0 then587 StrVersionCompare = intDiff588 'LogPrint "StrVersionCompare: --> "&intDiff&" #1"589 exit function590 end if591 592 ' If the same number of digits, the smaller digit wins. However, because of593 ' potential leading zeros, we must redo the compare. Assume ASCII-like stuff594 ' and we can use StrComp for this.595 intDiff = StrComp(Mid(str1, off1 - cchDigits, cchDigits), Mid(str2, off2 - cchDigits, cchDigits))596 if intDiff <> 0 then597 StrVersionCompare = intDiff598 'LogPrint "StrVersionCompare: --> "&intDiff&" #2"599 exit function600 end if601 chPrev1 = "x"602 chPrev2 = "x"603 else604 if blnDigest1 then605 StrVersionCompare = -1 ' Digits before characters606 'LogPrint "StrVersionCompare: --> -1 (#3)"607 elseif blnDigest2 then608 StrVersionCompare = 1 ' Digits before characters609 'LogPrint "StrVersionCompare: --> 1 (#4)"610 else611 StrVersionCompare = StrComp(ch1, ch2)612 'LogPrint "StrVersionCompare: --> "&StrVersionCompare&" (#5)"613 end if614 exit function615 end if616 end if617 loop618 619 ' The common part matches up, so the shorter string 'wins'.620 StrVersionCompare = (cch1 - off1) - (cch2 - off2)621 end if622 end if623 'LogPrint "StrVersionCompare: --> "&StrVersionCompare&" (#6)"624 end function625 626 627 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''628 ' Helpers: Arrays '629 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''630 631 ''632 ' Returns a reverse array (copy).633 function ArrayReverse(arr)634 dim cnt, i, j, iHalf, objTmp635 cnt = UBound(arr) - LBound(arr) + 1636 if cnt > 0 then637 j = UBound(arr)638 iHalf = Fix(LBound(arr) + cnt / 2)639 for i = LBound(arr) to iHalf - 1640 objTmp = arr(i)641 arr(i) = arr(j)642 arr(j) = objTmp643 j = j - 1644 next645 end if646 ArrayReverse = arr647 end function648 649 650 ''651 ' Returns a reverse sorted array (strings).652 function ArraySortStringsEx(arrStrings, ByRef fnCompare)653 dim str1, str2, i, j654 for i = LBound(arrStrings) to UBound(arrStrings)655 str1 = arrStrings(i)656 for j = i + 1 to UBound(arrStrings)657 str2 = arrStrings(j)658 if fnCompare(str2, str1) < 0 then659 arrStrings(j) = str1660 str1 = str2661 end if662 next663 arrStrings(i) = str1664 next665 ArraySortStringsEx = arrStrings666 end function667 668 669 ''670 ' Returns a reverse sorted array (strings).671 function ArraySortStrings(arrStrings)672 ArraySortStrings = ArraySortStringsEx(arrStrings, GetRef("StrComp"))673 end function674 675 676 ''677 ' Returns a reverse sorted array (strings).678 function ArrayVerSortStrings(arrStrings)679 ArrayVerSortStrings = ArraySortStringsEx(arrStrings, GetRef("StrVersionCompare"))680 end function681 682 683 ''684 ' Returns a reverse sorted array (strings).685 function ArrayRSortStrings(arrStrings)686 ArrayRSortStrings = ArrayReverse(ArraySortStringsEx(arrStrings, GetRef("StrComp")))687 end function688 689 690 ''691 ' Returns a reverse version sorted array (strings).692 function ArrayRVerSortStrings(arrStrings)693 ArrayRVerSortStrings = ArrayReverse(ArraySortStringsEx(arrStrings, GetRef("StrVersionCompare")))694 end function695 696 697 ''698 ' Prints a string array.699 sub ArrayPrintStrings(arrStrings, strPrefix)700 for i = LBound(arrStrings) to UBound(arrStrings)701 Print strPrefix & "arrStrings(" & i & ") = '" & arrStrings(i) & "'"702 next703 end sub704 705 706 ''707 ' Returns the input array with the string appended.708 ' Note! There must be some better way of doing this...709 ' @todo Lots of copying here...710 function ArrayAppend(arr, str)711 dim i, cnt712 cnt = UBound(arr) - LBound(arr) + 1713 redim arrRet(cnt)714 for i = LBound(arr) to UBound(arr)715 arrRet(i) = arr(i)716 next717 arrRet(UBound(arr) + 1) = str718 ArrayAppend = arrRet719 end function720 721 722 ''723 ' Checks if the array contains the given string (case sensitive).724 function ArrayContainsString(ByRef arr, str)725 dim strCur726 ArrayContainsString = False727 for each strCur in arr728 if StrComp(strCur, str) = 0 then729 ArrayContainsString = True730 exit function731 end if732 next733 end function734 735 736 ''737 ' Checks if the array contains the given string, using case insensitive compare.738 function ArrayContainsStringI(ByRef arr, str)739 dim strCur740 ArrayContainsStringI = False741 for each strCur in arr742 if StrComp(strCur, str, vbTextCompare) = 0 then743 ArrayContainsStringI = True744 exit function745 end if746 next747 end function748 749 ''750 ' Returns the number of entries in an array.751 function ArraySize(ByRef arr)752 if (UBound(arr) >= 0) then753 ArraySize = UBound(arr) - LBound(arr) + 1754 else755 ArraySize = 0756 end if757 end function758 759 760 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''761 ' Helpers: Registry '762 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''763 764 '' The registry globals765 dim g_objReg, g_objRegCtx766 dim g_blnRegistry767 g_blnRegistry = false768 769 770 ''771 ' Init the register provider globals.772 function RegInit()773 RegInit = false774 On Error Resume Next775 if g_blnRegistry = false then776 set g_objRegCtx = CreateObject("WbemScripting.SWbemNamedValueSet")777 ' Comment out the following for lines if the cause trouble on your windows version.778 if IsWow64() then779 g_objRegCtx.Add "__ProviderArchitecture", 64780 g_objRegCtx.Add "__RequiredArchitecture", true781 LogPrint "RegInit: WoW64"782 end if783 set objLocator = CreateObject("Wbemscripting.SWbemLocator")784 set objServices = objLocator.ConnectServer("", "root\default", "", "", , , , g_objRegCtx)785 set g_objReg = objServices.Get("StdRegProv")786 g_blnRegistry = true787 end if788 RegInit = true789 end function790 791 792 ''793 ' Translates a register root name to a value794 ' This will translate HKCU path to HKEY_USERS and fixing795 function RegTransRoot(strRoot, ByRef sSubKeyName)796 const HKEY_LOCAL_MACHINE = &H80000002797 const HKEY_CURRENT_USER = &H80000001798 const HKEY_USERS = &H80000003799 800 select case strRoot801 case "HKLM"802 RegTransRoot = HKEY_LOCAL_MACHINE803 case "HKUS"804 RegTransRoot = HKEY_USERS805 case "HKCU"806 dim strCurrentSid807 strCurrentSid = GetSid()808 if strCurrentSid <> "" then809 sSubKeyName = strCurrentSid & "\" & sSubKeyName810 RegTransRoot = HKEY_USERS811 'LogPrint "RegTransRoot: HKCU -> HKEY_USERS + " & sSubKeyName812 else813 RegTransRoot = HKEY_CURRENT_USER814 LogPrint "RegTransRoot: Warning! HKCU -> HKEY_USERS failed!"815 end if816 case else817 MsgFatal "RegTransRoot: Unknown root: '" & strRoot & "'"818 RegTransRoot = 0819 end select820 end function821 822 823 ''824 ' Gets a value from the registry. Returns "" if string wasn't found / valid.825 function RegGetString(strName)826 RegGetString = ""827 if RegInit() then828 dim strRoot, strKey, strValue829 830 ' split up into root, key and value parts.831 strRoot = left(strName, instr(strName, "\") - 1)832 strKey = mid(strName, instr(strName, "\") + 1, instrrev(strName, "\") - instr(strName, "\"))833 strValue = mid(strName, instrrev(strName, "\") + 1)834 835 ' Must use ExecMethod to call the GetStringValue method because of the context.836 Set InParms = g_objReg.Methods_("GetStringValue").Inparameters837 InParms.hDefKey = RegTransRoot(strRoot, strKey)838 InParms.sSubKeyName = strKey839 InParms.sValueName = strValue840 On Error Resume Next841 set OutParms = g_objReg.ExecMethod_("GetStringValue", InParms, , g_objRegCtx)842 if OutParms.ReturnValue = 0 then843 if OutParms.sValue <> Null then844 RegGetString = OutParms.sValue845 end if846 end if847 else848 ' fallback mode849 On Error Resume Next850 RegGetString = g_objShell.RegRead(strName)851 end if852 end function853 854 855 ''856 ' Gets a multi string value from the registry. Returns array of strings if found, otherwise empty array().857 function RegGetMultiString(strName)858 RegGetMultiString = Array()859 if RegInit() then860 dim strRoot, strKey, strValue861 862 ' split up into root, key and value parts.863 strRoot = left(strName, instr(strName, "\") - 1)864 strKey = mid(strName, instr(strName, "\") + 1, instrrev(strName, "\") - instr(strName, "\"))865 strValue = mid(strName, instrrev(strName, "\") + 1)866 867 ' Must use ExecMethod to call the GetStringValue method because of the context.868 Set InParms = g_objReg.Methods_("GetMultiStringValue").Inparameters869 InParms.hDefKey = RegTransRoot(strRoot, strKey)870 InParms.sSubKeyName = strKey871 InParms.sValueName = strValue872 On Error Resume Next873 set OutParms = g_objReg.ExecMethod_("GetMultiStringValue", InParms, , g_objRegCtx)874 if OutParms.ReturnValue = 0 then875 if OutParms.sValue <> Null then876 RegGetMultiString = OutParms.sValue877 end if878 end if879 else880 ' fallback mode881 On Error Resume Next882 RegGetMultiString = g_objShell.RegRead(strName)883 end if884 end function885 886 887 ''888 ' Returns an array of subkey strings.889 function RegEnumSubKeys(strRoot, ByVal strKeyPath)890 RegEnumSubKeys = Array()891 if RegInit() then892 ' Must use ExecMethod to call the EnumKey method because of the context.893 Set InParms = g_objReg.Methods_("EnumKey").Inparameters894 InParms.hDefKey = RegTransRoot(strRoot, strKeyPath)895 InParms.sSubKeyName = strKeyPath896 On Error Resume Next897 set OutParms = g_objReg.ExecMethod_("EnumKey", InParms, , g_objRegCtx)898 'LogPrint "RegEnumSubKeys(" & Hex(InParms.hDefKey) & "," & InParms.sSubKeyName &") -> " & OutParms.GetText_(1)899 if OutParms.ReturnValue = 0 then900 if OutParms.sNames <> Null then901 RegEnumSubKeys = OutParms.sNames902 end if903 end if904 else905 ' fallback mode906 dim objReg, rc, arrSubKeys907 set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")908 On Error Resume Next909 rc = objReg.EnumKey(RegTransRoot(strRoot, strKeyPath), strKeyPath, arrSubKeys)910 if rc = 0 then911 RegEnumSubKeys = arrSubKeys912 end if913 end if914 end function915 916 917 ''918 ' Returns an array of full path subkey strings.919 function RegEnumSubKeysFull(strRoot, strKeyPath)920 dim arrTmp921 arrTmp = RegEnumSubKeys(strRoot, strKeyPath)922 for i = LBound(arrTmp) to UBound(arrTmp)923 arrTmp(i) = strKeyPath & "\" & arrTmp(i)924 next925 RegEnumSubKeysFull = arrTmp926 end function927 928 929 ''930 ' Returns an rsorted array of subkey strings.931 function RegEnumSubKeysRVerSorted(strRoot, strKeyPath)932 RegEnumSubKeysRVerSorted = ArrayRVerSortStrings(RegEnumSubKeys(strRoot, strKeyPath))933 end function934 935 936 ''937 ' Returns an rsorted array of subkey strings.938 function RegEnumSubKeysFullRVerSorted(strRoot, strKeyPath)939 RegEnumSubKeysFullRVerSorted = ArrayRVerSortStrings(RegEnumSubKeysFull(strRoot, strKeyPath))940 end function941 942 943 ''944 ' Returns an array of value name strings.945 function RegEnumValueNames(strRoot, ByVal strKeyPath)946 RegEnumValueNames = Array()947 if RegInit() then948 ' Must use ExecMethod to call the EnumKey method because of the context.949 Set InParms = g_objReg.Methods_("EnumValues").Inparameters950 InParms.hDefKey = RegTransRoot(strRoot, strKeyPath)951 InParms.sSubKeyName = strKeyPath952 On Error Resume Next953 set OutParms = g_objReg.ExecMethod_("EnumValues", InParms, , g_objRegCtx)954 'LogPrint "RegEnumValueNames(" & Hex(InParms.hDefKey) & "," & InParms.sSubKeyName &") -> " & OutParms.GetText_(1)955 if OutParms.ReturnValue = 0 then956 if OutParms.sNames <> Null then957 RegEnumValueNames = OutParms.sNames958 end if959 end if960 else961 ' fallback mode962 dim objReg, rc, arrSubKeys963 set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")964 On Error Resume Next965 rc = objReg.EnumValues(RegTransRoot(strRoot, strKeyPath), strKeyPath, arrSubKeys)966 if rc = 0 then967 RegEnumValueNames = arrSubKeys968 end if969 end if970 end function971 972 973 ''974 ' Returns an array of full path value name strings.975 function RegEnumValueNamesFull(strRoot, strKeyPath)976 dim arrTmp977 arrTmp = RegEnumValueNames(strRoot, strKeyPath)978 for i = LBound(arrTmp) to UBound(arrTmp)979 arrTmp(i) = strKeyPath & "\" & arrTmp(i)980 next981 RegEnumValueNamesFull = arrTmp982 end function983 984 985 ''986 ' Extract relevant paths from program links using a callback function.987 '988 ' Enumerates start menu program links from "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"989 ' and similar, using the given callback to examine each and return a path if relevant. The relevant990 ' paths are returned in reverse sorted order.991 '992 ' The callback prototype is as follows fnCallback(ByRef arrStrings, cStrings, ByRef objUser).993 ' Any non-empty return strings are collected, reverse sorted uniquely and returned.994 '995 function CollectFromProgramItemLinks(ByRef fnCallback, ByRef objUser)996 dim arrValues, strValue, arrStrings, str, arrCandidates, iCandidates, cStrings997 CollectFromProgramItemLinks = Array()998 999 arrValues = RegEnumValueNamesFull("HKCU", "SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC")1000 redim arrCandidates(UBound(arrValues) - LBound(arrValues) + 1)1001 iCandidates = 01002 for each strValue in arrValues1003 arrStrings = RegGetMultiString("HKCU\" & strValue)1004 if UBound(arrStrings) >= 0 then1005 cStrings = UBound(arrStrings) + 1 - LBound(arrStrings)1006 str = fnCallback(arrStrings, cStrings, objUser)1007 if str <> "" then1008 if not ArrayContainsStringI(arrCandidates, str) then1009 arrCandidates(iCandidates) = str1010 iCandidates = iCandidates + 11011 end if1012 end if1013 end if1014 next1015 if iCandidates > 0 then1016 redim preserve arrCandidates(iCandidates - 1)1017 arrCandidates = ArrayRVerSortStrings(arrCandidates)1018 for iCandidates = LBound(arrCandidates) to UBound(arrCandidates)1019 LogPrint "CollectFromProgramItemLinks: #" & iCandidates & ": " & arrCandidates(iCandidates)1020 next1021 CollectFromProgramItemLinks = arrCandidates1022 end if1023 end function1024 1025 1026 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1027 ' Helpers: Messaging and Output '1028 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1029 1030 ''1031 ' Append text to the log file and echo it to stdout1032 sub Print(str)1033 LogPrint str1034 Wscript.Echo str1035 end sub1036 1037 1038 ''1039 ' Prints a test header1040 sub PrintHdr(strTest)1041 LogPrint "***** Checking for " & strTest & " *****"1042 Wscript.Echo "Checking for " & StrTest & "..."1043 end sub1044 1045 1046 ''1047 ' Prints a success message1048 sub PrintResultMsg(strTest, strResult)1049 dim cchPad1050 LogPrint "** " & strTest & ": " & strResult1051 Wscript.Echo " Found " & RightPad(strTest & ": ", 22) & strPad & strResult1052 end sub1053 1054 1055 ''1056 ' Prints a successfully detected path1057 sub PrintResult(strTest, strPath)1058 strLongPath = PathAbsLong(strPath)1059 if PathAbs(strPath) <> strLongPath then1060 LogPrint "** " & strTest & ": " & strPath & " (" & UnixSlashes(strLongPath) & ")"1061 Wscript.Echo " Found " & RightPad(strTest & ": ", 22) & strPath & " (" & UnixSlashes(strLongPath) & ")"1062 else1063 LogPrint "** " & strTest & ": " & strPath1064 Wscript.Echo " Found " & RightPad(strTest & ": ", 22) & strPath1065 end if1066 end sub1067 1068 1069 ''1070 ' Warning message.1071 sub MsgWarning(strMsg)1072 Print "warning: " & strMsg1073 end sub1074 1075 1076 ''1077 ' Fatal error.1078 sub MsgFatal(strMsg)1079 Print "fatal error: " & strMsg1080 Wscript.Quit(1)1081 end sub1082 1083 1084 ''1085 ' Error message, fatal unless flag to ignore errors is given.1086 sub MsgError(strMsg)1087 Print "error: " & strMsg1088 if g_blnContinueOnError = False then1089 Wscript.Quit(1)1090 end if1091 g_rcScript = 11092 end sub1093 105 1094 106 … … 1173 185 ' If no file is found, log the failure. 1174 186 function LogFindFile(strPath, strPattern) 1175 dim str 187 dim str, strOutput 1176 188 1177 189 ' … … 1180 192 ' too much hassle. So, we'll do it the unix way... 1181 193 ' 1182 if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True ) = 0 _1183 And InStr(1, g_strShellOutput, Chr(13)) > 1 _194 if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True, strOutput) = 0 _ 195 And InStr(1, strOutput, Chr(13)) > 1 _ 1184 196 then 1185 197 ' return the first word. 1186 LogFindFile = Left( g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)198 LogFindFile = Left(strOutput, InStr(1, strOutput, Chr(13)) - 1) 1187 199 else 1188 200 LogPrint "Testing '" & strPath & "': " & strPattern & " not found" … … 1197 209 ' else return the complete path to the found directory. 1198 210 function LogFindDir(strPath, strPattern) 1199 dim str 211 dim str, strOutput 1200 212 1201 213 ' … … 1206 218 1207 219 ' List the alphabetically last names as first entries (with /O-N). 1208 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True ) = 0 _1209 And InStr(1, g_strShellOutput, Chr(13)) > 1 _220 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True, strOutput) = 0 _ 221 And InStr(1, strOutput, Chr(13)) > 1 _ 1210 222 then 1211 223 ' return the first word. 1212 LogFindDir = strPath & "/" & Left( g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1)224 LogFindDir = strPath & "/" & Left(strOutput, InStr(1, strOutput, Chr(13)) - 1) 1213 225 else 1214 226 LogPrint "Testing '" & strPath & "': " & strPattern & " not found" … … 1217 229 end function 1218 230 231 232 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 233 ' Helpers: Configuration and Batch Script Writers ' 234 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 1219 235 1220 236 '' … … 1311 327 ' Do the setting. 1312 328 FileAppendLine g_strEnvFile, "set " & strEnv & "=%" & strEnv & "%" & strSep & strValue 1313 end sub1314 1315 1316 ''1317 ' Self test for some of the above routines.1318 '1319 sub SelfTest1320 dim i, str1321 str = "0123456789"1322 for i = 1 to Len(str)1323 if CharIsDigit(Mid(str, i, 1)) <> True then MsgFatal "SelfTest failed: CharIsDigit("&Mid(str, i, 1)&")"1324 next1325 str = "abcdefghijklmnopqrstuvwxyz~`!@#$%^&*()_+-=ABCDEFGHIJKLMNOPQRSTUVWXYZ/\[]{}"1326 for i = 1 to Len(str)1327 if CharIsDigit(Mid(str, i, 1)) <> False then MsgFatal "SelfTest failed: CharIsDigit("&Mid(str, i, 1)&")"1328 next1329 if StrVersionCompare("1234", "1234") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #1"1330 if StrVersionCompare("1", "1") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #2"1331 if StrVersionCompare("2", "1") <= 0 then MsgFatal "SelfTest failed: StrVersionCompare #3"1332 if StrVersionCompare("1", "2") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #4"1333 if StrVersionCompare("01", "1") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #5"1334 if StrVersionCompare("01", "001") <> 0 then MsgFatal "SelfTest failed: StrVersionCompare #6"1335 if StrVersionCompare("12", "123") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #7"1336 if StrVersionCompare("v123", "123") <= 0 then MsgFatal "SelfTest failed: StrVersionCompare #8"1337 if StrVersionCompare("v1.2.3", "v1.3.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #9"1338 if StrVersionCompare("v1.02.3", "v1.3.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #10"1339 if StrVersionCompare("v1.2.3", "v1.03.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #11"1340 if StrVersionCompare("v1.2.4", "v1.23.4") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #12"1341 if StrVersionCompare("v10.0.17163", "v10.00.18363") >= 0 then MsgFatal "SelfTest failed: StrVersionCompare #13"1342 329 end sub 1343 330 … … 1420 407 ' 1421 408 sub CheckForkBuild(strOptkBuild) 409 dim blnNeedEnvVars, strOutput 1422 410 PrintHdr "kBuild" 1423 411 … … 1432 420 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _ 1433 421 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _ 1434 And (Shell("kmk.exe --version", True ) = 0) _1435 And (InStr(1, g_strShellOutput, "kBuild Make 0.1") > 0) _1436 And (InStr(1, g_strShellOutput, "KBUILD_PATH") > 0) _1437 And (InStr(1, g_strShellOutput, "KBUILD_BIN_PATH") > 0) then422 And (Shell("kmk.exe --version", True, strOutput) = 0) _ 423 And (InStr(1,strOutput, "kBuild Make 0.1") > 0) _ 424 And (InStr(1,strOutput, "KBUILD_PATH") > 0) _ 425 And (InStr(1,strOutput, "KBUILD_BIN_PATH") > 0) then 1438 426 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests. 1439 427 'blnNeedEnvVars = False … … 1586 574 end if 1587 575 1588 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True ) <> 0) then576 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True, strOutput) <> 0) then 1589 577 MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out." 1590 578 exit sub … … 1656 644 public function checkClExe(strClExe) 1657 645 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH. 1658 dim strSavedPath, rcExit 646 dim strSavedPath, rcExit, strOutput 1659 647 1660 648 strSavedPath = EnvGet("PATH") … … 1662 650 EnvAppend "PATH", ";" & m_strPathVCCommon & "/IDE" 1663 651 end if 1664 rcExit = Shell(DosSlashes(strClExe), True )652 rcExit = Shell(DosSlashes(strClExe), True, strOutput) 1665 653 EnvSet "PATH", strSavedPath 1666 654 … … 1670 658 dim offVer, offEol, strVer 1671 659 strVer = "" 1672 offVer = InStr(1, g_strShellOutput, " Version ")660 offVer = InStr(1, strOutput, " Version ") 1673 661 if offVer > 0 then 1674 662 offVer = offVer + Len(" Version ") 1675 offEol = InStr(offVer, g_strShellOutput, Chr(13))663 offEol = InStr(offVer, strOutput, Chr(13)) 1676 664 if offEol > 0 then 1677 strVer = Trim(Mid( g_strShellOutput, offVer, offEol - offVer))665 strVer = Trim(Mid(strOutput, offVer, offEol - offVer)) 1678 666 end if 1679 667 end if … … 1988 976 '' Checks if the specified path points to a usable PSDK. 1989 977 function CheckForPlatformSDKSub(strPathPSDK) 978 dim strOutput 1990 979 CheckForPlatformSDKSub = False 1991 980 LogPrint "trying: strPathPSDK=" & strPathPSDK … … 1994 983 And LogFileExists(strPathPSDK, "lib/User32.Lib") _ 1995 984 And LogFileExists(strPathPSDK, "bin/rc.exe") _ 1996 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True ) <> 0 _985 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True, strOutput) <> 0 _ 1997 986 then 1998 if InStr(1, g_strShellOutput, "Resource Compiler Version 6.2.") > 0 then987 if InStr(1, strOutput, "Resource Compiler Version 6.2.") > 0 then 1999 988 g_strVerPSDK = "80" 2000 989 CheckForPlatformSDKSub = True 2001 elseif InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then990 elseif InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then 2002 991 g_strVerPSDK = "71" 2003 992 CheckForPlatformSDKSub = True … … 2195 1184 '' Quick check if the DDK is in the specified directory or not. 2196 1185 function CheckForWinDDKSub(strPathDDK, blnCheckBuild) 1186 dim strOutput 2197 1187 CheckForWinDDKSub = False 2198 1188 LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild … … 2208 1198 CheckForWinDDKSub = True 2209 1199 '' @todo Find better build check. 2210 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True ) <> 0 _2211 And InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then1200 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True, strOutput) <> 0 _ 1201 And InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then 2212 1202 CheckForWinDDKSub = True 2213 1203 end if … … 2880 1870 ' 2881 1871 function Main 1872 dim strOutput 1873 2882 1874 ' 2883 1875 ' Write the log header and check that we're not using wscript. … … 3025 2017 ' 3026 2018 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works" 3027 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False ) <> 0 then ' The 'E' is missing on purpose (4nt).2019 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False, strOutput) <> 0 then ' The 'E' is missing on purpose (4nt). 3028 2020 MsgFatal "shell execution test failed!" 3029 2021 end if 3030 if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then3031 Print "Shell test Test -> '" & g_strShellOutput & "'"2022 if strOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then 2023 Print "Shell test Test -> '" & strOutput & "'" 3032 2024 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe." 3033 2025 end if … … 3039 2031 ' 3040 2032 if blnOptDisableCOM = True then 3041 DisableCOM "--disable-com"2033 DisableCOM "--disable-com" 3042 2034 end if 3043 2035 if blnOptDisableUDPTunnel = True then 3044 DisableUDPTunnel "--disable-udptunnel"2036 DisableUDPTunnel "--disable-udptunnel" 3045 2037 end if 3046 2038 CheckSourcePath … … 3052 2044 CheckForMidl strOptMidl 3053 2045 CheckForOpenWatcom strOptOpenWatcom 2046 if blnOptDisableSDL = True then 2047 DisableSDL "--disable-sdl" 2048 else 2049 CheckForlibSDL strOptlibSDL 2050 end if 2051 CheckForXml2 strOptXml2 2052 CheckForSsl strOptSsl, False 2053 if g_strTargetArch = "amd64" then 2054 ' 32-bit openssl required as well 2055 CheckForSsl strOptSsl32, True 2056 end if 2057 CheckForCurl strOptCurl, False 2058 if g_strTargetArch = "amd64" then 2059 ' 32-bit Curl required as well 2060 CheckForCurl strOptCurl32, True 2061 end if 2062 CheckForQt strOptQt5, strOptQt5Infix 2063 CheckForPython strOptPython 2064 3054 2065 CfgPrintAssign "VBOX_WITH_LIBVPX", "" '' @todo look for libvpx 1.1.0+ 3055 2066 CfgPrintAssign "VBOX_WITH_LIBOPUS", "" '' @todo look for libopus 1.2.1+ 3056 3057 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win." & g_strHostArch & "\bin"), ";" '' @todo look for yasm2067 '' @todo look for yasm 2068 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win." & g_strHostArch & "\bin"), ";" 3058 2069 if g_strHostArch = "amd64" then 3059 2070 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win.x86\bin"), ";" … … 3061 2072 EnvPrintCleanup "PATH", DosSlashes(g_strPath & "\tools\win.amd64\bin"), ";" 3062 2073 end if 3063 if blnOptDisableSDL = True then3064 DisableSDL "--disable-sdl"3065 else3066 CheckForlibSDL strOptlibSDL3067 end if3068 CheckForXml2 strOptXml23069 CheckForSsl strOptSsl, False3070 if g_strTargetArch = "amd64" then3071 ' 32-bit openssl required as well3072 CheckForSsl strOptSsl32, True3073 end if3074 CheckForCurl strOptCurl, False3075 if g_strTargetArch = "amd64" then3076 ' 32-bit Curl required as well3077 CheckForCurl strOptCurl32, True3078 end if3079 CheckForQt strOptQt5, strOptQt5Infix3080 CheckForPython strOptPython3081 2074 3082 2075 Print "" -
trunk/tools/win/vbscript/helpers.vbs
r85807 r85809 1 1 ' $Id$ 2 2 '' @file 3 ' The purpose of this script is to check for all external tools, headers, and 4 ' libraries VBox OSE depends on. 3 ' Common VBScript helpers used by configure.vbs and later others. 5 4 ' 6 ' The script generates the build configuration file 'AutoConfig.kmk' and the 7 ' environment setup script 'env.bat'. A log of what has been done is 8 ' written to 'configure.log'. 5 ' Requires the script including it to define a LogPrint function. 9 6 ' 10 7 … … 22 19 23 20 24 '***************************************************************************** 25 '* Global Variables * 26 '***************************************************************************** 27 dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile, g_strShellOutput 28 g_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs")) 29 g_strEnvFile = g_strPath & "\env.bat" 30 g_strCfgFile = g_strPath & "\AutoConfig.kmk" 31 g_strLogFile = g_strPath & "\configure.log" 32 'g_strTmpFile = g_strPath & "\configure.tmp" 33 34 dim g_objShell, g_objFileSys 35 Set g_objShell = WScript.CreateObject("WScript.Shell") 21 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 22 ' Global Variables ' 23 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 24 dim g_objShell 25 Set g_objShell = WScript.CreateObject("WScript.Shell") 26 27 dim g_objFileSys 36 28 Set g_objFileSys = WScript.CreateObject("Scripting.FileSystemObject") 37 38 ' kBuild stuff.39 dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev40 g_strPathkBuild = ""41 g_strPathkBuildBin = ""42 g_strPathDev = ""43 44 dim g_strTargetArch, g_StrTargetArchWin45 g_strTargetArch = ""46 g_StrTargetArchWin = ""47 48 dim g_strHostArch, g_strHostArchWin49 g_strHostArch = ""50 g_strHostArchWin = ""51 52 ' Visual C++ info.53 dim g_strPathVCC, g_strVCCVersion54 g_strPathVCC = ""55 g_strVCCVersion = ""56 57 ' SDK and DDK.58 dim g_strPathSDK10, g_strPathPSDK, g_strVerPSDK, g_strPathDDK59 g_strPathSDK10 = ""60 g_strPathPSDK = ""61 g_strVerPSDK = ""62 g_strPathDDK = ""63 64 ' COM disabling.65 dim g_blnDisableCOM, g_strDisableCOM66 g_blnDisableCOM = False67 g_strDisableCOM = ""68 69 ' Whether to ignore (continue) on errors.70 dim g_blnContinueOnError, g_rcExit71 g_blnContinueOnError = False72 73 ' The script's exit code (for ignored errors).74 dim g_rcScript75 g_rcScript = 076 77 ' Whether to try the internal stuff first or last.78 dim g_blnInternalFirst79 g_blnInternalFirst = True80 81 ' List of program files locations.82 dim g_arrProgramFiles83 if EnvGet("ProgramFiles(x86)") <> "" then84 g_arrProgramFiles = Array(EnvGet("ProgramFiles"), EnvGet("ProgramFiles(x86)"))85 else86 g_arrProgramFiles = Array(EnvGet("ProgramFiles"))87 end if88 29 89 30 … … 365 306 366 307 '' 367 ' Executes a command in the shell catching output in g_strShellOutput368 function Shell(strCommand, blnBoth )308 ' Executes a command in the shell catching output in strOutput 309 function Shell(strCommand, blnBoth, ByRef strOutput) 369 310 dim strShell, strCmdline, objExec, str 370 311 … … 378 319 LogPrint "# Shell: " & strCmdline 379 320 Set objExec = g_objShell.Exec(strCmdLine) 380 g_strShellOutput = objExec.StdOut.ReadAll()321 strOutput = objExec.StdOut.ReadAll() 381 322 objExec.StdErr.ReadAll() 382 323 do while objExec.Status = 0 383 324 Wscript.Sleep 20 384 g_strShellOutput = g_strShellOutput & objExec.StdOut.ReadAll()325 strOutput = strOutput & objExec.StdOut.ReadAll() 385 326 objExec.StdErr.ReadAll() 386 327 loop … … 388 329 LogPrint "# Status: " & objExec.ExitCode 389 330 LogPrint "# Start of Output" 390 LogPrint g_strShellOutput331 LogPrint strOutput 391 332 LogPrint "# End of Output" 392 333 … … 1094 1035 1095 1036 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 1096 ' Helpers: Logging and Logged operations ' 1097 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 1098 1099 '' 1100 ' Write a log header with some basic info. 1101 sub LogInit 1102 FileDelete g_strLogFile 1103 LogPrint "# Log file generated by " & Wscript.ScriptFullName 1104 for i = 1 to WScript.Arguments.Count 1105 LogPrint "# Arg #" & i & ": " & WScript.Arguments.Item(i - 1) 1106 next 1107 if Wscript.Arguments.Count = 0 then 1108 LogPrint "# No arguments given" 1109 end if 1110 LogPrint "# Reconstructed command line: " & GetCommandline() 1111 1112 ' some Wscript stuff 1113 LogPrint "# Wscript properties:" 1114 LogPrint "# ScriptName: " & Wscript.ScriptName 1115 LogPrint "# Version: " & Wscript.Version 1116 LogPrint "# Build: " & Wscript.BuildVersion 1117 LogPrint "# Name: " & Wscript.Name 1118 LogPrint "# Full Name: " & Wscript.FullName 1119 LogPrint "# Path: " & Wscript.Path 1120 LogPrint "#" 1121 1122 1123 ' the environment 1124 LogPrint "# Environment:" 1125 dim objEnv 1126 for each strVar in g_objShell.Environment("PROCESS") 1127 LogPrint "# " & strVar 1128 next 1129 LogPrint "#" 1130 end sub 1131 1132 1133 '' 1134 ' Append text to the log file. 1135 sub LogPrint(str) 1136 FileAppendLine g_strLogFile, str 1137 'Wscript.Echo "dbg: " & str 1138 end sub 1139 1140 1141 '' 1142 ' Checks if the file exists and logs failures. 1143 function LogFileExists(strPath, strFilename) 1144 LogFileExists = FileExists(strPath & "/" & strFilename) 1145 if LogFileExists = False then 1146 LogPrint "Testing '" & strPath & "': " & strFilename & " not found" 1147 end if 1148 end function 1149 1150 1151 '' 1152 ' Checks if the file exists and logs failures. 1153 function LogFileExists1(strPath) 1154 LogFileExists1 = FileExists(strPath) 1155 if LogFileExists1 = False then 1156 LogPrint "Testing '" & strPath & "': file not found" 1157 end if 1158 end function 1159 1160 1161 '' 1162 ' Checks if the directory exists and logs failures. 1163 function LogDirExists(strPath) 1164 LogDirExists = DirExists(strPath) 1165 if LogDirExists = False then 1166 LogPrint "Testing '" & strPath & "': not found (or not dir)" 1167 end if 1168 end function 1169 1170 1171 '' 1172 ' Finds the first file matching the pattern. 1173 ' If no file is found, log the failure. 1174 function LogFindFile(strPath, strPattern) 1175 dim str 1176 1177 ' 1178 ' Yes, there are some facy database kinda interface to the filesystem 1179 ' however, breaking down the path and constructing a usable query is 1180 ' too much hassle. So, we'll do it the unix way... 1181 ' 1182 if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _ 1183 And InStr(1, g_strShellOutput, Chr(13)) > 1 _ 1184 then 1185 ' return the first word. 1186 LogFindFile = Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1) 1187 else 1188 LogPrint "Testing '" & strPath & "': " & strPattern & " not found" 1189 LogFindFile = "" 1190 end if 1191 end function 1192 1193 1194 '' 1195 ' Finds the first directory matching the pattern. 1196 ' If no directory is found, log the failure, 1197 ' else return the complete path to the found directory. 1198 function LogFindDir(strPath, strPattern) 1199 dim str 1200 1201 ' 1202 ' Yes, there are some facy database kinda interface to the filesystem 1203 ' however, breaking down the path and constructing a usable query is 1204 ' too much hassle. So, we'll do it the unix way... 1205 ' 1206 1207 ' List the alphabetically last names as first entries (with /O-N). 1208 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True) = 0 _ 1209 And InStr(1, g_strShellOutput, Chr(13)) > 1 _ 1210 then 1211 ' return the first word. 1212 LogFindDir = strPath & "/" & Left(g_strShellOutput, InStr(1, g_strShellOutput, Chr(13)) - 1) 1213 else 1214 LogPrint "Testing '" & strPath & "': " & strPattern & " not found" 1215 LogFindDir = "" 1216 end if 1217 end function 1218 1219 1220 '' 1221 ' Initializes the config file. 1222 sub CfgInit 1223 FileDelete g_strCfgFile 1224 CfgPrint "# -*- Makefile -*-" 1225 CfgPrint "#" 1226 CfgPrint "# Build configuration generated by " & GetCommandline() 1227 CfgPrint "#" 1228 CfgPrint "VBOX_OSE := 1" 1229 CfgPrint "VBOX_VCC_WERR = $(NO_SUCH_VARIABLE)" 1230 end sub 1231 1232 1233 '' 1234 ' Prints a string to the config file. 1235 sub CfgPrint(str) 1236 FileAppendLine g_strCfgFile, str 1237 end sub 1238 1239 '' 1240 ' Prints a string to the config file. 1241 sub CfgPrintAssign(strVar, strValue) 1242 if strValue = "" then 1243 FileAppendLine g_strCfgFile, RightPad(strVar, 17) & " :=" 1244 else 1245 FileAppendLine g_strCfgFile, RightPad(strVar, 17) & " := " & strValue 1246 end if 1247 end sub 1248 1249 1250 '' 1251 ' Initializes the environment batch script. 1252 sub EnvInit 1253 FileDelete g_strEnvFile 1254 EnvPrint "@echo off" 1255 EnvPrint "rem" 1256 EnvPrint "rem Environment setup script generated by " & GetCommandline() 1257 EnvPrint "rem" 1258 end sub 1259 1260 1261 '' 1262 ' Prints a string to the environment batch script. 1263 sub EnvPrint(str) 1264 FileAppendLine g_strEnvFile, str 1265 end sub 1266 1267 1268 '' 1269 ' Helper for EnvPrintPrepend and EnvPrintAppend. 1270 sub EnvPrintCleanup(strEnv, strValue, strSep) 1271 dim cchValueAndSep 1272 FileAppendLine g_strEnvFile, "set " & strEnv & "=%" & strEnv & ":" & strSep & strValue & strSep & "=" & strSep & "%" 1273 cchValueAndSep = Len(strValue) + Len(strSep) 1274 FileAppendLine g_strEnvFile, "if ""%" & strEnv & "%""==""" & strValue & """ set " & strEnv & "=" 1275 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0," & cchValueAndSep & "%""==""" & strValue & strSep & """ set " & strEnv & "=%" & strEnv & ":~" & cchValueAndSep & "%" 1276 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-" & cchValueAndSep & "%""==""" & strSep & strValue & """ set " & strEnv & "=%" & strEnv & ":~0,-" & cchValueAndSep & "%" 1277 end sub 1278 1279 1280 '' Use by EnvPrintPrepend to skip ';' stripping. 1281 dim g_strPrependCleanEnvVars 1282 1283 '' 1284 ' Print a statement prepending strValue to strEnv, removing duplicate values. 1285 sub EnvPrintPrepend(strEnv, strValue, strSep) 1286 ' Remove old values and any leading separators. 1287 EnvPrintCleanup strEnv, strValue, strSep 1288 if InStr(1, g_strPrependCleanEnvVars, "|" & strEnv & "|") = 0 then 1289 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0,1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~1%" 1290 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0,1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~1%" 1291 g_strPrependCleanEnvVars = g_strPrependCleanEnvVars & "|" & strEnv & "|" 1292 end if 1293 ' Do the setting 1294 FileAppendLine g_strEnvFile, "set " & strEnv & "=" & strValue & strSep & "%" & strEnv & "%" 1295 end sub 1296 1297 1298 '' Use by EnvPrintPrepend to skip ';' stripping. 1299 dim g_strAppendCleanEnvVars 1300 1301 '' 1302 ' Print a statement appending strValue to strEnv, removing duplicate values. 1303 sub EnvPrintAppend(strEnv, strValue, strSep) 1304 ' Remove old values and any trailing separators. 1305 EnvPrintCleanup strEnv, strValue, strSep 1306 if InStr(1, g_strAppendCleanEnvVars, "|" & strEnv & "|") = 0 then 1307 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~0,-1%" 1308 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~0,-1%" 1309 g_strAppendCleanEnvVars = g_strAppendCleanEnvVars & "|" & strEnv & "|" 1310 end if 1311 ' Do the setting. 1312 FileAppendLine g_strEnvFile, "set " & strEnv & "=%" & strEnv & "%" & strSep & strValue 1313 end sub 1314 1037 ' Testcases ' 1038 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 1315 1039 1316 1040 '' … … 1342 1066 end sub 1343 1067 1344 1345 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1346 ' Feature disabling '1347 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1348 1349 ''1350 ' No COM1351 sub DisableCOM(strReason)1352 if g_blnDisableCOM = False then1353 LogPrint "Disabled COM components: " & strReason1354 g_blnDisableCOM = True1355 g_strDisableCOM = strReason1356 CfgPrintAssign "VBOX_WITH_MAIN", ""1357 CfgPrintAssign "VBOX_WITH_QTGUI", ""1358 CfgPrintAssign "VBOX_WITH_VBOXSDL", ""1359 CfgPrintAssign "VBOX_WITH_DEBUGGER_GUI", ""1360 end if1361 end sub1362 1363 1364 ''1365 ' No UDPTunnel1366 sub DisableUDPTunnel(strReason)1367 if g_blnDisableUDPTunnel = False then1368 LogPrint "Disabled UDPTunnel network transport: " & strReason1369 g_blnDisableUDPTunnel = True1370 g_strDisableUDPTunnel = strReason1371 CfgPrintAssign "VBOX_WITH_UDPTUNNEL", ""1372 end if1373 end sub1374 1375 1376 ''1377 ' No SDL1378 sub DisableSDL(strReason)1379 if g_blnDisableSDL = False then1380 LogPrint "Disabled SDL frontend: " & strReason1381 g_blnDisableSDL = True1382 g_strDisableSDL = strReason1383 CfgPrintAssign "VBOX_WITH_VBOXSDL", ""1384 end if1385 end sub1386 1387 1388 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1389 ' Tool/Library Locating and Checking '1390 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''1391 1392 ''1393 ' Checks the the path doesn't contain characters the tools cannot deal with.1394 '1395 sub CheckSourcePath1396 dim sPwd1397 1398 sPwd = PathAbsLong(g_strPath) ' Must check the long version.1399 if InStr(1, sPwd, " ") > 0 then1400 MsgError "Source path contains spaces! Please move it. (" & sPwd & ")"1401 end if1402 if InStr(1, sPwd, "$") > 0 then1403 MsgError "Source path contains the '$' char! Please move it. (" & sPwd & ")"1404 end if1405 if InStr(1, sPwd, "%") > 0 then1406 MsgError "Source path contains the '%' char! Please move it. (" & sPwd & ")"1407 end if1408 if InStr(1, sPwd, Chr(10)) > 0 _1409 or InStr(1, sPwd, Chr(13)) > 0 _1410 or InStr(1, sPwd, Chr(9)) > 0 _1411 then1412 MsgError "Source path contains control characters! Please move it. (" & sPwd & ")"1413 end if1414 Print "Source path: OK"1415 end sub1416 1417 1418 ''1419 ' Checks for kBuild - very simple :)1420 '1421 sub CheckForkBuild(strOptkBuild)1422 PrintHdr "kBuild"1423 1424 '1425 ' Check if there is a 'kmk' in the path somewhere without1426 ' any KBUILD_*PATH stuff around.1427 '1428 blnNeedEnvVars = True1429 g_strPathkBuild = strOptkBuild1430 g_strPathkBuildBin = ""1431 if (g_strPathkBuild = "") _1432 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _1433 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _1434 And (Shell("kmk.exe --version", True) = 0) _1435 And (InStr(1,g_strShellOutput, "kBuild Make 0.1") > 0) _1436 And (InStr(1,g_strShellOutput, "KBUILD_PATH") > 0) _1437 And (InStr(1,g_strShellOutput, "KBUILD_BIN_PATH") > 0) then1438 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.1439 'blnNeedEnvVars = False1440 MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _1441 & "deal with that yet and will use the one it ships with. Sorry."1442 end if1443 1444 '1445 ' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.1446 '1447 if g_strPathkBuild = "" then1448 g_strPathkBuild = EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")1449 if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then1450 MsgWarning "Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild & ")"1451 g_strPathkBuild = ""1452 end if1453 1454 if g_strPathkBuild = "" then1455 g_strPathkBuild = g_strPath & "/kBuild"1456 end if1457 end if1458 1459 g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))1460 1461 '1462 ' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).1463 '1464 str = EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")1465 if (str <> "") _1466 And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then1467 EnvPrint "set KBUILD_TYPE=release"1468 EnvSet "KBUILD_TYPE", "release"1469 MsgWarning "Found unknown KBUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."1470 end if1471 1472 str = EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")1473 if (str <> "") _1474 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!1475 EnvPrint "set KBUILD_TARGET=win"1476 EnvSet "KBUILD_TARGET", "win"1477 MsgWarning "Found unknown KBUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."1478 end if1479 1480 str = EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")1481 if (str <> "") _1482 And (InStr(1, "x86|amd64", str) <= 0) then1483 EnvPrint "set KBUILD_TARGET_ARCH=x86"1484 EnvSet "KBUILD_TARGET_ARCH", "x86"1485 MsgWarning "Found unknown KBUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."1486 str = "x86"1487 end if1488 if g_strTargetArch = "" then '' command line parameter --target-arch=x86|amd64 has priority1489 if str <> "" then1490 g_strTargetArch = str1491 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _1492 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then1493 g_strTargetArch = "amd64"1494 else1495 g_strTargetArch = "x86"1496 end if1497 else1498 if InStr(1, "x86|amd64", g_strTargetArch) <= 0 then1499 EnvPrint "set KBUILD_TARGET_ARCH=x86"1500 EnvSet "KBUILD_TARGET_ARCH", "x86"1501 MsgWarning "Unknown --target-arch=" & str &". Setting it to 'x86'."1502 end if1503 end if1504 LogPrint " Target architecture: " & g_strTargetArch & "."1505 Wscript.Echo " Target architecture: " & g_strTargetArch & "."1506 EnvPrint "set KBUILD_TARGET_ARCH=" & g_strTargetArch1507 1508 ' Windows variant of the arch name.1509 g_strTargetArchWin = g_strTargetArch1510 if g_strTargetArchWin = "amd64" then g_strTargetArchWin = "x64"1511 1512 str = EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")1513 ' perhaps a bit pedantic this since this isn't clearly define nor used much...1514 if (str <> "") _1515 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then1516 EnvPrint "set BUILD_TARGET_CPU=i386"1517 EnvSet "KBUILD_TARGET_CPU", "i386"1518 MsgWarning "Found unknown KBUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."1519 end if1520 1521 str = EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")1522 if (str <> "") _1523 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!1524 EnvPrint "set KBUILD_HOST=win"1525 EnvSet "KBUILD_HOST", "win"1526 MsgWarning "Found unknown KBUILD_HOST value '" & str &"' in your environment. Setting it to 'win32'."1527 end if1528 1529 str = EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")1530 if str <> "" then1531 if InStr(1, "x86|amd64", str) <= 0 then1532 str = "x86"1533 MsgWarning "Found unknown KBUILD_HOST_ARCH value '" & str &"' in your environment. Setting it to 'x86'."1534 end if1535 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _1536 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then1537 str = "amd64"1538 else1539 str = "x86"1540 end if1541 LogPrint " Host architecture: " & str & "."1542 Wscript.Echo " Host architecture: " & str & "."1543 EnvPrint "set KBUILD_HOST_ARCH=" & str1544 g_strHostArch = str1545 1546 ' Windows variant of the arch name.1547 g_strHostArchWin = g_strHostArch1548 if g_strHostArchWin = "amd64" then g_strHostArchWin = "x64"1549 1550 1551 str = EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")1552 ' perhaps a bit pedantic this since this isn't clearly define nor used much...1553 if (str <> "") _1554 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then1555 EnvPrint "set KBUILD_HOST_CPU=i386"1556 EnvSet "KBUILD_HOST_CPU", "i386"1557 MsgWarning "Found unknown KBUILD_HOST_CPU value '" & str &"' in your environment. Setting it to 'i386'."1558 end if1559 1560 '1561 ' Determin the location of the kBuild binaries.1562 '1563 if g_strPathkBuildBin = "" then1564 g_strPathkBuildBin = g_strPathkBuild & "/bin/win." & g_strHostArch1565 if FileExists(g_strPathkBuildBin & "/kmk.exe") = False then1566 g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"1567 end if1568 end if1569 g_strPathkBuildBin = UnixSlashes(PathAbs(g_strPathkBuildBin))1570 1571 '1572 ' Perform basic validations of the kBuild installation.1573 '1574 if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _1575 Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _1576 Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then1577 MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _1578 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."1579 exit sub1580 end if1581 if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _1582 Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then1583 MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _1584 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."1585 exit sub1586 end if1587 1588 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True) <> 0) then1589 MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."1590 exit sub1591 end if1592 1593 '1594 ' If KBUILD_DEVTOOLS is set, check that it's pointing to something useful.1595 '1596 str = UnixSlashes(EnvGet("KBUILD_DEVTOOLS"))1597 g_strPathDev = str1598 if str <> "" _1599 and LogDirExists(str & "/bin") _1600 and LogDirExists(str & "/win.amd64/bin") _1601 and LogDirExists(str & "/win.x86/bin") _1602 then1603 LogPrint "Found KBUILD_DEVTOOLS='" & str & "'."1604 elseif str <> "" then1605 MsgWarning "Ignoring bogus KBUILD_DEVTOOLS='" & str &"' in your environment!"1606 g_strPathDev = strNew1607 end if1608 if g_strPathDev = "" then1609 g_strPathDev = UnixSlashes(g_strPath & "/tools")1610 LogPrint "Using KBUILD_DEVTOOLS='" & g_strPathDev & "'."1611 if str <> "" then1612 EnvPrint "set KBUILD_DEVTOOLS=" & g_strPathDev1613 EnvSet "KBUILD_DEVTOOLS", g_strPathDev1614 end if1615 end if1616 1617 '1618 ' Write KBUILD_PATH and updated PATH to the environment script if necessary.1619 '1620 if blnNeedEnvVars = True then1621 EnvPrint "set KBUILD_PATH=" & g_strPathkBuild1622 EnvSet "KBUILD_PATH", g_strPathkBuild1623 1624 if Right(g_strPathkBuildBin, 7) = "win.x86" then1625 EnvPrintCleanup "PATH", DosSlashes(Left(g_strPathkBuildBin, Len(g_strPathkBuildBin) - 7) & "win.amd64"), ";"1626 end if1627 if Right(g_strPathkBuildBin, 9) = "win.amd64" then1628 EnvPrintCleanup "PATH", DosSlashes(Left(g_strPathkBuildBin, Len(g_strPathkBuildBin) - 9) & "win.x86"), ";"1629 end if1630 EnvPrintPrepend "PATH", DosSlashes(g_strPathkBuildBin), ";"1631 EnvPrepend "PATH", g_strPathkBuildBin & ";"1632 end if1633 1634 PrintResult "kBuild", g_strPathkBuild1635 PrintResult "kBuild binaries", g_strPathkBuildBin1636 end sub1637 1638 '' Class we use for detecting VisualC++1639 class VisualCPPState1640 public m_blnFound1641 public m_strPathVC1642 public m_strPathVCCommon1643 public m_strVersion1644 public m_strClVersion1645 public m_blnNewLayout1646 1647 private sub Class_Initialize1648 m_blnFound = False1649 m_strPathVC = ""1650 m_strPathVCCommon = ""1651 m_strVersion = ""1652 m_strClVersion = ""1653 m_blnNewLayout = false1654 end sub1655 1656 public function checkClExe(strClExe)1657 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH.1658 dim strSavedPath, rcExit1659 1660 strSavedPath = EnvGet("PATH")1661 if (m_strPathVCCommon <> "") then1662 EnvAppend "PATH", ";" & m_strPathVCCommon & "/IDE"1663 end if1664 rcExit = Shell(DosSlashes(strClExe), True)1665 EnvSet "PATH", strSavedPath1666 1667 checkClExe = False1668 if rcExit = 0 then1669 ' Extract the ' Version xx.yy.build.zz for arch' bit.1670 dim offVer, offEol, strVer1671 strVer = ""1672 offVer = InStr(1, g_strShellOutput, " Version ")1673 if offVer > 0 then1674 offVer = offVer + Len(" Version ")1675 offEol = InStr(offVer, g_strShellOutput, Chr(13))1676 if offEol > 0 then1677 strVer = Trim(Mid(g_strShellOutput, offVer, offEol - offVer))1678 end if1679 end if1680 1681 ' Check that it's a supported version1682 checkClExe = True1683 if InStr(1, strVer, "16.") = 1 then1684 m_strVersion = "VCC110"1685 elseif InStr(1, strVer, "17.") = 1 then1686 m_strVersion = "VCC111"1687 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer1688 elseif InStr(1, strVer, "18.") = 1 then1689 m_strVersion = "VCC112"1690 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer1691 elseif InStr(1, strVer, "19.0") = 1 then1692 m_strVersion = "VCC140"1693 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer1694 elseif InStr(1, strVer, "19.1") = 1 then1695 m_strVersion = "VCC141"1696 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer1697 elseif InStr(1, strVer, "19.2") = 1 then1698 m_strVersion = "VCC142"1699 else1700 LogPrint "The Visual C++ compiler we found ('" & strClExe & "') isn't in the 10.0-19.2x range (" & strVer & ")."1701 LogPrint "Check the build requirements and select the appropriate compiler version."1702 checkClExe = False1703 exit function1704 end if1705 LogPrint "'" & strClExe & "' = " & m_strVersion & " (" & strVer & ")"1706 else1707 LogPrint "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed (rcExit=" & rcExit & ")."1708 end if1709 end function1710 1711 public function checkInner(strPathVC) ' For the new layout only1712 if m_blnFound = False then1713 if LogDirExists(strPathVC & "/bin") _1714 and LogDirExists(strPathVC & "/lib") _1715 and LogDirExists(strPathVC & "/include") _1716 and LogFileExists(strPathVC, "include/stdarg.h") _1717 and LogFileExists(strPathVC, "lib/x64/libcpmt.lib") _1718 and LogFileExists(strPathVC, "lib/x86/libcpmt.lib") _1719 and LogFileExists(strPathVC, "bin/Host" & g_strHostArchWin & "/" & g_strTargetArchWin & "/cl.exe") _1720 and LogFileExists(strPathVC, "bin/Host" & g_strHostArchWin & "/" & g_strHostArchWin & "/cl.exe") _1721 then1722 LogPrint " => seems okay. new layout."1723 m_blnFound = checkClExe(strPathVC & "/bin/Host" & g_strHostArchWin & "/" & g_strTargetArchWin & "/cl.exe")1724 if m_blnFound then1725 m_strPathVC = strPathVC1726 end if1727 end if1728 end if1729 checkInner = m_blnFound1730 end function1731 1732 public function check(strPathVC, strPathVCommon)1733 if (m_blnFound = False) and (strPathVC <> "") then1734 m_strPathVC = UnixSlashes(PathAbs(strPathVC))1735 m_strPathVCCommon = strPathVCCommon1736 m_strVersion = ""1737 1738 LogPrint "Trying: strPathVC=" & m_strPathVC & " strPathVCCommon=" & m_strPathVCCommon1739 if LogDirExists(m_strPathVC) then1740 ' 15.0+ layout? This is fun because of the multiple CL versions (/tools/msvc/xx.yy.bbbbb/).1741 ' OTOH, the user may have pointed us directly to one of them.1742 if LogDirExists(m_strPathVC & "/Tools/MSVC") then1743 m_blnNewLayout = True1744 LogPrint " => seems okay. new layout."1745 dim arrFolders, i1746 arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "14.2")1747 if UBound(arrFolders) < 0 then arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "14.1")1748 if UBound(arrFolders) < 0 then arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "1")1749 for i = UBound(arrFolders) to LBound(arrFolders) step -11750 if checkInner(m_strPathVC & "/Tools/MSVC/" & arrFolders(i)) then exit for ' modifies m_strPathVC on success1751 next1752 elseif LogDirExists(m_strPathVC & "/bin/HostX64") _1753 or LogDirExists(m_strPathVC & "/bin/HostX86") then1754 checkInner(m_strPathVC)1755 ' 14.0 and older layout?1756 elseif LogFileExists(m_strPathVC, "/bin/cl.exe") then1757 m_blnNewLayout = False1758 if LogFileExists(m_strPathVC, "bin/link.exe") _1759 and LogFileExists(m_strPathVC, "include/string.h") _1760 and LogFileExists(m_strPathVC, "lib/libcmt.lib") _1761 and LogFileExists(m_strPathVC, "lib/msvcrt.lib") _1762 then1763 LogPrint " => seems okay. old layout."1764 m_blnFound = checkClExe(m_strPathVC & "/bin/cl.exe")1765 end if1766 end if1767 end if1768 end if1769 check = m_bldFound1770 end function1771 1772 public function checkProg(strProg)1773 if m_blnFound = False then1774 dim str, i, offNewLayout1775 str = Which(strProg)1776 if str <> "" then1777 LogPrint "checkProg: '" & strProg & "' -> '" & str & "'"1778 if FileExists(PathStripFilename(str) & "/build.exe") then1779 Warning "Ignoring DDK cl.exe (" & str & ")." ' don't know how to deal with this cl.1780 else1781 ' Assume we've got cl.exe from somewhere under the 'bin' directory..1782 m_strPathVC = PathParent(PathStripFilename(str))1783 for i = 1 To 51784 if LogDirExists(m_strPathVC & "/include") then1785 m_strPathVCCommon = PathParent(m_strPathVC) & "/Common7"1786 if DirExists(m_strPathVCCommon) = False then1787 m_strPathVCCommon = ""1788 ' New layout?1789 offNewLayout = InStr(1, LCase(DosSlashes(m_strPathVC)), "\tools\msvc\")1790 if offNewLayout > 0 then m_strPathVC = Left(m_strPathVC, offNewLayout)1791 end if1792 check m_strPathVC, m_strPathVCCommon1793 exit for1794 end if1795 m_strPathVC = PathParent(m_strPathVC)1796 next1797 end if1798 end if1799 end if1800 checkProg = m_bldFound1801 end function1802 1803 public function checkProgFiles(strSubdir)1804 if m_blnFound = False then1805 dim strProgFiles1806 for each strProgFiles in g_arrProgramFiles1807 check strProgFiles & "/" & strSubdir, ""1808 next1809 end if1810 checkProgFiles = m_blnFound1811 end function1812 1813 public function checkRegistry(strValueNm, strVCSubdir, strVCommonSubdir)1814 if m_blnFound = False then1815 dim str, strPrefix, arrPrefixes1816 arrPrefixes = Array("HKLM\SOFTWARE\Wow6432Node\", "HKLM\SOFTWARE\", "HKCU\SOFTWARE\Wow6432Node\", "HKCU\SOFTWARE\")1817 for each strPrefix in arrPrefixes1818 str = RegGetString(strPrefix & strValueNm)1819 if str <> "" then1820 LogPrint "checkRegistry: '" & strPrefix & strValueNm & "' -> '" & str & "'"1821 if check(str & strVCSubdir, str & strVCommonSubdir) = True then1822 exit for1823 end if1824 end if1825 next1826 end if1827 checkRegistry = m_bldFound1828 end function1829 1830 public function checkInternal1831 check g_strPathDev & "/win.amd64/vcc/v14.2", ""1832 check g_strPathDev & "/win.amd64/vcc/v14.1", ""1833 check g_strPathDev & "/win.amd64/vcc/v14.0", ""1834 check g_strPathDev & "/win.amd64/vcc/v10sp1", ""1835 check g_strPathDev & "/win.x86/vcc/v10sp1", ""1836 checkInternal = m_blnFound1837 end function1838 end class1839 1840 1841 ''1842 ' Checks for Visual C++ version 16 (2019), 15 (2017), 14 (2015), 12 (2013), 11 (2012) or 10 (2010).1843 '1844 sub CheckForVisualCPP(strOptVC, strOptVCCommon)1845 PrintHdr "Visual C++"1846 1847 '1848 ' Try find it...1849 '1850 dim objState, strProgFiles1851 set objState = new VisualCPPState1852 objState.check strOptVC, strOptVCCommon1853 if g_blnInternalFirst = True then objState.checkInternal1854 objState.checkProgFiles "Microsoft Visual Studio\2019\BuildTools\VC"1855 objState.checkProgFiles "Microsoft Visual Studio\2019\Professional\VC"1856 objState.checkProgFiles "Microsoft Visual Studio\2019\Community\VC"1857 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\16.0", "VC", "" ' doesn't work.1858 objState.checkProgFiles "Microsoft Visual Studio\2017\BuildTools\VC"1859 objState.checkProgFiles "Microsoft Visual Studio\2017\Professional\VC"1860 objState.checkProgFiles "Microsoft Visual Studio\2017\Community\VC"1861 objState.checkProgFiles "Microsoft Visual Studio\2017\Express\VC"1862 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\15.0", "VC", ""1863 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\14.0", "VC", "Common7"1864 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\12.0", "VC", "Common7" '?1865 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\11.0", "VC", "Common7" '?1866 objState.checkProg "cl.exe"1867 objState.checkRegistry "Microsoft\VisualStudio\10.0\Setup\VS\ProductDir", "VC", "Common7"1868 if g_blnInternalFirst = False then objState.checkInternal1869 1870 if objState.m_blnFound = False then1871 MsgError "Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."1872 exit sub1873 end if1874 g_strPathVCC = objState.m_strPathVC1875 g_strVCCVersion = objState.m_strVersion1876 1877 '1878 ' Ok, emit build config variables.1879 '1880 CfgPrintAssign "VBOX_VCC_TOOL_STEM", objState.m_strVersion1881 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion, g_strPathVCC1882 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion & "X86", "$(PATH_TOOL_" & objState.m_strVersion & ")"1883 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion & "AMD64", "$(PATH_TOOL_" & objState.m_strVersion & ")"1884 1885 if objState.m_strVersion = "VCC100" _1886 or objState.m_strVersion = "VCC110" _1887 or objState.m_strVersion = "VCC120" _1888 or objState.m_strVersion = "VCC140" _1889 then1890 CfgPrintAssign "VBOX_WITH_NEW_VCC", "" '?? for VCC110+1891 else1892 CfgPrintAssign "VBOX_WITH_NEW_VCC", "1"1893 end if1894 PrintResult "Visual C++ " & objState.m_strVersion, g_strPathVCC1895 1896 ' And the env.bat path fix.1897 if objState.m_strPathVCCommon <> "" then1898 EnvPrintAppend "PATH", DosSlashes(objState.m_strPathVCCommon) & "\IDE", ";"1899 end if1900 end sub1901 1902 '' Checks for a platform SDK that works with the compiler1903 sub CheckForPlatformSDK(strOptSDK)1904 dim strPathPSDK, str1905 PrintHdr "Windows Platform SDK (recent)"1906 1907 strPathPSDK = ""1908 1909 ' Check the supplied argument first.1910 str = strOptSDK1911 if str <> "" then1912 if CheckForPlatformSDKSub(str) then strPathPSDK = str1913 end if1914 1915 ' The tools location (first).1916 if strPathPSDK = "" And g_blnInternalFirst then1917 str = g_strPathDev & "/win.x86/sdk/v7.1"1918 if CheckForPlatformSDKSub(str) then strPathPSDK = str1919 end if1920 1921 if strPathPSDK = "" And g_blnInternalFirst then1922 str = g_strPathDev & "/win.x86/sdk/v8.0"1923 if CheckForPlatformSDKSub(str) then strPathPSDK = str1924 end if1925 1926 ' Look for it in the environment1927 str = EnvGet("MSSdk")1928 if strPathPSDK = "" And str <> "" then1929 if CheckForPlatformSDKSub(str) then strPathPSDK = str1930 end if1931 1932 str = EnvGet("Mstools")1933 if strPathPSDK = "" And str <> "" then1934 if CheckForPlatformSDKSub(str) then strPathPSDK = str1935 end if1936 1937 ' Check if there is one installed with the compiler.1938 if strPathPSDK = "" And str <> "" then1939 str = g_strPathVCC & "/PlatformSDK"1940 if CheckForPlatformSDKSub(str) then strPathPSDK = str1941 end if1942 1943 ' Check the registry next (ASSUMES sorting).1944 arrSubKeys = RegEnumSubKeysRVerSorted("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")1945 for each strSubKey in arrSubKeys1946 str = RegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")1947 if strPathPSDK = "" And str <> "" then1948 if CheckForPlatformSDKSub(str) then strPathPSDK = str1949 end if1950 Next1951 arrSubKeys = RegEnumSubKeysRVerSorted("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows")1952 for each strSubKey in arrSubKeys1953 str = RegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")1954 if strPathPSDK = "" And str <> "" then1955 if CheckForPlatformSDKSub(str) then strPathPSDK = str1956 end if1957 Next1958 1959 ' The tools location (post).1960 if (strPathPSDK = "") And (g_blnInternalFirst = False) then1961 str = g_strPathDev & "/win.x86/sdk/v7.1"1962 if CheckForPlatformSDKSub(str) then strPathPSDK = str1963 end if1964 1965 if (strPathPSDK = "") And (g_blnInternalFirst = False) then1966 str = g_strPathDev & "/win.x86/sdk/v8.0"1967 if CheckForPlatformSDKSub(str) then strPathPSDK = str1968 end if1969 1970 ' Give up.1971 if strPathPSDK = "" then1972 MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."1973 exit sub1974 end if1975 1976 '1977 ' Emit the config.1978 '1979 strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))1980 CfgPrintAssign "PATH_SDK_WINPSDK" & g_strVerPSDK, strPathPSDK1981 CfgPrintAssign "VBOX_WINPSDK", "WINPSDK" & g_strVerPSDK1982 1983 PrintResult "Windows Platform SDK", strPathPSDK1984 PrintResultMsg "Windows Platform SDK version", g_strVerPSDK1985 g_strPathPSDK = strPathPSDK1986 end sub1987 1988 '' Checks if the specified path points to a usable PSDK.1989 function CheckForPlatformSDKSub(strPathPSDK)1990 CheckForPlatformSDKSub = False1991 LogPrint "trying: strPathPSDK=" & strPathPSDK1992 if LogFileExists(strPathPSDK, "include/Windows.h") _1993 And LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _1994 And LogFileExists(strPathPSDK, "lib/User32.Lib") _1995 And LogFileExists(strPathPSDK, "bin/rc.exe") _1996 And Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True) <> 0 _1997 then1998 if InStr(1, g_strShellOutput, "Resource Compiler Version 6.2.") > 0 then1999 g_strVerPSDK = "80"2000 CheckForPlatformSDKSub = True2001 elseif InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then2002 g_strVerPSDK = "71"2003 CheckForPlatformSDKSub = True2004 end if2005 end if2006 end function2007 2008 2009 ''2010 ' Checks for a windows 10 SDK (later also WDK).2011 '2012 sub CheckForSDK10(strOptSDK10, strOptSDK10Version)2013 dim strPathSDK10, strSDK10Version, str2014 PrintHdr "Windows 10 SDK/WDK"2015 '' @todo implement strOptSDK10Version2016 2017 '2018 ' Try find the Windows 10 kit.2019 '2020 strSDK10Version = ""2021 strPathSDK10 = CheckForSDK10Sub(strOptSDK10, strSDK10Version)2022 if strPathSDK10 = "" and g_blnInternalFirst = True then strPathSDK10 = CheckForSDK10ToolsSub(strSDK10Version)2023 if strPathSDK10 = "" then2024 str = RegGetString("HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10")2025 strPathSDK10 = CheckForSDK10Sub(str, strSDK10Version)2026 end if2027 if strPathSDK10 = "" then2028 for each str in g_arrProgramFiles2029 strPathSDK10 = CheckForSDK10Sub(str & "/Windows Kits/10", strSDK10Version)2030 if strPathSDK10 <> "" then exit for2031 next2032 end if2033 if strPathSDK10 = "" and g_blnInternalFirst = False then strPathSDK10 = CheckForSDK10ToolsSub()2034 2035 if strPathSDK10 = "" then2036 MsgError "Cannot find a suitable Windows 10 SDK. Check configure.log and the build requirements."2037 exit sub2038 end if2039 2040 '2041 ' Emit the config.2042 '2043 strPathSDK10 = UnixSlashes(PathAbs(strPathSDK10))2044 CfgPrintAssign "PATH_SDK_WINSDK10", strPathSDK102045 CfgPrintAssign "SDK_WINSDK10_VERSION", strSDK10Version2046 2047 PrintResult "Windows 10 SDK", strPathSDK102048 PrintResultMsg "Windows 10 SDK version", strSDK10Version2049 g_strPathSDK10 = strPathSDK102050 end sub2051 2052 '' Checks the tools directory.2053 function CheckForSDK10ToolsSub(ByRef strSDK10Version)2054 dim arrToolsDirs, strToolsDir, arrDirs, strDir2055 CheckForSDK10ToolSub = ""2056 arrToolsDirs = Array(g_strPathDev & "/win." & g_strTargetArch & "/sdk", _2057 g_strPathDev & "/win.x86/sdk", g_strPathDev & "/win.amd64/sdk")2058 for each strToolsDir in arrToolsDirs2059 arrDirs = GetSubdirsStartingWithRSortedVersion(strToolsDir, "v10.")2060 for each strDir in arrDirs2061 CheckForSDK10ToolsSub = CheckForSDK10Sub(strToolsDir & "/" & strDir, strSDK10Version)2062 if CheckForSDK10ToolsSub <> "" then2063 exit function2064 end if2065 next2066 next2067 2068 end function2069 2070 '' Checks if the specified path points to a usable Windows 10 SDK/WDK.2071 function CheckForSDK10Sub(strPathSDK10, ByRef strSDK10Version)2072 CheckForSDK10Sub = ""2073 if strPathSDK10 <> "" then2074 LogPrint "Trying: strPathSDK10=" & strPathSDK102075 if LogDirExists(strPathSDK10) then2076 if LogDirExists(strPathSDK10 & "/Bin") _2077 and LogDirExists(strPathSDK10 & "/Include") _2078 and LogDirExists(strPathSDK10 & "/Lib") _2079 and LogDirExists(strPathSDK10 & "/Redist") _2080 then2081 ' Only testing the highest one, for now. '' @todo incorporate strOptSDK10Version2082 dim arrVersions2083 arrVersions = GetSubdirsStartingWithVerSorted(strPathSDK10 & "/Include", "10.0.")2084 if UBound(arrVersions) >= 0 then2085 dim strVersion2086 strVersion = arrVersions(UBound(arrVersions))2087 LogPrint "Trying version: " & strVersion2088 if LogFileExists(strPathSDK10, "include/" & strVersion & "/um/Windows.h") _2089 and LogFileExists(strPathSDK10, "include/" & strVersion & "/ucrt/malloc.h") _2090 and LogFileExists(strPathSDK10, "include/" & strVersion & "/ucrt/stdio.h") _2091 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/um/" & g_strTargetArchWin & "/kernel32.lib") _2092 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/um/" & g_strTargetArchWin & "/user32.lib") _2093 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/ucrt/" & g_strTargetArchWin & "/libucrt.lib") _2094 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/ucrt/" & g_strTargetArchWin & "/ucrt.lib") _2095 and LogFileExists(strPathSDK10, "bin/" & strVersion & "/" & g_strHostArchWin & "/rc.exe") _2096 and LogFileExists(strPathSDK10, "bin/" & strVersion & "/" & g_strHostArchWin & "/midl.exe") _2097 then2098 if StrComp(strVersion, "10.0.17134.0") >= 0 then2099 strSDK10Version = strVersion2100 CheckForSDK10Sub = strPathSDK102101 else2102 LogPrint "Version " & strVersion & " is too low, minimum: 10.0.17134.0"2103 end if2104 end if2105 else2106 LogPrint "Found no 10.0.* subdirectories under '" & strPathSDK10 & "/Include'!"2107 end if2108 end if2109 end if2110 end if2111 end function2112 2113 2114 ''2115 ' Locating a Windows 7 Driver Kit.2116 '2117 sub CheckForWinDDK(strOptDDK)2118 dim strPathDDK, str, strSubKeys2119 PrintHdr "Windows DDK v7.1"2120 2121 '2122 ' Find the DDK.2123 '2124 strPathDDK = ""2125 ' The specified path.2126 if strPathDDK = "" And strOptDDK <> "" then2127 if CheckForWinDDKSub(strOptDDK, True) then strPathDDK = strOptDDK2128 end if2129 2130 ' The tools location (first).2131 if strPathDDK = "" And g_blnInternalFirst then2132 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"2133 if CheckForWinDDKSub(str, False) then strPathDDK = str2134 end if2135 2136 ' Check the environment2137 str = EnvGet("DDK_INC_PATH")2138 if strPathDDK = "" And str <> "" then2139 str = PathParent(PathParent(str))2140 if CheckForWinDDKSub(str, True) then strPathDDK = str2141 end if2142 2143 str = EnvGet("BASEDIR")2144 if strPathDDK = "" And str <> "" then2145 if CheckForWinDDKSub(str, True) then strPathDDK = str2146 end if2147 2148 ' Some array constants to ease the work.2149 arrSoftwareKeys = array("SOFTWARE", "SOFTWARE\Wow6432Node")2150 arrRoots = array("HKLM", "HKCU")2151 2152 ' Windows 7 WDK.2153 arrLocations = array()2154 for each strSoftwareKey in arrSoftwareKeys2155 for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")2156 for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)2157 str = RegGetString("HKLM\" & strSubKey2 & "\setup-install-location")2158 if str <> "" then2159 arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))2160 end if2161 next2162 next2163 next2164 arrLocations = ArrayRVerSortStrings(arrLocations)2165 2166 ' Check the locations we've gathered.2167 for each str in arrLocations2168 if strPathDDK = "" then2169 if CheckForWinDDKSub(str, True) then strPathDDK = str2170 end if2171 next2172 2173 ' The tools location (post).2174 if (strPathDDK = "") And (g_blnInternalFirst = False) then2175 str = g_strPathDev & "/win.x86/ddk/7600.16385.1"2176 if CheckForWinDDKSub(str, False) then strPathDDK = str2177 end if2178 2179 ' Give up.2180 if strPathDDK = "" then2181 MsgError "Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."2182 exit sub2183 end if2184 2185 '2186 ' Emit the config.2187 '2188 strPathDDK = UnixSlashes(PathAbs(strPathDDK))2189 CfgPrintAssign "PATH_SDK_WINDDK71", strPathDDK2190 2191 PrintResult "Windows DDK v7.1", strPathDDK2192 g_strPathDDK = strPathDDK2193 end sub2194 2195 '' Quick check if the DDK is in the specified directory or not.2196 function CheckForWinDDKSub(strPathDDK, blnCheckBuild)2197 CheckForWinDDKSub = False2198 LogPrint "trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild2199 if LogFileExists(strPathDDK, "inc/api/ntdef.h") _2200 And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _2201 And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _2202 And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _2203 And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _2204 And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _2205 And LogFileExists(strPathDDK, "bin/x86/rc.exe") _2206 then2207 if Not blnCheckBuild then2208 CheckForWinDDKSub = True2209 '' @todo Find better build check.2210 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True) <> 0 _2211 And InStr(1, g_strShellOutput, "Resource Compiler Version 6.1.") > 0 then2212 CheckForWinDDKSub = True2213 end if2214 end if2215 end function2216 2217 2218 ''2219 ' Locating midl.exe2220 '2221 sub CheckForMidl(strOptMidl)2222 dim strMidl2223 PrintHdr "Midl.exe"2224 2225 ' Skip if no COM/ATL.2226 if g_blnDisableCOM then2227 PrintResultMsg "Midl.exe", "Skipped (" & g_strDisableCOM & ")"2228 exit sub2229 end if2230 2231 strMidl = CheckForMidlSub(strOptMidl)2232 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathSDK10 & "/bin/" & g_strHostArchWin & "/Midl.exe")2233 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathSDK10 & "/bin/x86/Midl.exe")2234 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathPSDK & "/bin/Midl.exe")2235 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathVCC & "/Common7/Tools/Bin/Midl.exe")2236 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/" & g_strHostArchWin & "/Midl.exe")2237 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/x86/Midl.exe")2238 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/Midl.exe")2239 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDev & "/win.x86/bin/Midl.exe")2240 if strMidl = "" then2241 PrintResultMsg "Midl.exe", "not found"2242 exit sub2243 end if2244 2245 CfgPrintAssign "VBOX_MAIN_IDL", strMidl2246 PrintResult "Midl.exe", strMidl2247 end sub2248 2249 function CheckForMidlSub(strMidl)2250 CheckForMidlSub = ""2251 if strMidl <> "" then2252 if LogFileExists1(strMidl) then2253 CheckForMidlSub = UnixSlashes(PathAbs(strMidl))2254 end if2255 end if2256 end function2257 2258 2259 ''2260 ' Locating OpenWatcom 1.92261 '2262 sub CheckForOpenWatcom(strOptOpenWatcom)2263 dim strPathOpenWatcom2264 PrintHdr "OpenWatcom"2265 2266 strPathOpenWatcom = CheckForOpenWatcomSub(strOptOpenWatcom)2267 if strPathOpenWatcom = "" and g_blnInternalFirst = True then strPathOpenWatcom = CheckForOpenWatcomToolsSub()2268 if strPathOpenWatcom = "" then strPathOpenWatcom = CheckForOpenWatcomSub(EnvGet("WATCOM"))2269 if strPathOpenWatcom = "" then strPathOpenWatcom = CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe"))))2270 if strPathOpenWatcom = "" then2271 dim arrCandiates, strCandidate2272 arrCandidates = CollectFromProgramItemLinks(GetRef("OpenWatcomProgramItemCallback"), strPathOpenWatcom)2273 for each strCandidate in arrCandidates2274 if strPathOpenWatcom = "" then strPathOpenWatcom = CheckForOpenWatcomSub(strCandidate)2275 next2276 end if2277 if strPathOpenWatcom = "" and g_blnInternalFirst = False then strPathOpenWatcom = CheckForOpenWatcomToolsSub()2278 2279 if strPathOpenWatcom = "" then2280 PrintResultMsg "OpenWatcom", "not found"2281 CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", ""2282 exit sub2283 end if2284 2285 CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", "1"2286 CfgPrintAssign "PATH_TOOL_OPENWATCOM", strPathOpenWatcom2287 PrintResult "OpenWatcom", strPathOpenWatcom2288 end sub2289 2290 function CheckForOpenWatcomToolsSub()2291 dim arrToolsDirs, strToolsDir, arrDirs, strDir2292 arrToolsDirs = Array(g_strPathDev & "/common/openwatcom", _2293 g_strPathDev & "/win." & g_strTargetArch & "/openwatcom", _2294 g_strPathDev & "/win.x86/openwatcom", g_strPathDev & "/win.amd64/openwatcom")2295 for each strToolsDir in arrToolsDirs2296 arrDirs = GetSubdirsStartingWithRSortedVersion(strToolsDir, "v")2297 for each strDir in arrDirs2298 CheckForOpenWatcomToolsSub = CheckForOpenWatcomSub(strToolsDir & "/" & strDir)2299 if CheckForOpenWatcomToolsSub <> "" then2300 exit function2301 end if2302 next2303 next2304 CheckForOpenWatcomToolsSub = ""2305 end function2306 2307 function OpenWatcomProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)2308 dim str, off2309 OpenWatcomProgramItemCallback = ""2310 if cStrings > 1 then2311 str = arrStrings(1)2312 off = InStr(1, str, "\binnt\", vbTextCompare)2313 if off > 0 then2314 OpenWatcomProgramItemCallback = Left(str, off - 1)2315 end if2316 end if2317 end function2318 2319 function CheckForOpenWatcomSub(strPathOpenWatcom)2320 CheckForOpenWatcomSub = ""2321 if strPathOpenWatcom <> "" then2322 LogPrint "Trying: " & strPathOpenWatcom2323 if LogDirExists(strPathOpenWatcom) then2324 if LogDirExists(strPathOpenWatcom & "/binnt") _2325 and LogDirExists(strPathOpenWatcom & "/h") _2326 and LogDirExists(strPathOpenWatcom & "/eddat") _2327 and LogFileExists(strPathOpenWatcom, "binnt/wcc386.exe") _2328 and LogFileExists(strPathOpenWatcom, "binnt/wcc.exe") _2329 and LogFileExists(strPathOpenWatcom, "binnt/wlink.exe") _2330 and LogFileExists(strPathOpenWatcom, "binnt/wcl386.exe") _2331 and LogFileExists(strPathOpenWatcom, "binnt/wcl.exe") _2332 and LogFileExists(strPathOpenWatcom, "binnt/wlib.exe") _2333 and LogFileExists(strPathOpenWatcom, "binnt/wasm.exe") _2334 and LogFileExists(strPathOpenWatcom, "h/stdarg.h") _2335 then2336 '' @todo check the version!2337 CheckForOpenWatcomSub = UnixSlashes(PathAbs(strPathOpenWatcom))2338 end if2339 end if2340 end if2341 end function2342 2343 2344 ''2345 ' Checks for any libSDL binaries.2346 '2347 sub CheckForlibSDL(strOptlibSDL)2348 dim strPathlibSDL, str2349 PrintHdr "libSDL"2350 2351 '2352 ' Try find some SDL library.2353 '2354 2355 ' First, the specific location.2356 strPathlibSDL = ""2357 if (strPathlibSDL = "") And (strOptlibSDL <> "") then2358 if CheckForlibSDLSub(strOptlibSDL) then strPathlibSDL = strOptlibSDL2359 end if2360 2361 ' The tools location (first).2362 if (strPathlibSDL = "") And (g_blnInternalFirst = True) then2363 str = g_strPathDev & "/win." & g_strTargetArch & "/libsdl"2364 if HasSubdirsStartingWith(str, "v") then2365 PrintResult "libSDL", str & "/v* (auto)"2366 exit sub2367 end if2368 end if2369 2370 ' Poke about in the path.2371 if strPathlibSDL = "" then2372 str = WhichEx("LIB", "SDLmain.lib")2373 if str = "" then str = Which("..\lib\SDLmain.lib")2374 if str = "" then str = Which("SDLmain.lib")2375 if str <> "" then2376 str = PathParent(PathStripFilename(str))2377 if CheckForlibSDLSub(str) then strPathlibSDL = str2378 end if2379 end if2380 2381 if strPathlibSDL = "" then2382 str = Which("SDL.dll")2383 if str <> "" then2384 str = PathParent(PathStripFilename(str))2385 if CheckForlibSDLSub(str) then strPathlibSDL = str2386 end if2387 end if2388 2389 ' The tools location (post).2390 if (strPathlibSDL = "") And (g_blnInternalFirst = False) then2391 str = g_strPathDev & "/win." & g_strTargetArch & "/libsdl"2392 if HasSubdirsStartingWith(str, "v") then2393 PrintResult "libSDL", str & "/v* (auto)"2394 exit sub2395 end if2396 end if2397 2398 ' Success?2399 if strPathlibSDL = "" then2400 if strOptlibSDL = "" then2401 MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _2402 & "If still no luck, consult the configure.log and the build requirements."2403 else2404 MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."2405 end if2406 exit sub2407 end if2408 2409 strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))2410 CfgPrintAssign "PATH_SDK_LIBSDL", strPathlibSDL2411 2412 PrintResult "libSDL", strPathlibSDL2413 end sub2414 2415 '' Checks if the specified path points to an usable libSDL or not.2416 function CheckForlibSDLSub(strPathlibSDL)2417 CheckForlibSDLSub = False2418 LogPrint "trying: strPathlibSDL=" & strPathlibSDL2419 if LogFileExists(strPathlibSDL, "lib/SDL.lib") _2420 And LogFileExists(strPathlibSDL, "lib/SDLmain.lib") _2421 And LogFileExists(strPathlibSDL, "lib/SDL.dll") _2422 And LogFileExists(strPathlibSDL, "include/SDL.h") _2423 And LogFileExists(strPathlibSDL, "include/SDL_syswm.h") _2424 And LogFileExists(strPathlibSDL, "include/SDL_version.h") _2425 then2426 CheckForlibSDLSub = True2427 end if2428 end function2429 2430 2431 ''2432 ' Checks for libxml2.2433 '2434 sub CheckForXml2(strOptXml2)2435 dim strPathXml2, str2436 PrintHdr "libxml2"2437 2438 '2439 ' Part of tarball / svn, so we can exit immediately if no path was specified.2440 '2441 if (strOptXml2 = "") then2442 PrintResultMsg "libxml2", "src/lib/libxml2-*"2443 exit sub2444 end if2445 2446 ' Skip if no COM/ATL.2447 if g_blnDisableCOM then2448 PrintResultMsg "libxml2", "Skipped (" & g_strDisableCOM & ")"2449 exit sub2450 end if2451 2452 '2453 ' Try find some xml2 dll/lib.2454 '2455 strPathXml2 = ""2456 if (strPathXml2 = "") And (strOptXml2 <> "") then2457 if CheckForXml2Sub(strOptXml2) then strPathXml2 = strOptXml22458 end if2459 2460 if strPathXml2 = "" then2461 str = Which("libxml2.lib")2462 if str <> "" then2463 str = PathParent(PathStripFilename(str))2464 if CheckForXml2Sub(str) then strPathXml2 = str2465 end if2466 end if2467 2468 ' Success?2469 if strPathXml2 = "" then2470 if strOptXml2 = "" then2471 MsgError "Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _2472 & "If still no luck, consult the configure.log and the build requirements."2473 else2474 MsgError "Can't locate libxml2. Please consult the configure.log and the build requirements."2475 end if2476 exit sub2477 end if2478 2479 strPathXml2 = UnixSlashes(PathAbs(strPathXml2))2480 CfgPrintAssign "SDK_VBOX_LIBXML2_DEFS", "_REENTRANT"2481 CfgPrintAssign "SDK_VBOX_LIBXML2_INCS", strPathXml2 & "/include"2482 CfgPrintAssign "SDK_VBOX_LIBXML2_LIBS", strPathXml2 & "/lib/libxml2.lib"2483 2484 PrintResult "libxml2", strPathXml22485 end sub2486 2487 '' Checks if the specified path points to an usable libxml2 or not.2488 function CheckForXml2Sub(strPathXml2)2489 dim str2490 2491 CheckForXml2Sub = False2492 LogPrint "trying: strPathXml2=" & strPathXml22493 if LogFileExists(strPathXml2, "include/libxml/xmlexports.h") _2494 And LogFileExists(strPathXml2, "include/libxml/xmlreader.h") _2495 then2496 str = LogFindFile(strPathXml2, "bin/libxml2.dll")2497 if str <> "" then2498 if LogFindFile(strPathXml2, "lib/libxml2.lib") <> "" then2499 CheckForXml2Sub = True2500 end if2501 end if2502 end if2503 end function2504 2505 2506 '' Checks for openssl2507 sub CheckForSsl(strOptSsl, bln32Bit)2508 dim strPathSsl, str2509 PrintHdr "openssl"2510 2511 strOpenssl = "openssl"2512 if bln32Bit = True then2513 strOpenssl = "openssl32"2514 end if2515 2516 '2517 ' Part of tarball / svn, so we can exit immediately if no path was specified.2518 '2519 if (strOptSsl = "") then2520 PrintResult strOpenssl, "src/libs/openssl-*"2521 exit sub2522 end if2523 2524 '2525 ' Try find some openssl dll/lib.2526 '2527 strPathSsl = ""2528 if (strPathSsl = "") And (strOptSsl <> "") then2529 if CheckForSslSub(strOptSsl) then strPathSsl = strOptSsl2530 end if2531 2532 if strPathSsl = "" then2533 str = Which("libssl.lib")2534 if str <> "" then2535 str = PathParent(PathStripFilename(str))2536 if CheckForSslSub(str) then strPathSsl = str2537 end if2538 end if2539 2540 ' Success?2541 if strPathSsl = "" then2542 if strOptSsl = "" then2543 MsgError "Can't locate " & strOpenssl & ". " _2544 & "Try specify the path with the --with-" & strOpenssl & "=<path> argument. " _2545 & "If still no luck, consult the configure.log and the build requirements."2546 else2547 MsgError "Can't locate " & strOpenssl & ". " _2548 & "Please consult the configure.log and the build requirements."2549 end if2550 exit sub2551 end if2552 2553 strPathSsl = UnixSlashes(PathAbs(strPathSsl))2554 if bln32Bit = True then2555 CfgPrintAssign "SDK_VBOX_OPENSSL-x86_INCS", strPathSsl & "/include"2556 CfgPrintAssign "SDK_VBOX_OPENSSL-x86_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"2557 CfgPrintAssign "SDK_VBOX_BLD_OPENSSL-x86_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"2558 else2559 CfgPrintAssign "SDK_VBOX_OPENSSL_INCS", strPathSsl & "/include"2560 CfgPrintAssign "SDK_VBOX_OPENSSL_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"2561 CfgPrintAssign "SDK_VBOX_BLD_OPENSSL_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"2562 end if2563 2564 PrintResult strOpenssl, strPathSsl2565 end sub2566 2567 '' Checks if the specified path points to an usable openssl or not.2568 function CheckForSslSub(strPathSsl)2569 2570 CheckForSslSub = False2571 LogPrint "trying: strPathSsl=" & strPathSsl2572 if LogFileExists(strPathSsl, "include/openssl/md5.h") _2573 And LogFindFile(strPathSsl, "lib/libssl.lib") <> "" _2574 then2575 CheckForSslSub = True2576 end if2577 end function2578 2579 2580 ''2581 ' Checks for libcurl2582 '2583 sub CheckForCurl(strOptCurl, bln32Bit)2584 dim strPathCurl, str2585 PrintHdr "libcurl"2586 2587 strCurl = "libcurl"2588 if bln32Bit = True then2589 strCurl = "libcurl32"2590 end if2591 2592 '2593 ' Part of tarball / svn, so we can exit immediately if no path was specified.2594 '2595 if (strOptCurl = "") then2596 PrintResult strCurl, "src/libs/curl-*"2597 exit sub2598 end if2599 2600 '2601 ' Try find some cURL dll/lib.2602 '2603 strPathCurl = ""2604 if (strPathCurl = "") And (strOptCurl <> "") then2605 if CheckForCurlSub(strOptCurl) then strPathCurl = strOptCurl2606 end if2607 2608 if strPathCurl = "" then2609 str = Which("libcurl.lib")2610 if str <> "" then2611 str = PathParent(PathStripFilename(str))2612 if CheckForCurlSub(str) then strPathCurl = str2613 end if2614 end if2615 2616 ' Success?2617 if strPathCurl = "" then2618 if strOptCurl = "" then2619 MsgError "Can't locate " & strCurl & ". " _2620 & "Try specify the path with the --with-" & strCurl & "=<path> argument. " _2621 & "If still no luck, consult the configure.log and the build requirements."2622 else2623 MsgError "Can't locate " & strCurl & ". " _2624 & "Please consult the configure.log and the build requirements."2625 end if2626 exit sub2627 end if2628 2629 strPathCurl = UnixSlashes(PathAbs(strPathCurl))2630 if bln32Bit = True then2631 CfgPrintAssign "SDK_VBOX_LIBCURL-x86_INCS", strPathCurl & "/include"2632 CfgPrintAssign "SDK_VBOX_LIBCURL-x86_LIBS.x86", strPathCurl & "/libcurl.lib"2633 else2634 CfgPrintAssign "SDK_VBOX_LIBCURL_INCS", strPathCurl & "/include"2635 CfgPrintAssign "SDK_VBOX_LIBCURL_LIBS", strPathCurl & "/libcurl.lib"2636 end if2637 2638 PrintResult strCurl, strPathCurl2639 end sub2640 2641 '' Checks if the specified path points to an usable libcurl or not.2642 function CheckForCurlSub(strPathCurl)2643 2644 CheckForCurlSub = False2645 LogPrint "trying: strPathCurl=" & strPathCurl2646 if LogFileExists(strPathCurl, "include/curl/curl.h") _2647 And LogFindFile(strPathCurl, "libcurl.dll") <> "" _2648 And LogFindFile(strPathCurl, "libcurl.lib") <> "" _2649 then2650 CheckForCurlSub = True2651 end if2652 end function2653 2654 2655 ''2656 ' Checks for any Qt5 binaries.2657 '2658 sub CheckForQt(strOptQt5, strOptInfix)2659 dim strPathQt5, strInfixQt5, arrFolders, arrVccInfixes, strVccInfix2660 PrintHdr "Qt5"2661 2662 '2663 ' Try to find the Qt5 installation (user specified path with --with-qt5)2664 '2665 LogPrint "Checking for user specified path of Qt5 ... "2666 strPathQt5 = ""2667 if strOptQt5 <> "" then2668 strPathQt5 = CheckForQt5Sub(UnixSlashes(strOptQt5), strOptInfix, strInfixQt5)2669 end if2670 2671 if strPathQt = "" then2672 '2673 ' Collect links from "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"2674 '2675 ' Typical string list:2676 ' C:\Users\someuser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Qt\5.x.y\MSVC 20zz (64-bit)\Qt 5.x.y (MSVC 20zz 64-bit).lnk2677 ' C:\Windows\System32\cmd.exe2678 ' /A /Q /K E:\qt\installed\5.x.y\msvc20zz_64\bin\qtenv2.bat2679 '2680 dim arrCandidates, strCandidate2681 arrCandidates = CollectFromProgramItemLinks(GetRef("Qt5ProgramItemCallback"), strPathQt5)2682 LogPrint "Testing qtenv2.bat links (" & ArraySize(arrCandidates) & ") ..."2683 2684 ' VC infixes/subdir names to consider (ASSUMES 64bit)2685 if g_strVCCVersion = "VCC142" or g_strVCCVersion = "" then2686 arrVccInfixes = Array("msvc2019_64", "msvc2017_64", "msvc2015_64")2687 elseif g_strVCCVersion = "VCC141" then2688 arrVccInfixes = Array("msvc2017_64", "msvc2015_64", "msvc2019_64")2689 elseif g_strVCCVersion = "VCC140" then2690 arrVccInfixes = Array("msvc2015_64", "msvc2017_64", "msvc2019_64")2691 elseif g_strVCCVersion = "VCC120" then2692 arrVccInfixes = Array("msvc2013_64")2693 elseif g_strVCCVersion = "VCC110" then2694 arrVccInfixes = Array("msvc2012_64")2695 elseif g_strVCCVersion = "VCC100" then2696 arrVccInfixes = Array("msvc2010_64")2697 else2698 MsgFatal "Unexpected VC version: " & g_strVCCVersion2699 arrVccInfixes = Array()2700 end if2701 for each strVccInfix in arrVccInfixes2702 for each strCandidate in arrCandidates2703 if InStr(1, LCase(strCandidate), strVccInfix) > 0 then2704 strPathQt5 = CheckForQt5Sub(strCandidate, strOptInfix, strInfixQt5)2705 if strPathQt5 <> "" then exit for2706 end if2707 next2708 if strPathQt5 <> "" then exit for2709 next2710 end if2711 2712 ' Check the dev tools - prefer ones matching the compiler.2713 if strPathQt5 = "" then2714 LogPrint "Testing tools dir (" & g_strPathDev & "/win." & g_strTargetArch & "/qt/v5*) ..."2715 arrFolders = GetSubdirsStartingWithVerSorted(g_strPathDev & "/win." & g_strTargetArch & "/qt", "v5")2716 arrVccInfixes = Array(LCase(g_strVCCVersion), Left(LCase(g_strVCCVersion), Len(g_strVCCVersion) - 1), "")2717 for each strVccInfix in arrVccInfixes2718 for i = UBound(arrFolders) to LBound(arrFolders) step -12719 if strVccInfix = "" or InStr(1, LCase(arrFolders(i)), strVccInfix) > 0 then2720 strPathQt5 = CheckForQt5Sub(g_strPathDev & "/win." & g_strTargetArch & "/qt/" & arrFolders(i), strOptInfix, strInfixQt5)2721 if strPathQt5 <> "" then exit for2722 end if2723 next2724 if strPathQt5 <> "" then exit for2725 next2726 end if2727 2728 '2729 ' Display the result and output the config.2730 '2731 if strPathQt5 <> "" then2732 PrintResult "Qt5", strPathQt52733 PrintResultMsg "Qt5 infix", strInfixQt52734 CfgPrintAssign "PATH_SDK_QT5", strPathQt52735 CfgPrintAssign "PATH_TOOL_QT5", "$(PATH_SDK_QT5)"2736 CfgPrintAssign "VBOX_PATH_QT", "$(PATH_SDK_QT5)"2737 CfgPrintAssign "VBOX_QT_INFIX", strInfixQt52738 CfgPrintAssign "VBOX_WITH_QT_PAYLOAD", "1"2739 else2740 PrintResultMsg "Qt5", "not found"2741 CfgPrintAssign "VBOX_WITH_QTGUI", ""2742 end if2743 end sub2744 2745 function Qt5ProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)2746 dim str, off2747 Qt5ProgramItemCallback = ""2748 if cStrings >= 3 then2749 str = Trim(arrStrings(UBound(arrStrings)))2750 if LCase(Right(str, Len("\bin\qtenv2.bat"))) = "\bin\qtenv2.bat" _2751 and InStr(1, LCase(str), "\msvc20") > 0 _2752 and InStr(1, str, ":") > 0 _2753 then2754 off = InStr(1, str, ":") - 12755 Qt5ProgramItemCallback = Mid(str, off, Len(str) - off - Len("\bin\qtenv2.bat") + 1)2756 end if2757 end if2758 end function2759 2760 function CheckForQt5Sub(strPathQt5, strOptInfix, ByRef strInfixQt5)2761 CheckForQt5Sub = ""2762 LogPrint "trying: strPathQt5=" & strPathQt52763 2764 if LogFileExists(strPathQt5, "bin/moc.exe") _2765 and LogFileExists(strPathQt5, "bin/uic.exe") _2766 and LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _2767 and LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _2768 and LogFileExists(strPathQt5, "include/QtGui/QImage") _2769 and LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _2770 then2771 ' Infix testing.2772 if LogFileExists(strPathQt5, "lib/Qt5Core.lib") _2773 and LogFileExists(strPathQt5, "lib/Qt5Network.lib") then2774 strInfixQt5 = ""2775 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))2776 elseif LogFileExists(strPathQt5, "lib/Qt5Core" & strOptInfix & ".lib") _2777 and LogFileExists(strPathQt5, "lib/Qt5Network" & strOptInfix & ".lib") then2778 strInfixQt5 = strOptInfix2779 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))2780 elseif LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib") _2781 and LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib") then2782 strInfixQt5 = "VBox"2783 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))2784 end if2785 end if2786 end function2787 2788 2789 ''2790 ' Checks for python.2791 '2792 function CheckForPython(strOptPython)2793 dim strPathPython, arrVersions, strVer, str2794 PrintHdr "Python"2795 CheckForPython = False2796 2797 '2798 ' Locate it.2799 '2800 strPathPython = CheckForPythonSub(strOptPython)2801 if strPathPython = "" then2802 arrVersions = Array("3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6", "3.5", "2.7")2803 for each strVer in arrVersions2804 strPathPython = CheckForPythonSub(RegGetString("HKLM\SOFTWARE\Python\PythonCore\" & strVer & "\InstallPath\"))2805 if strPathPython <> "" then exit for2806 next2807 end if2808 if strPathPython = "" then strPathPython = CheckForPythonSub(PathStripFilename(Which("python.exe")))2809 2810 '2811 ' Output config & result.2812 '2813 CheckForPython = strPathPython <> ""2814 if CheckForPython then2815 CfgPrintAssign "VBOX_BLD_PYTHON", strPathPython2816 PrintResult "Python", strPathPython2817 else2818 PrintResultMsg "Python", "not found"2819 end if2820 end function2821 2822 function CheckForPythonSub(strPathPython)2823 CheckForPythonSub = ""2824 if strPathPython <> "" then2825 if LogFileExists(strPathPython, "python.exe") _2826 and LogDirExists(strPathPython & "/DLLs") _2827 then2828 CheckForPythonSub = UnixSlashes(PathAbs(strPathPython & "/python.exe"))2829 end if2830 end if2831 end function2832 2833 2834 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''2835 ' Main function and usage '2836 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''2837 2838 ''2839 ' Show usage.2840 '2841 sub usage2842 Print "Usage: cscript configure.vbs [options]"2843 Print ""2844 Print "Configuration:"2845 Print " -h, --help Display this."2846 Print " --target-arch=x86|amd64 The target architecture."2847 Print " --continue-on-error Do not stop on errors."2848 Print " --internal-last Check internal tools (tools/win.*) last."2849 Print " --internal-first Check internal tools (tools/win.*) first (default)."2850 Print ""2851 Print "Components:"2852 Print " --disable-COM Disables all frontends and API."2853 Print " --disable-SDL Disables the SDL frontend."2854 Print " --disable-UDPTunnel"2855 Print ""2856 Print "Locations:"2857 Print " --with-kBuild=PATH Where kBuild is to be found."2858 Print " --with-libSDL=PATH Where libSDL is to be found."2859 Print " --with-Qt5=PATH Where Qt5 is to be found."2860 Print " --with-DDK=PATH Where the WDK is to be found."2861 Print " --with-SDK=PATH Where the Windows SDK is to be found."2862 Print " --with-SDK10=PATH Where the Windows 10 SDK/WDK is to be found."2863 Print " --with-VC=PATH Where the Visual C++ compiler is to be found."2864 Print " (Expecting bin, include and lib subdirs.)"2865 Print " --with-VC-Common=PATH Maybe needed for 2015 and older to"2866 Print " locate the Common7 directory."2867 Print " --with-midl=PATH Where midl.exe is to be found."2868 Print " --with-openwatcom=PATH Where OpenWatcom 1.9 is to be found."2869 Print " --with-python=PATH The python to use."2870 Print " --with-libxml2=PATH To use a libxml2 other than the VBox one."2871 Print " --with-openssl=PATH To use an openssl other than the VBox one."2872 Print " --with-openssl32=PATH The 32-bit variant of openssl."2873 Print " --with-libcurl=PATH To use a cURL other than the VBox one."2874 Print " --with-libcurl32=PATH The 32-bit variant of cURL."2875 end sub2876 2877 2878 ''2879 ' The main() like function.2880 '2881 function Main2882 '2883 ' Write the log header and check that we're not using wscript.2884 '2885 LogInit2886 if UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" then2887 Wscript.Echo "This script must be run under CScript."2888 Main = 12889 exit function2890 end if2891 SelfTest2892 2893 '2894 ' Parse arguments.2895 '2896 strOptDDK = ""2897 strOptDXDDK = ""2898 strOptkBuild = ""2899 strOptlibSDL = ""2900 strOptQt5 = ""2901 strOptQt5Infix = ""2902 strOptSDK = ""2903 strOptSDK10 = ""2904 strOptSDK10Version = ""2905 strOptVC = ""2906 strOptVCCommon = ""2907 strOptMidl = ""2908 strOptOpenWatcom = ""2909 strOptXml2 = ""2910 strOptSsl = ""2911 strOptSsl32 = ""2912 strOptCurl = ""2913 strOptCurl32 = ""2914 strOptPython = ""2915 blnOptDisableCOM = False2916 blnOptDisableUDPTunnel = False2917 blnOptDisableSDL = False2918 for i = 1 to Wscript.Arguments.Count2919 dim str, strArg, strPath2920 2921 ' Separate argument and path value2922 str = Wscript.Arguments.item(i - 1)2923 if InStr(1, str, "=") > 0 then2924 strArg = Mid(str, 1, InStr(1, str, "=") - 1)2925 strPath = Mid(str, InStr(1, str, "=") + 1)2926 if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."2927 else2928 strArg = str2929 strPath = ""2930 end if2931 2932 ' Process the argument2933 select case LCase(strArg)2934 ' --with-something:2935 case "--with-ddk"2936 strOptDDK = strPath2937 case "--with-dxsdk"2938 MsgWarning "Ignoring --with-dxsdk (the DirectX SDK is no longer required)."2939 case "--with-kbuild"2940 strOptkBuild = strPath2941 case "--with-libsdl"2942 strOptlibSDL = strPath2943 case "--with-mingw32"2944 ' ignore2945 case "--with-mingw-w64"2946 ' ignore2947 case "--with-qt5"2948 strOptQt5 = strPath2949 case "--with-qt5-infix"2950 strOptQt5Infix = strPath2951 case "--with-sdk"2952 strOptSDK = strPath2953 case "--with-sdk10"2954 strOptSDK10 = strPath2955 case "--with-sdk10-version"2956 strOptSDK10Version = strPath2957 case "--with-vc"2958 strOptVC = strPath2959 case "--with-vc-common"2960 strOptVCCommon = strPath2961 case "--with-vc-express-edition"2962 ' ignore2963 case "--with-w32api"2964 ' ignore2965 case "--with-midl"2966 strOptMidl = strPath2967 case "--with-openwatcom"2968 strOptOpenWatcom = strPath2969 case "--with-libxml2"2970 strOptXml2 = strPath2971 case "--with-openssl"2972 strOptSsl = strPath2973 case "--with-openssl32"2974 strOptSsl32 = strPath2975 case "--with-libcurl"2976 strOptCurl = strPath2977 case "--with-libcurl32"2978 strOptCurl32 = strPath2979 case "--with-python"2980 strOptPython = strPath2981 2982 ' --disable-something/--enable-something2983 case "--disable-com"2984 blnOptDisableCOM = True2985 case "--enable-com"2986 blnOptDisableCOM = False2987 case "--disable-udptunnel"2988 blnOptDisableUDPTunnel = True2989 case "--enable-udptunnel"2990 blnOptDisableUDPTunnel = False2991 case "--disable-sdl"2992 blnOptDisableSDL = True2993 case "--endable-sdl"2994 blnOptDisableSDL = False2995 2996 ' Other stuff.2997 case "--continue-on-error"2998 g_blnContinueOnError = True2999 case "--internal-first"3000 g_blnInternalFirst = True3001 case "--internal-last"3002 g_blnInternalFirst = False3003 case "--target-arch"3004 g_strTargetArch = strPath3005 case "-h", "--help", "-?"3006 usage3007 Main = 03008 exit function3009 case else3010 Wscript.echo "syntax error: Unknown option '" & str &"'."3011 usage3012 Main = 23013 exit function3014 end select3015 next3016 3017 '3018 ' Initialize output files.3019 '3020 CfgInit3021 EnvInit3022 3023 '3024 ' Check that the Shell function is sane.3025 '3026 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"3027 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False) <> 0 then ' The 'E' is missing on purpose (4nt).3028 MsgFatal "shell execution test failed!"3029 end if3030 if g_strShellOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then3031 Print "Shell test Test -> '" & g_strShellOutput & "'"3032 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."3033 end if3034 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""3035 Print "Shell inheritance test: OK"3036 3037 '3038 ' Do the checks.3039 '3040 if blnOptDisableCOM = True then3041 DisableCOM "--disable-com"3042 end if3043 if blnOptDisableUDPTunnel = True then3044 DisableUDPTunnel "--disable-udptunnel"3045 end if3046 CheckSourcePath3047 CheckForkBuild strOptkBuild3048 CheckForWinDDK strOptDDK3049 CheckForVisualCPP strOptVC, strOptVCCommon3050 CheckForPlatformSDK strOptSDK3051 CheckForSDK10 strOptSDK10, strOptSDK10Version3052 CheckForMidl strOptMidl3053 CheckForOpenWatcom strOptOpenWatcom3054 CfgPrintAssign "VBOX_WITH_LIBVPX", "" '' @todo look for libvpx 1.1.0+3055 CfgPrintAssign "VBOX_WITH_LIBOPUS", "" '' @todo look for libopus 1.2.1+3056 3057 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win." & g_strHostArch & "\bin"), ";" '' @todo look for yasm3058 if g_strHostArch = "amd64" then3059 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win.x86\bin"), ";"3060 else3061 EnvPrintCleanup "PATH", DosSlashes(g_strPath & "\tools\win.amd64\bin"), ";"3062 end if3063 if blnOptDisableSDL = True then3064 DisableSDL "--disable-sdl"3065 else3066 CheckForlibSDL strOptlibSDL3067 end if3068 CheckForXml2 strOptXml23069 CheckForSsl strOptSsl, False3070 if g_strTargetArch = "amd64" then3071 ' 32-bit openssl required as well3072 CheckForSsl strOptSsl32, True3073 end if3074 CheckForCurl strOptCurl, False3075 if g_strTargetArch = "amd64" then3076 ' 32-bit Curl required as well3077 CheckForCurl strOptCurl32, True3078 end if3079 CheckForQt strOptQt5, strOptQt5Infix3080 CheckForPython strOptPython3081 3082 Print ""3083 Print "Execute env.bat once before you start to build VBox:"3084 Print ""3085 Print " env.bat"3086 Print " kmk"3087 Print ""3088 if g_rcScript <> 0 then3089 Print "Warning: ignored errors. See above or in configure.log."3090 end if3091 3092 Main = g_rcScript3093 end function3094 3095 '3096 ' What crt0.o typically does:3097 '3098 WScript.Quit(Main())3099
Note:
See TracChangeset
for help on using the changeset viewer.