Changeset 85809 in vbox for trunk/tools/win
- Timestamp:
- Aug 18, 2020 8:56:54 AM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 139966
- Location:
- trunk/tools/win
- Files:
-
- 2 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
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.