3 ' The purpose of this script is to check for all external tools, headers, and
4 ' libraries VBox OSE depends on.
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'.
12 ' Copyright (C) 2006-2023 Oracle and/or its affiliates.
14 ' This file is part of VirtualBox base platform packages, as
15 ' available from https://www.virtualbox.org.
17 ' This program is free software; you can redistribute it and/or
18 ' modify it under the terms of the GNU General Public License
19 ' as published by the Free Software Foundation, in version 3 of the
22 ' This program is distributed in the hope that it will be useful, but
23 ' WITHOUT ANY WARRANTY; without even the implied warranty of
24 ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 ' General Public License for more details.
27 ' You should have received a copy of the GNU General Public License
28 ' along with this program; if not, see <https://www.gnu.org/licenses>.
30 ' SPDX-License-Identifier: GPL-3.0-only
34 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
36 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
39 ' Includes a vbscript file relative to the script.
40 sub IncludeFile(strFilename
)
41 dim objFile
, objFileSys
42 set objFileSys
= WScript
.CreateObject("Scripting.FileSystemObject")
43 dim strPath
: strPath
= objFileSys
.BuildPath(objFileSys
.GetParentFolderName(Wscript
.ScriptFullName
), strFilename
)
44 set objFile
= objFileSys
.openTextFile(strPath
)
45 executeglobal objFile
.readAll()
47 set objFileSys
= nothing
50 IncludeFile
"tools\win\vbscript\helpers.vbs"
53 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
55 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
56 dim g_strPath
, g_strEnvFile
, g_strLogFile
, g_strCfgFile
57 g_strPath
= Left(Wscript
.ScriptFullName
, Len(Wscript
.ScriptFullName
) - Len("\configure.vbs"))
58 g_strEnvFile
= g_strPath
& "\env.bat"
59 g_strCfgFile
= g_strPath
& "\AutoConfig.kmk"
60 g_strLogFile
= g_strPath
& "\configure.log"
61 'g_strTmpFile = g_strPath & "\configure.tmp"
65 dim g_strPathkBuild
, g_strPathkBuildBin
, g_strPathDev
, g_arrPathDev
67 g_strPathkBuildBin
= ""
69 g_arrPathDev
= Array(":placeholder:")
71 dim g_strTargetArch
, g_StrTargetArchWin
73 g_StrTargetArchWin
= ""
75 dim g_strHostArch
, g_strHostArchWin
80 dim g_strPathVCC
, g_strVCCVersion
85 dim g_strPathSDK10
, g_strPathPSDK
, g_strVerPSDK
, g_strPathDDK
92 dim g_blnDisableCOM
, g_strDisableCOM
93 g_blnDisableCOM
= False
96 ' Whether to try the internal stuff first or last.
97 dim g_blnInternalFirst
98 g_blnInternalFirst
= True
100 ' List of program files locations.
101 dim g_arrProgramFiles
102 if EnvGet("ProgramFiles(x86)") <> "" then
103 g_arrProgramFiles
= Array(EnvGet("ProgramFiles"), EnvGet("ProgramFiles(x86)"))
105 g_arrProgramFiles
= Array(EnvGet("ProgramFiles"))
110 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
111 ' Helpers: Logging and Logged operations '
112 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
115 ' Write a log header with some basic info.
117 FileDelete g_strLogFile
118 LogPrint
"# Log file generated by " & Wscript
.ScriptFullName
119 for i
= 1 to WScript
.Arguments
.Count
120 LogPrint
"# Arg #" & i
& ": " & WScript
.Arguments
.Item(i
- 1)
122 if Wscript
.Arguments
.Count
= 0 then
123 LogPrint
"# No arguments given"
125 LogPrint
"# Reconstructed command line: " & GetCommandline()
128 LogPrint
"# Wscript properties:"
129 LogPrint
"# ScriptName: " & Wscript
.ScriptName
130 LogPrint
"# Version: " & Wscript
.Version
131 LogPrint
"# Build: " & Wscript
.BuildVersion
132 LogPrint
"# Name: " & Wscript
.Name
133 LogPrint
"# Full Name: " & Wscript
.FullName
134 LogPrint
"# Path: " & Wscript
.Path
139 LogPrint
"# Environment:"
141 for each strVar
in g_objShell
.Environment("PROCESS")
142 LogPrint
"# " & strVar
149 ' Append text to the log file.
151 FileAppendLine g_strLogFile
, str
152 'Wscript.Echo "dbg: " & str
158 'FileAppendLine g_strLogFile, str
159 'Wscript.Echo "dbg: " & str
164 ' Checks if the file exists and logs failures.
165 function LogFileExists(strPath
, strFilename
)
166 LogFileExists
= FileExists(strPath
& "/" & strFilename
)
167 if LogFileExists
= False then
168 LogPrint
"Testing '" & strPath
& "': " & strFilename
& " not found"
174 ' Checks if the file exists and logs failures.
175 function LogFileExists1(strPath
)
176 LogFileExists1
= FileExists(strPath
)
177 if LogFileExists1
= False then
178 LogPrint
"Testing '" & strPath
& "': file not found"
184 ' Checks if the directory exists and logs failures.
185 function LogDirExists(strPath
)
186 LogDirExists
= DirExists(strPath
)
187 if LogDirExists
= False then
188 LogPrint
"Testing '" & strPath
& "': not found (or not dir)"
194 ' Finds the first file matching the pattern.
195 ' If no file is found, log the failure.
196 function LogFindFile(strPath
, strPattern
)
200 ' Yes, there are some facy database kinda interface to the filesystem
201 ' however, breaking down the path and constructing a usable query is
202 ' too much hassle. So, we'll do it the unix way...
204 if Shell("dir /B """ & DosSlashes(strPath
) & "\" & DosSlashes(strPattern
) & """", True, strOutput
) = 0 _
205 And InStr(1, strOutput
, Chr(13)) > 1 _
207 ' return the first word.
208 LogFindFile
= Left(strOutput
, InStr(1, strOutput
, Chr(13)) - 1)
210 LogPrint
"Testing '" & strPath
& "': " & strPattern
& " not found"
217 ' Finds the first directory matching the pattern.
218 ' If no directory is found, log the failure,
219 ' else return the complete path to the found directory.
220 function LogFindDir(strPath
, strPattern
)
224 ' Yes, there are some facy database kinda interface to the filesystem
225 ' however, breaking down the path and constructing a usable query is
226 ' too much hassle. So, we'll do it the unix way...
229 ' List the alphabetically last names as first entries (with /O-N).
230 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath
) & "\" & DosSlashes(strPattern
) & """", True, strOutput
) = 0 _
231 And InStr(1, strOutput
, Chr(13)) > 1 _
233 ' return the first word.
234 LogFindDir
= strPath
& "/" & Left(strOutput
, InStr(1, strOutput
, Chr(13)) - 1)
236 LogPrint
"Testing '" & strPath
& "': " & strPattern
& " not found"
243 ' Wrapper around RegGetString that logs successes.
244 function LogRegGetString(strName
)
245 LogRegGetString
= RegGetString(strName
)
246 if LogRegGetString
<> "" then LogPrint
"RegGetString(" & strName
& ") -> " & LogRegGetString
250 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
251 ' Helpers: Configuration and Batch Script Writers '
252 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
255 ' Initializes the config file.
257 FileDelete g_strCfgFile
258 CfgPrint
"# -*- Makefile -*-"
260 CfgPrint
"# Build configuration generated by " & GetCommandline()
262 CfgPrintAssign
"VBOX_OSE", "1"
263 CfgPrintAssignRecursive
"VBOX_VCC_WERR", "$(NO_SUCH_VARIABLE)"
268 ' Prints a string to the config file.
270 FileAppendLine g_strCfgFile, str
274 ' Prints a simple assignment to the config file.
275 sub CfgPrintAssign(strVar, strValue)
276 if strValue = "" then
277 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " :="
279 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " := " & strValue
284 ' Prints a recursive assignment to the config file.
285 sub CfgPrintAssignRecursive(strVar, strValue)
286 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " = " & strValue
291 ' Initializes the environment batch script.
293 FileDelete g_strEnvFile
296 EnvPrint
"rem Environment setup script generated by " & GetCommandline()
302 ' Prints a string to the environment batch script.
304 FileAppendLine g_strEnvFile
, str
309 ' Helper for EnvPrintPrepend and EnvPrintAppend.
310 sub EnvPrintCleanup(strEnv
, strValue
, strSep
)
312 FileAppendLine g_strEnvFile
, "set " & strEnv
& "=%" & strEnv
& ":" & strSep
& strValue
& strSep
& "=" & strSep
& "%"
313 cchValueAndSep
= Len(strValue
) + Len(strSep
)
314 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& "%""==""" & strValue
& """ set " & strEnv
& "="
315 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~0," & cchValueAndSep
& "%""==""" & strValue
& strSep
& """ set " & strEnv
& "=%" & strEnv
& ":~" & cchValueAndSep
& "%"
316 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~-" & cchValueAndSep
& "%""==""" & strSep
& strValue
& """ set " & strEnv
& "=%" & strEnv
& ":~0,-" & cchValueAndSep
& "%"
320 '' Use by EnvPrintPrepend to skip ';' stripping.
321 dim g_strPrependCleanEnvVars
324 ' Print a statement prepending strValue to strEnv, removing duplicate values.
325 sub EnvPrintPrepend(strEnv
, strValue
, strSep
)
326 ' Remove old values and any leading separators.
327 EnvPrintCleanup strEnv
, strValue
, strSep
328 if InStr(1, g_strPrependCleanEnvVars
, "|" & strEnv
& "|") = 0 then
329 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~0,1%""==""" & strSep
& """ set " & strEnv
& "=%" & strEnv
& ":~1%"
330 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~0,1%""==""" & strSep
& """ set " & strEnv
& "=%" & strEnv
& ":~1%"
331 g_strPrependCleanEnvVars
= g_strPrependCleanEnvVars
& "|" & strEnv
& "|"
334 FileAppendLine g_strEnvFile
, "set " & strEnv
& "=" & strValue
& strSep
& "%" & strEnv
& "%"
338 '' Use by EnvPrintPrepend to skip ';' stripping.
339 dim g_strAppendCleanEnvVars
342 ' Print a statement appending strValue to strEnv, removing duplicate values.
343 sub EnvPrintAppend(strEnv
, strValue
, strSep
)
344 ' Remove old values and any trailing separators.
345 EnvPrintCleanup strEnv
, strValue
, strSep
346 if InStr(1, g_strAppendCleanEnvVars
, "|" & strEnv
& "|") = 0 then
347 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~-1%""==""" & strSep
& """ set " & strEnv
& "=%" & strEnv
& ":~0,-1%"
348 FileAppendLine g_strEnvFile
, "if ""%" & strEnv
& ":~-1%""==""" & strSep
& """ set " & strEnv
& "=%" & strEnv
& ":~0,-1%"
349 g_strAppendCleanEnvVars
= g_strAppendCleanEnvVars
& "|" & strEnv
& "|"
352 FileAppendLine g_strEnvFile
, "set " & strEnv
& "=%" & strEnv
& "%" & strSep
& strValue
356 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
357 ' Feature disabling '
358 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
362 sub DisableCOM(strReason
)
363 if g_blnDisableCOM
= False then
364 LogPrint
"Disabled COM components: " & strReason
365 g_blnDisableCOM
= True
366 g_strDisableCOM
= strReason
367 CfgPrintAssign
"VBOX_WITH_MAIN", ""
368 CfgPrintAssign
"VBOX_WITH_QTGUI", ""
369 CfgPrintAssign
"VBOX_WITH_VBOXSDL", ""
370 CfgPrintAssign
"VBOX_WITH_DEBUGGER_GUI", ""
377 sub DisableUDPTunnel(strReason
)
378 if g_blnDisableUDPTunnel
= False then
379 LogPrint
"Disabled UDPTunnel network transport: " & strReason
380 g_blnDisableUDPTunnel
= True
381 g_strDisableUDPTunnel
= strReason
382 CfgPrintAssign
"VBOX_WITH_UDPTUNNEL", ""
389 sub DisableSDL(strReason
)
390 if g_blnDisableSDL
= False then
391 LogPrint
"Disabled SDL frontend: " & strReason
392 g_blnDisableSDL
= True
393 g_strDisableSDL
= strReason
394 CfgPrintAssign
"VBOX_WITH_VBOXSDL", ""
399 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
400 ' Tool/Library Locating and Checking '
401 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
404 ' Generic helper for looking for a tools under g_strPathDev.
406 ' The callback function takes the '.../tools/win.arch/tool/version' dir and
407 ' varUser as arguments, returning an non-empty string if it was found suitable.
409 function SearchToolsEx(strTool
, strVerPrefix
, ByRef fnCallback
, ByRef varUser
, ByRef arrToolsDirs
)
410 dim strToolsDir
, arrDirs
, strDir
412 for each strToolsDir
in arrToolsDirs
413 arrDirs
= GetSubdirsStartingWithRVerSorted(strToolsDir
, strVerPrefix
)
414 for each strDir
in arrDirs
415 SearchToolsEx
= fnCallback(strToolsDir
& "/" & strDir
, varUser
)
416 if SearchToolsEx
<> "" then
423 '' Search under g_strPathDev for a tool, target arch only.
424 function SearchTargetTools(strTool
, strVerPrefix
, ByRef fnCallback
, ByRef varUser
)
426 redim arrToolsDirs(ArraySize(g_arrPathDev
) - 1)
427 for i
= 0 to UBound(g_arrPathDev
)
428 arrToolsDirs(i
) = g_arrPathDev(i
) & "/win." & g_strTargetArch
& "/" & strTool
430 SearchTargetTools
= SearchToolsEx(strTool
, strVerPrefix
, fnCallback
, varUser
, arrToolsDirs
)
433 '' Search under g_strPathDev for a tool, target arch and alternative arches.
434 function SearchTargetPlusTools(strTool
, strVerPrefix
, ByRef fnCallback
, ByRef varUser
)
436 redim arrToolsDirs(ArraySize(g_arrPathDev
)*3 - 1)
437 for i
= 0 to UBound(g_arrPathDev
)
438 arrToolsDirs(i
*3 + 0) = g_arrPathDev(i
) & "/win." & g_strTargetArch
& "/" & strTool
439 arrToolsDirs(i
*3 + 1) = g_arrPathDev(i
) & "/win.x86/" & strTool
440 arrToolsDirs(i
*3 + 2) = g_arrPathDev(i
) & "/win.amd64/" & strTool
442 SearchTargetPlusTools
= SearchToolsEx(strTool
, strVerPrefix
, fnCallback
, varUser
, arrToolsDirs
)
445 '' Search under g_strPathDev for a tool, host arch first.
446 function SearchHostTools(strTool
, strVerPrefix
, ByRef fnCallback
, ByRef varUser
)
448 redim arrToolsDirs(ArraySize(g_arrPathDev
) * 3 - 1)
449 for i
= 0 to UBound(g_arrPathDev
)
450 arrToolsDirs(i
*3 + 0) = g_arrPathDev(i
) & "/win." & g_strHostArch
& "/" & strTool
451 arrToolsDirs(i
*3 + 1) = g_arrPathDev(i
) & "/win.x86/" & strTool
452 arrToolsDirs(i
*3 + 2) = g_arrPathDev(i
) & "/win.amd64/" & strTool
454 SearchHostTools
= SearchToolsEx(strTool
, strVerPrefix
, fnCallback
, varUser
, arrToolsDirs
)
457 '' Search under g_strPathDev for a tool, common dir first.
458 function SearchCommonTools(strTool
, strVerPrefix
, ByRef fnCallback
, ByRef varUser
)
460 redim arrToolsDirs(ArraySize(g_arrPathDev
) * 4 - 1)
461 for i
= 0 to UBound(g_arrPathDev
)
462 arrToolsDirs(i
*4 + 0) = g_arrPathDev(i
) & "/win.common/" & strTool
463 arrToolsDirs(i
*4 + 1) = g_arrPathDev(i
) & "/win." & g_strTargetArch
& "/" & strTool
464 arrToolsDirs(i
*4 + 2) = g_arrPathDev(i
) & "/win.x86/" & strTool
465 arrToolsDirs(i
*4 + 3) = g_arrPathDev(i
) & "/win.amd64/" & strTool
467 SearchCommonTools
= SearchToolsEx(strTool
, strVerPrefix
, fnCallback
, varUser
, arrToolsDirs
)
471 ' Checks the the path doesn't contain characters the tools cannot deal with.
476 sPwd
= PathAbsLong(g_strPath
) ' Must check the long version.
477 if InStr(1, sPwd
, " ") > 0 then
478 MsgError
"Source path contains spaces! Please move it. (" & sPwd
& ")"
480 if InStr(1, sPwd
, "$") > 0 then
481 MsgError "Source path contains the
'$' char! Please move it. (" & sPwd & ")"
483 if InStr(1, sPwd
, "%") > 0 then
484 MsgError
"Source path contains the '%' char! Please move it. (" & sPwd
& ")"
486 if InStr(1, sPwd
, Chr(10)) > 0 _
487 or InStr(1, sPwd
, Chr(13)) > 0 _
488 or InStr(1, sPwd
, Chr(9)) > 0 _
490 MsgError
"Source path contains control characters! Please move it. (" & sPwd
& ")"
492 Print
"Source path: OK"
497 ' Checks for kBuild - very simple :)
499 sub CheckForkBuild(strOptkBuild
)
500 dim blnNeedEnvVars
, strOutput
504 ' Check if there is a 'kmk' in the path somewhere without
505 ' any KBUILD_*PATH stuff around.
507 blnNeedEnvVars
= True
508 g_strPathkBuild
= strOptkBuild
509 g_strPathkBuildBin
= ""
510 if (g_strPathkBuild
= "") _
511 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _
512 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _
513 And (Shell("kmk.exe --version", True, strOutput
) = 0) _
514 And (InStr(1,strOutput
, "kBuild Make 0.1") > 0) _
515 And (InStr(1,strOutput
, "KBUILD_PATH") > 0) _
516 And (InStr(1,strOutput
, "KBUILD_BIN_PATH") > 0) then
517 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.
518 'blnNeedEnvVars = False
519 MsgWarning
"You've installed kBuild it seems. configure.vbs hasn't been updated to " _
520 & "deal with that yet and will use the one it ships with. Sorry."
524 ' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.
526 if g_strPathkBuild
= "" then
527 g_strPathkBuild
= EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")
528 if (g_strPathkBuild
<> "") and (FileExists(g_strPathkBuild
& "/footer.kmk") = False) then
529 MsgWarning
"Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild
& ")"
533 if g_strPathkBuild
= "" then
534 g_strPathkBuild
= g_strPath
& "/kBuild"
538 g_strPathkBuild
= UnixSlashes(PathAbs(g_strPathkBuild
))
541 ' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).
543 str
= EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")
545 And (InStr(1, "|release|debug|profile|kprofile", str
) <= 0) then
546 EnvPrint
"set KBUILD_TYPE=release"
547 EnvSet
"KBUILD_TYPE", "release"
548 MsgWarning
"Found unknown KBUILD_TYPE value '" & str
&"' in your environment. Setting it to 'release'."
551 str
= EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")
553 And (InStr(1, "win|win32|win64", str
) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
554 EnvPrint
"set KBUILD_TARGET=win"
555 EnvSet
"KBUILD_TARGET", "win"
556 MsgWarning
"Found unknown KBUILD_TARGET value '" & str
&"' in your environment. Setting it to 'win32'."
559 str
= EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")
561 And (InStr(1, "x86|amd64", str
) <= 0) then
562 EnvPrint
"set KBUILD_TARGET_ARCH=x86"
563 EnvSet
"KBUILD_TARGET_ARCH", "x86"
564 MsgWarning
"Found unknown KBUILD_TARGET_ARCH value '" & str
&"' in your environment. Setting it to 'x86'."
567 if g_strTargetArch
= "" then '' command line parameter --target-arch=x86|amd64 has priority
569 g_strTargetArch
= str
570 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
571 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
572 g_strTargetArch
= "amd64"
574 g_strTargetArch
= "x86"
577 if InStr(1, "x86|amd64", g_strTargetArch
) <= 0 then
578 EnvPrint
"set KBUILD_TARGET_ARCH=x86"
579 EnvSet
"KBUILD_TARGET_ARCH", "x86"
580 MsgWarning
"Unknown --target-arch=" & str
&". Setting it to 'x86'."
583 LogPrint
" Target architecture: " & g_strTargetArch
& "."
584 Wscript
.Echo
" Target architecture: " & g_strTargetArch
& "."
585 EnvPrint
"set KBUILD_TARGET_ARCH=" & g_strTargetArch
587 ' Windows variant of the arch name.
588 g_strTargetArchWin
= g_strTargetArch
589 if g_strTargetArchWin
= "amd64" then g_strTargetArchWin
= "x64"
591 str
= EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")
592 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
594 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str
) <= 0) then
595 EnvPrint
"set BUILD_TARGET_CPU=i386"
596 EnvSet
"KBUILD_TARGET_CPU", "i386"
597 MsgWarning
"Found unknown KBUILD_TARGET_CPU value '" & str
&"' in your environment. Setting it to 'i386'."
600 str
= EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")
602 And (InStr(1, "win|win32|win64", str
) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
603 EnvPrint
"set KBUILD_HOST=win"
604 EnvSet
"KBUILD_HOST", "win"
605 MsgWarning
"Found unknown KBUILD_HOST value '" & str
&"' in your environment. Setting it to 'win32'."
608 str
= EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")
610 if InStr(1, "x86|amd64", str
) <= 0 then
612 MsgWarning
"Found unknown KBUILD_HOST_ARCH value '" & str
&"' in your environment. Setting it to 'x86'."
614 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
615 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
620 LogPrint
" Host architecture: " & str
& "."
621 Wscript
.Echo
" Host architecture: " & str
& "."
622 EnvPrint
"set KBUILD_HOST_ARCH=" & str
625 ' Windows variant of the arch name.
626 g_strHostArchWin
= g_strHostArch
627 if g_strHostArchWin
= "amd64" then g_strHostArchWin
= "x64"
630 str
= EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")
631 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
633 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str
) <= 0) then
634 EnvPrint
"set KBUILD_HOST_CPU=i386"
635 EnvSet
"KBUILD_HOST_CPU", "i386"
636 MsgWarning
"Found unknown KBUILD_HOST_CPU value '" & str
&"' in your environment. Setting it to 'i386'."
640 ' Determin the location of the kBuild binaries.
642 if g_strPathkBuildBin
= "" then
643 g_strPathkBuildBin
= g_strPathkBuild
& "/bin/win." & g_strHostArch
644 if FileExists(g_strPathkBuildBin
& "/kmk.exe") = False then
645 g_strPathkBuildBin
= g_strPathkBuild
& "/bin/win.x86"
648 g_strPathkBuildBin
= UnixSlashes(PathAbs(g_strPathkBuildBin
))
651 ' Perform basic validations of the kBuild installation.
653 if (FileExists(g_strPathkBuild
& "/footer.kmk") = False) _
654 Or (FileExists(g_strPathkBuild
& "/header.kmk") = False) _
655 Or (FileExists(g_strPathkBuild
& "/rules.kmk") = False) then
656 MsgFatal
"Can't find valid kBuild at '" & g_strPathkBuild
& "'. Either there is an " _
657 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
660 if (FileExists(g_strPathkBuildBin
& "/kmk.exe") = False) _
661 Or (FileExists(g_strPathkBuildBin
& "/kmk_ash.exe") = False) then
662 MsgFatal
"Can't find valid kBuild binaries at '" & g_strPathkBuildBin
& "'. Either there is an " _
663 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
667 if (Shell(DosSlashes(g_strPathkBuildBin
& "/kmk.exe") & " --version", True, strOutput
) <> 0) then
668 MsgFatal
"Can't execute '" & g_strPathkBuildBin
& "/kmk.exe --version'. check configure.log for the out."
673 ' If KBUILD_DEVTOOLS is set, check that it's pointing to something useful.
675 str
= UnixSlashes(EnvGet("KBUILD_DEVTOOLS"))
678 and LogDirExists(str
& "/bin") _
679 and LogDirExists(str
& "/win.amd64/bin") _
680 and LogDirExists(str
& "/win.x86/bin") _
682 LogPrint
"Found KBUILD_DEVTOOLS='" & str
& "'."
683 elseif str
<> "" then
684 MsgWarning
"Ignoring bogus KBUILD_DEVTOOLS='" & str
&"' in your environment!"
685 g_strPathDev
= strNew
687 if g_strPathDev
= "" then
688 g_strPathDev
= UnixSlashes(g_strPath
& "/tools")
689 LogPrint
"Using KBUILD_DEVTOOLS='" & g_strPathDev
& "'."
691 EnvPrint
"set KBUILD_DEVTOOLS=" & g_strPathDev
692 EnvSet
"KBUILD_DEVTOOLS", g_strPathDev
695 g_arrPathDev(ArrayFindString(g_arrPathDev
, ":placeholder:")) = g_strPathDev
698 ' Write KBUILD_PATH and updated PATH to the environment script if necessary.
700 if blnNeedEnvVars
= True then
701 EnvPrint
"set KBUILD_PATH=" & g_strPathkBuild
702 EnvSet
"KBUILD_PATH", g_strPathkBuild
704 if Right(g_strPathkBuildBin
, 7) = "win.x86" then
705 EnvPrintCleanup
"PATH", DosSlashes(Left(g_strPathkBuildBin
, Len(g_strPathkBuildBin
) - 7) & "win.amd64"), ";"
707 if Right(g_strPathkBuildBin
, 9) = "win.amd64" then
708 EnvPrintCleanup
"PATH", DosSlashes(Left(g_strPathkBuildBin
, Len(g_strPathkBuildBin
) - 9) & "win.x86"), ";"
710 EnvPrintPrepend
"PATH", DosSlashes(g_strPathkBuildBin
), ";"
711 EnvPrependPathItem
"PATH", g_strPathkBuildBin
, ";"
714 PrintResult
"kBuild", g_strPathkBuild
715 PrintResult
"kBuild binaries", g_strPathkBuildBin
720 ' Checks for Visual C++ version 16 (2019), 15 (2017), 14 (2015), 12 (2013), 11 (2012) or 10 (2010).
722 sub CheckForVisualCPP(strOptVC
, strOptVCCommon
)
723 PrintHdr
"Visual C++"
728 dim objState
, strProgFiles
729 set objState
= new VisualCPPState
730 objState
.check strOptVC
, strOptVCCommon
731 if g_blnInternalFirst
= True then objState
.checkInternal
732 objState
.checkProgItems
"2019"
733 objState
.checkProgFiles
"Microsoft Visual Studio\2019\BuildTools\VC"
734 objState
.checkProgFiles
"Microsoft Visual Studio\2019\Professional\VC"
735 objState
.checkProgFiles
"Microsoft Visual Studio\2019\Community\VC"
736 objState
.checkRegistry
"Microsoft\VisualStudio\SxS\VS7\16.0", "VC", "" ' doesn't work.
737 objState
.checkProgItems
"2017"
738 objState
.checkProgFiles
"Microsoft Visual Studio\2017\BuildTools\VC"
739 objState
.checkProgFiles
"Microsoft Visual Studio\2017\Professional\VC"
740 objState
.checkProgFiles
"Microsoft Visual Studio\2017\Community\VC"
741 objState
.checkProgFiles
"Microsoft Visual Studio\2017\Express\VC"
742 objState
.checkRegistry
"Microsoft\VisualStudio\SxS\VS7\15.0", "VC", ""
743 objState
.checkRegistry
"Microsoft\VisualStudio\SxS\VS7\14.0", "VC", "Common7"
744 objState
.checkRegistry
"Microsoft\VisualStudio\SxS\VS7\12.0", "VC", "Common7" '?
745 objState
.checkRegistry
"Microsoft\VisualStudio\SxS\VS7\11.0", "VC", "Common7" '?
746 objState
.checkProg
"cl.exe"
747 objState
.checkRegistry
"Microsoft\VisualStudio\10.0\Setup\VS\ProductDir", "VC", "Common7"
748 if g_blnInternalFirst
= False then objState
.checkInternal
750 if objState
.m_blnFound
= False then
751 MsgError
"Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."
754 g_strPathVCC
= objState
.m_strPathVC
755 g_strVCCVersion
= objState
.m_strVersion
758 ' Ok, emit build config variables.
760 CfgPrintAssign
"VBOX_VCC_TOOL_STEM", objState
.m_strVersion
761 CfgPrintAssign
"PATH_TOOL_" & objState
.m_strVersion
, g_strPathVCC
762 CfgPrintAssign
"PATH_TOOL_" & objState
.m_strVersion
& "X86", "$(PATH_TOOL_" & objState.m_strVersion & ")"
763 CfgPrintAssign "PATH_TOOL_
" & objState.m_strVersion & "AMD64
", "$(PATH_TOOL_" & objState
.m_strVersion
& ")"
765 if objState
.m_strVersion
= "VCC100" _
766 or objState
.m_strVersion
= "VCC110" _
767 or objState
.m_strVersion
= "VCC120" _
768 or objState
.m_strVersion
= "VCC140" _
770 CfgPrintAssign
"VBOX_WITH_NEW_VCC", "" '?? for VCC110+
772 CfgPrintAssign
"VBOX_WITH_NEW_VCC", "1"
774 PrintResult
"Visual C++ " & objState
.m_strVersion
, g_strPathVCC
776 ' And the env.bat path fix.
777 if objState
.m_strPathVCCommon
<> "" then
778 EnvPrintAppend
"PATH", DosSlashes(objState
.m_strPathVCCommon
) & "\IDE", ";"
782 '' Class we use for detecting Visual C++
786 public m_strPathVCCommon
788 public m_strClVersion
789 public m_blnNewLayout
791 private sub Class_Initialize
794 m_strPathVCCommon
= ""
797 m_blnNewLayout
= false
800 public function checkClExe(strClExe
)
801 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH.
802 dim strSavedPath
, rcExit
, strOutput
804 strSavedPath
= EnvGet("PATH")
805 if (m_strPathVCCommon
<> "") then
806 EnvAppendPathItem
"PATH", m_strPathVCCommon
& "/IDE", ";"
808 rcExit
= Shell(DosSlashes(strClExe
), True, strOutput
)
809 EnvSet
"PATH", strSavedPath
813 ' Extract the ' Version xx.yy.build.zz for arch' bit.
814 dim offVer
, offEol
, strVer
816 offVer
= InStr(1, strOutput
, " Version ")
818 offVer
= offVer
+ Len(" Version ")
819 offEol
= InStr(offVer
, strOutput
, Chr(13))
821 strVer
= Trim(Mid(strOutput
, offVer
, offEol
- offVer
))
825 ' Check that it's a supported version
827 if InStr(1, strVer
, "16.") = 1 then
828 m_strVersion
= "VCC100"
829 elseif InStr(1, strVer
, "17.") = 1 then
830 m_strVersion
= "VCC110"
831 LogPrint
"The Visual C++ compiler ('" & strClExe
& "') version isn't really supported, but may work: " & strVer
832 elseif InStr(1, strVer
, "18.") = 1 then
833 m_strVersion
= "VCC120"
834 LogPrint
"The Visual C++ compiler ('" & strClExe
& "') version isn't really supported, but may work: " & strVer
835 elseif InStr(1, strVer
, "19.0") = 1 then
836 m_strVersion
= "VCC140"
837 LogPrint
"The Visual C++ compiler ('" & strClExe
& "') version isn't really supported, but may work: " & strVer
838 elseif InStr(1, strVer
, "19.1") = 1 then
839 m_strVersion
= "VCC141"
840 LogPrint
"The Visual C++ compiler ('" & strClExe
& "') version isn't really supported, but may work: " & strVer
841 elseif InStr(1, strVer
, "19.2") = 1 then
842 m_strVersion
= "VCC142"
844 LogPrint
"The Visual C++ compiler we found ('" & strClExe
& "') isn't in the 10.0-19.2x range (" & strVer
& ")."
845 LogPrint
"Check the build requirements and select the appropriate compiler version."
849 LogPrint
"'" & strClExe
& "' = " & m_strVersion
& " (" & strVer
& ")"
851 LogPrint
"Executing '" & strClExe
& "' (which we believe to be the Visual C++ compiler driver) failed (rcExit=" & rcExit
& ")."
855 public function checkInner(strPathVC
) ' For the new layout only
856 if m_blnFound
= False then
857 if LogDirExists(strPathVC
& "/bin") _
858 and LogDirExists(strPathVC
& "/lib") _
859 and LogDirExists(strPathVC
& "/include") _
860 and LogFileExists(strPathVC
, "include/stdarg.h") _
861 and LogFileExists(strPathVC
, "lib/x64/libcpmt.lib") _
862 and LogFileExists(strPathVC
, "lib/x86/libcpmt.lib") _
863 and LogFileExists(strPathVC
, "bin/Host" & g_strHostArchWin
& "/" & g_strTargetArchWin
& "/cl.exe") _
864 and LogFileExists(strPathVC
, "bin/Host" & g_strHostArchWin
& "/" & g_strHostArchWin
& "/cl.exe") _
866 LogPrint
" => seems okay. new layout."
867 m_blnFound
= checkClExe(strPathVC
& "/bin/Host" & g_strHostArchWin
& "/" & g_strTargetArchWin
& "/cl.exe")
869 m_strPathVC
= strPathVC
873 checkInner
= m_blnFound
876 public function check(strPathVC
, strPathVCommon
)
877 if (m_blnFound
= False) and (strPathVC
<> "") then
878 m_strPathVC
= UnixSlashes(PathAbs(strPathVC
))
879 m_strPathVCCommon
= strPathVCCommon
882 LogPrint
"Trying: strPathVC=" & m_strPathVC
& " strPathVCCommon=" & m_strPathVCCommon
883 if LogDirExists(m_strPathVC
) then
884 ' 15.0+ layout? This is fun because of the multiple CL versions (/tools/msvc/xx.yy.bbbbb/).
885 ' OTOH, the user may have pointed us directly to one of them.
886 if LogDirExists(m_strPathVC
& "/Tools/MSVC") then
887 m_blnNewLayout
= True
888 LogPrint
" => seems okay. new layout."
890 arrFolders
= GetSubdirsStartingWithVerSorted(m_strPathVC
& "/Tools/MSVC", "14.2")
891 if UBound(arrFolders
) < 0 then arrFolders
= GetSubdirsStartingWithVerSorted(m_strPathVC
& "/Tools/MSVC", "14.1")
892 if UBound(arrFolders
) < 0 then arrFolders
= GetSubdirsStartingWithVerSorted(m_strPathVC
& "/Tools/MSVC", "1")
893 for i
= UBound(arrFolders
) to LBound(arrFolders
) step
-1
894 if checkInner(m_strPathVC
& "/Tools/MSVC/" & arrFolders(i
)) then exit for ' modifies m_strPathVC on success
896 elseif LogDirExists(m_strPathVC
& "/bin/HostX64") _
897 or LogDirExists(m_strPathVC
& "/bin/HostX86") then
898 checkInner(m_strPathVC
)
899 ' 14.0 and older layout?
900 elseif LogFileExists(m_strPathVC
, "/bin/cl.exe") then
901 m_blnNewLayout
= False
902 if LogFileExists(m_strPathVC
, "bin/link.exe") _
903 and LogFileExists(m_strPathVC
, "include/string.h") _
904 and LogFileExists(m_strPathVC
, "lib/libcmt.lib") _
905 and LogFileExists(m_strPathVC
, "lib/msvcrt.lib") _
907 LogPrint
" => seems okay. old layout."
908 m_blnFound
= checkClExe(m_strPathVC
& "/bin/cl.exe")
916 public function checkProg(strProg
)
917 if m_blnFound
= False then
918 dim str
, i
, offNewLayout
921 LogPrint
"checkProg: '" & strProg
& "' -> '" & str
& "'"
922 if FileExists(PathStripFilename(str
) & "/build.exe") then
923 Warning
"Ignoring DDK cl.exe (" & str
& ")." ' don't know how to deal with this cl.
925 ' Assume we've got cl.exe from somewhere under the 'bin' directory..
926 m_strPathVC
= PathParent(PathStripFilename(str
))
928 if LogDirExists(m_strPathVC
& "/include") then
929 m_strPathVCCommon
= PathParent(m_strPathVC
) & "/Common7"
930 if DirExists(m_strPathVCCommon
) = False then
931 m_strPathVCCommon
= ""
933 offNewLayout
= InStr(1, LCase(DosSlashes(m_strPathVC
)), "\tools\msvc\")
934 if offNewLayout
> 0 then m_strPathVC
= Left(m_strPathVC
, offNewLayout
)
936 check m_strPathVC
, m_strPathVCCommon
939 m_strPathVC
= PathParent(m_strPathVC
)
944 checkProg
= m_bldFound
947 public function checkProgFiles(strSubdir
)
948 if m_blnFound
= False then
950 for each strProgFiles
in g_arrProgramFiles
951 check strProgFiles
& "/" & strSubdir
, ""
954 checkProgFiles
= m_blnFound
957 public function checkRegistry(strValueNm
, strVCSubdir
, strVCommonSubdir
)
958 if m_blnFound
= False then
959 dim str
, strPrefix
, arrPrefixes
960 arrPrefixes
= Array("HKLM\SOFTWARE\Wow6432Node\", "HKLM\SOFTWARE\", "HKCU\SOFTWARE\Wow6432Node\", "HKCU\SOFTWARE\")
961 for each strPrefix
in arrPrefixes
962 str
= LogRegGetString(strPrefix
& strValueNm
)
964 LogPrint
"checkRegistry: '" & strPrefix
& strValueNm
& "' -> '" & str
& "'"
965 if check(str
& strVCSubdir
, str
& strVCommonSubdir
) = True then
971 checkRegistry
= m_bldFound
974 public function checkProgItems(strVersionYear
)
975 if m_blnFound
= False then
977 for each strCandidate
in CollectFromProgramItemLinks(GetRef("VisualCPPCallback"), strVersionYear
)
978 check strCandidate
, ""
981 checkProgItems
= m_blnFound
984 public function checkInternal
986 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.amd64/vcc/v14.2", "" : next
987 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.amd64/vcc/v14.2", "" : next
988 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.amd64/vcc/v14.1", "" : next
989 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.amd64/vcc/v14.0", "" : next
990 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.amd64/vcc/v10sp1", "" : next
991 for each strPathDev
in g_arrPathDev
: check strPathDev
& "/win.x86/vcc/v10sp1", "" : next
992 checkInternal
= m_blnFound
996 ' See checkProgItems()
997 function VisualCPPCallback(ByRef arrStrings
, cStrings
, ByRef strVersionYear
)
998 VisualCPPCallback
= ""
999 ' We're looking for items with three strings like this:
1000 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019.lnk
1001 ' C:\Windows\system32\cmd.exe
1002 ' /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
1003 if cStrings
>= 3 then
1004 if InStr(1, arrStrings(0), strVersionYear
) > 0 then
1005 dim strTail
: strTail
= "\Auxiliary\Build\vcvars64.bat"""
1006 dim str
: str
= arrStrings(UBound(arrStrings
))
1007 if StrComp(Right(str
, Len(strTail
)), strTail
, vbTextCompare
) = 0 then
1008 dim offColon
: offColon
= InStr(1, str
, ":")
1009 if offColon
> 1 then
1010 VisualCPPCallback
= Mid(str
, offColon
- 1, Len(str
) - (offColon
- 2) - Len(strTail
))
1019 ' Checks for a windows 10 SDK (later also WDK).
1021 sub CheckForSDK10(strOptSDK10
, strOptSDK10Version
)
1022 dim strPathSDK10
, strSDK10Version
, str
1023 PrintHdr
"Windows 10 SDK/WDK"
1024 '' @todo implement strOptSDK10Version
1027 ' Try find the Windows 10 kit.
1029 strSDK10Version
= ""
1030 strPathSDK10
= CheckForSDK10Sub(strOptSDK10
, strSDK10Version
)
1031 if strPathSDK10
= "" and g_blnInternalFirst
= true then
1032 strPathSDK10
= SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version
)
1035 if strPathSDK10
= "" then
1036 str
= LogRegGetString("HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10")
1037 strPathSDK10
= CheckForSDK10Sub(str
, strSDK10Version
)
1039 if strPathSDK10
= "" then
1040 for each str
in g_arrProgramFiles
1041 strPathSDK10
= CheckForSDK10Sub(str
& "/Windows Kits/10", strSDK10Version
)
1042 if strPathSDK10
<> "" then exit for
1045 if strPathSDK10
= "" and g_blnInternalFirst
= true then
1046 strPathSDK10
= SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version
)
1049 if strPathSDK10
= "" then
1050 MsgError
"Cannot find a suitable Windows 10 SDK. Check configure.log and the build requirements."
1057 strPathSDK10
= UnixSlashes(PathAbs(strPathSDK10
))
1058 CfgPrintAssign
"PATH_SDK_WINSDK10", strPathSDK10
1059 CfgPrintAssign
"SDK_WINSDK10_VERSION", strSDK10Version
1061 PrintResult
"Windows 10 SDK", strPathSDK10
1062 PrintResultMsg
"Windows 10 SDK version", strSDK10Version
1063 g_strPathSDK10
= strPathSDK10
1066 '' Checks if the specified path points to a usable Windows 10 SDK/WDK.
1067 function CheckForSDK10Sub(strPathSDK10
, ByRef strSDK10Version
)
1068 CheckForSDK10Sub
= ""
1069 if strPathSDK10
<> "" then
1070 LogPrint
"Trying: strPathSDK10=" & strPathSDK10
1071 if LogDirExists(strPathSDK10
) then
1072 if LogDirExists(strPathSDK10
& "/Bin") _
1073 and LogDirExists(strPathSDK10
& "/Include") _
1074 and LogDirExists(strPathSDK10
& "/Lib") _
1075 and LogDirExists(strPathSDK10
& "/Redist") _
1077 ' Only testing the highest one, for now. '' @todo incorporate strOptSDK10Version
1079 arrVersions
= GetSubdirsStartingWithVerSorted(strPathSDK10
& "/Include", "10.0.")
1080 if UBound(arrVersions
) >= 0 then
1082 strVersion
= arrVersions(UBound(arrVersions
))
1083 LogPrint
"Trying version: " & strVersion
1084 if LogFileExists(strPathSDK10
, "include/" & strVersion
& "/um/Windows.h") _
1085 and LogFileExists(strPathSDK10
, "include/" & strVersion
& "/ucrt/malloc.h") _
1086 and LogFileExists(strPathSDK10
, "include/" & strVersion
& "/ucrt/stdio.h") _
1087 and LogFileExists(strPathSDK10
, "lib/" & strVersion
& "/um/" & g_strTargetArchWin
& "/kernel32.lib") _
1088 and LogFileExists(strPathSDK10
, "lib/" & strVersion
& "/um/" & g_strTargetArchWin
& "/user32.lib") _
1089 and LogFileExists(strPathSDK10
, "lib/" & strVersion
& "/ucrt/" & g_strTargetArchWin
& "/libucrt.lib") _
1090 and LogFileExists(strPathSDK10
, "lib/" & strVersion
& "/ucrt/" & g_strTargetArchWin
& "/ucrt.lib") _
1091 and LogFileExists(strPathSDK10
, "bin/" & strVersion
& "/" & g_strHostArchWin
& "/rc.exe") _
1092 and LogFileExists(strPathSDK10
, "bin/" & strVersion
& "/" & g_strHostArchWin
& "/midl.exe") _
1094 if StrComp(strVersion
, "10.0.17134.0") >= 0 then
1095 strSDK10Version
= strVersion
1096 CheckForSDK10Sub
= strPathSDK10
1098 LogPrint
"Version " & strVersion
& " is too low, minimum: 10.0.17134.0"
1102 LogPrint
"Found no 10.0.* subdirectories under '" & strPathSDK10
& "/Include'!"
1111 ' Locating a Windows 7 Driver Kit.
1113 sub CheckForWinDDK(strOptDDK
)
1114 dim strPathDDK
, str
, strSubKeys
1115 PrintHdr
"Windows DDK v7.1"
1120 strPathDDK
= CheckForWinDDKSub(strOptDDK
, True)
1122 ' The tools location (first).
1123 if strPathDDK
= "" and g_blnInternalFirst
= true then
1124 for each str
in g_arrPathDev
1125 strPathDDK
= CheckForWinDDKSub(str
& "/win.x86/ddk/7600.16385.1", False)
1126 if strPathDDK
<> "" then exit for
1130 ' Check the environment
1131 if strPathDDK
= "" then strPathDDK
= CheckForWinDDKSub(PathParent(PathParent(EnvGet("DDK_INC_PATH"))), True)
1132 if strPathDDK
= "" then strPathDDK
= CheckForWinDDKSub(EnvGet("BASEDIR"), True)
1134 ' Some array constants to ease the work.
1135 arrSoftwareKeys
= array("SOFTWARE", "SOFTWARE\Wow6432Node")
1136 arrRoots
= array("HKLM", "HKCU")
1139 if strPathDDK
= "" then
1140 arrLocations
= array()
1141 for each strSoftwareKey
in arrSoftwareKeys
1142 for each strSubKey
in RegEnumSubKeysFull("HKLM", strSoftwareKey
& "\Microsoft\KitSetup\configured-kits")
1143 for each strSubKey2
in RegEnumSubKeysFull("HKLM", strSubKey
)
1144 str
= LogRegGetString("HKLM\" & strSubKey2
& "\setup-install-location")
1146 arrLocations
= ArrayAppend(arrLocations
, PathAbsLong(str
))
1151 arrLocations
= ArrayRVerSortStrings(arrLocations
)
1153 ' Check the locations we've gathered.
1154 for each str
in arrLocations
1155 strPathDDK
= CheckForWinDDKSub(str
, True)
1156 if strPathDDK
<> "" then exit for
1160 ' The tools location (post).
1161 if strPathDDK
= "" and g_blnInternalFirst
= false then
1162 for each str
in g_arrPathDev
1163 strPathDDK
= CheckForWinDDKSub(str
& "/win.x86/ddk/7600.16385.1", False)
1164 if strPathDDK
<> "" then exit for
1169 if strPathDDK
= "" then
1170 MsgError
"Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."
1177 strPathDDK
= UnixSlashes(PathAbs(strPathDDK
))
1178 CfgPrintAssign
"PATH_SDK_WINDDK71", strPathDDK
1180 PrintResult
"Windows DDK v7.1", strPathDDK
1181 g_strPathDDK
= strPathDDK
1184 '' Quick check if the DDK is in the specified directory or not.
1185 function CheckForWinDDKSub(strPathDDK
, blnCheckBuild
)
1186 CheckForWinDDKSub
= ""
1187 if strPathDDK
<> "" then
1189 LogPrint
"Trying: strPathDDK=" & strPathDDK
& " blnCheckBuild=" & blnCheckBuild
1190 if LogFileExists(strPathDDK
, "inc/api/ntdef.h") _
1191 And LogFileExists(strPathDDK
, "lib/win7/i386/int64.lib") _
1192 And LogFileExists(strPathDDK
, "lib/wlh/i386/int64.lib") _
1193 And LogFileExists(strPathDDK
, "lib/wnet/i386/int64.lib") _
1194 And LogFileExists(strPathDDK
, "lib/wxp/i386/int64.lib") _
1195 And Not LogFileExists(strPathDDK
, "lib/win8/i386/int64.lib") _
1196 And LogFileExists(strPathDDK
, "bin/x86/rc.exe") _
1198 if Not blnCheckBuild
then
1199 CheckForWinDDKSub
= strPathDDK
1200 '' @todo Find better build check.
1201 elseif Shell("""" & DosSlashes(strPathDDK
& "/bin/x86/rc.exe") & """" , True, strOutput
) <> 0 _
1202 and InStr(1, strOutput
, "Resource Compiler Version 6.1.") > 0 _
1204 CheckForWinDDKSub
= strPathDDK
1214 sub CheckForMidl(strOptMidl
)
1218 ' Skip if no COM/ATL.
1219 if g_blnDisableCOM
then
1220 PrintResultMsg
"Midl.exe", "Skipped (" & g_strDisableCOM
& ")"
1224 strMidl
= CheckForMidlSub(strOptMidl
)
1225 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathSDK10
& "/bin/" & g_strHostArchWin
& "/Midl.exe")
1226 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathSDK10
& "/bin/x86/Midl.exe")
1227 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathPSDK
& "/bin/Midl.exe")
1228 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathVCC
& "/Common7/Tools/Bin/Midl.exe")
1229 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathDDK
& "/bin/" & g_strHostArchWin
& "/Midl.exe")
1230 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathDDK
& "/bin/x86/Midl.exe")
1231 if strMidl
= "" then strMidl
= CheckForMidlSub(g_strPathDDK
& "/bin/Midl.exe")
1232 if strMidl
= "" then
1233 for each str
in g_arrPathDev
1234 strMidl
= CheckForMidlSub(str
& "/win." & g_strHostArchWin
& "/bin/Midl.exe")
1235 if strMidl
<> "" then exit for
1236 strMidl
= CheckForMidlSub(str
& "/win.x86/bin/Midl.exe")
1237 if strMidl
<> "" then exit for
1241 if strMidl
= "" then
1242 PrintResultMsg
"Midl.exe", "not found"
1244 CfgPrintAssign
"VBOX_MAIN_IDL", strMidl
1245 PrintResult
"Midl.exe", strMidl
1249 function CheckForMidlSub(strMidl
)
1250 CheckForMidlSub
= ""
1251 if strMidl
<> "" then
1252 if LogFileExists1(strMidl
) then
1253 CheckForMidlSub
= UnixSlashes(PathAbs(strMidl
))
1262 sub CheckForYasm(strOptYasm
)
1263 dim strPathYasm
, strVersion
1267 strPathYasm
= CheckForYasmSub(strOptYasm
, strVersion
)
1268 if strPathYasm
= "" then strPathYasm
= CheckForYasmSub(PathStripFilename(strOptYasm
), strVersion
)
1269 if strPathYasm
= "" and g_blnInternalFirst
= true then
1270 strPathYasm
= SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion
)
1272 if strPathYasm
= "" then strPathYasm
= CheckForYasmSub(PathStripFilename(Which("yasm.exe")), strVersion
)
1273 if strPathYasm
= "" and g_blnInternalFirst
= false then
1274 strPathYasm
= SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion
)
1277 if strPathYasm
= "" then
1278 PrintResultMsg
"yasm", "not found"
1279 MsgError
"Unable to locate yasm!"
1281 CfgPrintAssign
"PATH_TOOL_YASM", strPathYasm
1282 PrintResult
"yasm v" & strVersion
, strPathYasm
1286 function CheckForYasmSub(strPathYasm
, ByRef strVersion
)
1287 CheckForYasmSub
= ""
1288 if strPathYasm
<> "" then
1289 if LogFileExists(strPathYasm
, "yasm.exe") then
1291 if Shell("""" & DosSlashes(strPathYasm
& "\yasm.exe") & """ --version", True, strOutput
) = 0 then
1292 dim strPreamble
: strPreamble
= "yasm"
1293 dim strVer
: strVer
= Trim(StrGetFirstLine(strOutput
))
1294 if StrComp(Left(strVer
, Len(strPreamble
)), strPreamble
, vbTextCompare
) = 0 then
1295 strVersion
= StrGetFirstWord(Trim(Mid(strVer
, Len(strPreamble
) + 1)))
1296 if StrVersionCompare(strVersion
, "1.3.0") >= 0 and strVersion
<> "" then
1297 LogPrint
"Found yasm version: " & strVer
1298 CheckForYasmSub
= UnixSlashes(PathAbs(strPathYasm
))
1300 LogPrint
"yasm version is older than 1.3.0: " & strVersion
1303 LogPrint
"Not yasm: " & strVer
1314 sub CheckForNasm(strOptNasm
)
1315 dim strPathNasm
, strVersion
1318 strPathNasm
= CheckForNasmSub(strOptNasm
, strVersion
)
1319 if strPathNasm
= "" then strPathNasm
= CheckForNasmSub(PathStripFilename(strOptNasm
), strVersion
)
1320 if strPathNasm
= "" and g_blnInternalFirst
= true then
1321 strPathNasm
= SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion
)
1323 if strPathNasm
= "" then strPathNasm
= CheckForNasmSub(LogRegGetString("HKLM\SOFTWARE\nasm\"), strVersion
)
1324 if strPathNasm
= "" then strPathNasm
= CheckForNasmSub(LogRegGetString("HKCU\SOFTWARE\nasm\"), strVersion
)
1325 if strPathNasm
= "" then
1326 for each strCandidate
in CollectFromProgramItemLinks(GetRef("NasmProgramItemCallback"), strPathNasm
)
1327 strPathNasm
= CheckForNasmSub(strCandidate
, strVersion
)
1330 if strPathNasm
= "" then strPathNasm
= CheckForNasmSub(PathStripFilename(Which("nasm.exe")), strVersion
)
1331 if strPathNasm
= "" and g_blnInternalFirst
= false then
1332 strPathNasm
= SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion
)
1335 if strPathNasm
= "" then
1336 PrintResultMsg
"nasm", "not found"
1338 CfgPrintAssign
"PATH_TOOL_NASM", strPathNasm
1339 PrintResult
"nasm v" & strVersion
, strPathNasm
1343 function NasmProgramItemCallback(ByRef arrStrings
, cStrings
, ByRef strUnused
)
1345 NasmProgramItemCallback
= ""
1346 if cStrings
> 1 then
1348 off
= InStr(1, str
, "\nasm.exe", vbTextCompare
)
1350 NasmProgramItemCallback
= Left(str
, off
- 1)
1355 function CheckForNasmSub(strPathNasm
, ByRef strVersion
)
1356 CheckForNasmSub
= ""
1357 if strPathNasm
<> "" then
1358 if LogFileExists(strPathNasm
, "nasm.exe") then
1360 if Shell("""" & DosSlashes(strPathNasm
& "\nasm.exe") & """ -version", True, strOutput
) = 0 then
1361 dim strPreamble
: strPreamble
= "NASM version"
1362 dim strVer
: strVer
= Trim(StrGetFirstLine(strOutput
))
1363 if StrComp(Left(strVer
, Len(strPreamble
)), strPreamble
, vbTextCompare
) = 0 then
1364 strVersion
= StrGetFirstWord(Trim(Mid(strVer
, Len(strPreamble
) + 1)))
1365 if StrVersionCompare(strVersion
, "2.12.0") >= 0 and strVersion
<> "" then
1366 LogPrint
"Found nasm version: " & strVersion
1367 CheckForNasmSub
= UnixSlashes(PathAbs(strPathNasm
))
1369 LogPrint
"nasm version is older than 2.12.0: " & strVersion
1372 LogPrint
"Not nasm: " & strVer
1381 ' Locating OpenWatcom 1.9
1383 sub CheckForOpenWatcom(strOptOpenWatcom
)
1384 dim strPathOW
, strCandidate
, strVersion
1385 PrintHdr
"OpenWatcom"
1387 strPathOW
= CheckForOpenWatcomSub(strOptOpenWatcom
, strVersion
)
1388 if strPathOW
= "" and g_blnInternalFirst
= true then
1389 strPathOW
= SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion
)
1391 if strPathOW
= "" then
1392 for each strCandidate
in CollectFromProgramItemLinks(GetRef("OpenWatcomProgramItemCallback"), strPathOW
)
1393 if strPathOW
= "" then strPathOW
= CheckForOpenWatcomSub(strCandidate
, strVersion
)
1396 if strPathOW
= "" then strPathOW
= CheckForOpenWatcomSub(EnvGet("WATCOM"), strVersion
)
1397 if strPathOW
= "" then strPathOW
= CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe"))), strVersion
)
1398 if strPathOW
= "" and g_blnInternalFirst
= false then
1399 strPathOW
= SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion
)
1402 if strPathOW
= "" then
1403 PrintResultMsg
"OpenWatcom", "not found"
1404 CfgPrintAssign
"VBOX_WITH_OPEN_WATCOM", ""
1408 CfgPrintAssign
"VBOX_WITH_OPEN_WATCOM", "1"
1409 CfgPrintAssign
"PATH_TOOL_OPENWATCOM", strPathOW
1410 PrintResult
"OpenWatcom v" & strVersion
, strPathOW
1411 if StrVersionCompare(strVersion
, "2.0") >= 0 then
1412 MsgWarning
"We only test building with OpenWatcom 1.9."
1416 function OpenWatcomProgramItemCallback(ByRef arrStrings
, cStrings
, ByRef strUnused
)
1418 OpenWatcomProgramItemCallback
= ""
1419 if cStrings
> 1 then
1421 off
= InStr(1, str
, "\binnt\", vbTextCompare
)
1423 OpenWatcomProgramItemCallback
= Left(str
, off
- 1)
1428 function CheckForOpenWatcomSub(strPathOW
, ByRef strVersion
)
1429 CheckForOpenWatcomSub
= ""
1430 if strPathOW
<> "" then
1431 LogPrint
"Trying: " & strPathOW
1432 if LogDirExists(strPathOW
) then
1433 if LogDirExists(strPathOW
& "/binnt") _
1434 and LogDirExists(strPathOW
& "/h") _
1435 and LogDirExists(strPathOW
& "/eddat") _
1436 and LogFileExists(strPathOW
, "binnt/wcc386.exe") _
1437 and LogFileExists(strPathOW
, "binnt/wcc.exe") _
1438 and LogFileExists(strPathOW
, "binnt/wlink.exe") _
1439 and LogFileExists(strPathOW
, "binnt/wcl386.exe") _
1440 and LogFileExists(strPathOW
, "binnt/wcl.exe") _
1441 and LogFileExists(strPathOW
, "binnt/wlib.exe") _
1442 and LogFileExists(strPathOW
, "binnt/wasm.exe") _
1443 and LogFileExists(strPathOW
, "h/stdarg.h") _
1445 ' Some wcl/wcl386 option parsing quirk allows us to specify /whatever
1446 ' and just get the logo text and exit code 0. We use /y as it's a valid option.
1448 if Shell("""" & DosSlashes(strPathOW
& "\binnt\wcl.exe") & """ /y", True, strOutput
) = 0 then
1449 dim strPreamble
: strPreamble
= "Open Watcom C/C++16 Compile and Link Utility Version"
1450 strOutput
= StrGetFirstLine(strOutput
)
1451 if StrStartsWithI(strOutput
, strPreamble
) then
1452 strVersion
= StrGetFirstWord(Trim(Mid(strOutput
, Len(strPreamble
) + 1)))
1453 if StrVersionCompare(strVersion
, "1.9") >= 0 then
1454 CheckForOpenWatcomSub
= UnixSlashes(PathAbs(strPathOW
))
1456 LogPrint
"OpenWatcom version id older than 1.9: " & strVersion
1459 LogPrint
"Not OpenWatcom: " & strOutput
1469 ' Checks for any libSDL binaries.
1471 sub CheckForlibSDL(strOptlibSDL
)
1472 dim strPathLibSDL
, strVersion
1476 ' Try find some SDL library.
1478 strPathLibSDL
= CheckForLibSDLSub(strOptlibSDL
, strVersion
)
1479 if strPathlibSDL
= "" and g_blnInternalFirst
= true then
1480 strPathLibSDL
= SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion
)
1483 ' Poke about in the LIB and PATH env.vars.
1484 if strPathlibSDL
= "" then strPathLibSDL
= CheckForlibSDLSub(PathParent(PathStripFilename(WhichEx("LIB", "SDLmain.lib"))), strVersion
)
1485 if strPathlibSDL
= "" then strPathLibSDL
= CheckForlibSDLSub(PathParent(PathStripFilename(Which("..\lib\SDLmain.lib"))), strVersion
)
1486 if strPathlibSDL
= "" then strPathLibSDL
= CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDLmain.lib"))), strVersion
)
1487 if strPathlibSDL
= "" then strPathLibSDL
= CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDL.dll"))), strVersion
)
1490 if strPathlibSDL
= "" and g_blnInternalFirst
= false then
1491 strPathLibSDL
= SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion
)
1495 if strPathlibSDL
= "" then
1496 if strOptlibSDL
= "" then
1497 MsgError
"Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
1498 & "If still no luck, consult the configure.log and the build requirements."
1500 MsgError
"Can't locate libSDL. Please consult the configure.log and the build requirements."
1505 strPathLibSDL
= UnixSlashes(PathAbs(strPathLibSDL
))
1506 CfgPrintAssign
"PATH_SDK_LIBSDL", strPathlibSDL
1508 PrintResult
"libSDL", strPathlibSDL
1511 '' Checks if the specified path points to an usable libSDL or not.
1512 function CheckForLibSDLSub(strPathlibSDL
, strVersion
)
1513 CheckForlibSDLSub
= ""
1514 if strPathLibSDL
<> "" then
1515 LogPrint
"Trying: strPathLibSDL=" & strPathLibSDL
1516 if LogFileExists(strPathLibSDL
, "lib/SDL.lib") _
1517 and LogFileExists(strPathLibSDL
, "lib/SDLmain.lib") _
1518 and LogFileExists(strPathLibSDL
, "lib/SDL.dll") _
1520 dim strIncSub
: strIncSub
= "include"
1521 if DirExists(strPathlibSDL
& "/include/SDL") then strIncSub
= "include/SDL"
1522 if LogFileExists(strPathLibSDL
, strIncSub
& "/SDL.h") _
1523 and LogFileExists(strPathLibSDL
, strIncSub
& "/SDL_syswm.h") _
1524 and LogFileExists(strPathLibSDL
, strIncSub
& "/SDL_version.h") _
1527 CheckForLibSDLSub
= strPathLibSDL
1535 ' Checks for libxml2.
1537 sub CheckForXml2(strOptXml2
)
1538 dim strPathXml2
, str
1542 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1544 if (strOptXml2
= "") then
1545 PrintResultMsg
"libxml2", "src/lib/libxml2-*"
1549 ' Skip if no COM/ATL.
1550 if g_blnDisableCOM
then
1551 PrintResultMsg
"libxml2", "Skipped (" & g_strDisableCOM
& ")"
1556 ' Try find some xml2 dll/lib.
1559 if (strPathXml2
= "") And (strOptXml2
<> "") then
1560 if CheckForXml2Sub(strOptXml2
) then strPathXml2
= strOptXml2
1563 if strPathXml2
= "" then
1564 str
= Which("libxml2.lib")
1566 str
= PathParent(PathStripFilename(str
))
1567 if CheckForXml2Sub(str
) then strPathXml2
= str
1572 if strPathXml2
= "" then
1573 if strOptXml2
= "" then
1574 MsgError
"Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _
1575 & "If still no luck, consult the configure.log and the build requirements."
1577 MsgError
"Can't locate libxml2. Please consult the configure.log and the build requirements."
1582 strPathXml2
= UnixSlashes(PathAbs(strPathXml2
))
1583 CfgPrintAssign
"SDK_VBoxLibXml2_DEFS", "_REENTRANT"
1584 CfgPrintAssign
"SDK_VBoxLibXml2_INCS", strPathXml2
& "/include"
1585 CfgPrintAssign
"SDK_VBoxLibXml2_LIBS", strPathXml2
& "/lib/libxml2.lib"
1587 PrintResult
"libxml2", strPathXml2
1590 '' Checks if the specified path points to an usable libxml2 or not.
1591 function CheckForXml2Sub(strPathXml2
)
1594 CheckForXml2Sub
= False
1595 LogPrint
"trying: strPathXml2=" & strPathXml2
1596 if LogFileExists(strPathXml2
, "include/libxml/xmlexports.h") _
1597 And LogFileExists(strPathXml2
, "include/libxml/xmlreader.h") _
1599 str
= LogFindFile(strPathXml2
, "bin/libxml2.dll")
1601 if LogFindFile(strPathXml2
, "lib/libxml2.lib") <> "" then
1602 CheckForXml2Sub
= True
1609 '' Checks for openssl
1610 sub CheckForSsl(strOptSsl
, bln32Bit
)
1614 strOpenssl
= "openssl"
1615 if bln32Bit
= True then
1616 strOpenssl
= "openssl32"
1620 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1622 if (strOptSsl
= "") then
1623 PrintResult strOpenssl
, "src/libs/openssl-*"
1628 ' Try find some openssl dll/lib.
1631 if (strPathSsl
= "") And (strOptSsl
<> "") then
1632 if CheckForSslSub(strOptSsl
) then strPathSsl
= strOptSsl
1635 if strPathSsl
= "" then
1636 str
= Which("libssl.lib")
1638 str
= PathParent(PathStripFilename(str
))
1639 if CheckForSslSub(str
) then strPathSsl
= str
1644 if strPathSsl
= "" then
1645 if strOptSsl
= "" then
1646 MsgError
"Can't locate " & strOpenssl
& ". " _
1647 & "Try specify the path with the --with-" & strOpenssl
& "=<path> argument. " _
1648 & "If still no luck, consult the configure.log and the build requirements."
1650 MsgError
"Can't locate " & strOpenssl
& ". " _
1651 & "Please consult the configure.log and the build requirements."
1656 strPathSsl
= UnixSlashes(PathAbs(strPathSsl
))
1657 if bln32Bit
= True then
1658 CfgPrintAssign
"SDK_VBoxOpenSslStatic-x86_INCS", strPathSsl
& "/include"
1659 CfgPrintAssign
"SDK_VBoxOpenSslStatic-x86_LIBS", strPathSsl
& "/lib/libcrypto.lib" & " " & strPathSsl
& "/lib/libssl.lib"
1660 CfgPrintAssign
"SDK_VBoxOpenSslBldProg-x86_LIBS", strPathSsl
& "/lib/libcrypto.lib" & " " & strPathSsl
& "/lib/libssl.lib"
1662 CfgPrintAssign
"SDK_VBoxOpenSslStatic_INCS", strPathSsl
& "/include"
1663 CfgPrintAssign
"SDK_VBoxOpenSslStatic_LIBS", strPathSsl
& "/lib/libcrypto.lib" & " " & strPathSsl
& "/lib/libssl.lib"
1664 CfgPrintAssign
"SDK_VBoxOpenSslBldProg_LIBS", strPathSsl
& "/lib/libcrypto.lib" & " " & strPathSsl
& "/lib/libssl.lib"
1667 PrintResult strOpenssl
, strPathSsl
1670 '' Checks if the specified path points to an usable openssl or not.
1671 function CheckForSslSub(strPathSsl
)
1673 CheckForSslSub
= False
1674 LogPrint
"trying: strPathSsl=" & strPathSsl
1675 if LogFileExists(strPathSsl
, "include/openssl/md5.h") _
1676 And LogFindFile(strPathSsl
, "lib/libssl.lib") <> "" _
1678 CheckForSslSub
= True
1684 ' Checks for libcurl
1686 sub CheckForCurl(strOptCurl
, bln32Bit
)
1687 dim strPathCurl
, str
1691 if bln32Bit
= True then
1692 strCurl
= "libcurl32"
1696 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1698 if (strOptCurl
= "") then
1699 PrintResult strCurl
, "src/libs/curl-*"
1704 ' Try find some cURL dll/lib.
1707 if (strPathCurl
= "") And (strOptCurl
<> "") then
1708 if CheckForCurlSub(strOptCurl
) then strPathCurl
= strOptCurl
1711 if strPathCurl
= "" then
1712 str
= Which("libcurl.lib")
1714 str
= PathParent(PathStripFilename(str
))
1715 if CheckForCurlSub(str
) then strPathCurl
= str
1720 if strPathCurl
= "" then
1721 if strOptCurl
= "" then
1722 MsgError
"Can't locate " & strCurl
& ". " _
1723 & "Try specify the path with the --with-" & strCurl
& "=<path> argument. " _
1724 & "If still no luck, consult the configure.log and the build requirements."
1726 MsgError
"Can't locate " & strCurl
& ". " _
1727 & "Please consult the configure.log and the build requirements."
1732 strPathCurl
= UnixSlashes(PathAbs(strPathCurl
))
1733 if bln32Bit
= True then
1734 CfgPrintAssign
"SDK_VBoxLibCurl-x86_INCS", strPathCurl
& "/include"
1735 CfgPrintAssign
"SDK_VBoxLibCurl-x86_LIBS.x86", strPathCurl
& "/libcurl.lib"
1737 CfgPrintAssign
"SDK_VBoxLibCurl_INCS", strPathCurl
& "/include"
1738 CfgPrintAssign
"SDK_VBoxLibCurl_LIBS", strPathCurl
& "/libcurl.lib"
1741 PrintResult strCurl
, strPathCurl
1744 '' Checks if the specified path points to an usable libcurl or not.
1745 function CheckForCurlSub(strPathCurl
)
1747 CheckForCurlSub
= False
1748 LogPrint
"trying: strPathCurl=" & strPathCurl
1749 if LogFileExists(strPathCurl
, "include/curl/curl.h") _
1750 And LogFindFile(strPathCurl
, "libcurl.dll") <> "" _
1751 And LogFindFile(strPathCurl
, "libcurl.lib") <> "" _
1753 CheckForCurlSub
= True
1759 ' Checks for any Qt binaries.
1761 sub CheckForQt(strOptQt
, strOptInfix
)
1762 dim strPathQt
, strInfixQt
, arrFolders
, arrVccInfixes
, strVccInfix
, strPathDev
1766 ' Try to find the Qt installation (user specified path with --with-qt)
1768 LogPrint
"Checking for user specified path of Qt ... "
1769 strPathQt
= CheckForQtSub(UnixSlashes(strOptQt
), strOptInfix
, strInfixQt
)
1770 if strPathQt
= "" and g_blnInternalFirst
= true then strPathQt
= CheckForQtInternal(strOptInfix
, strInfixQt
)
1771 if strPathQt
= "" then
1773 ' Collect links from "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"
1775 ' Typical string list:
1776 ' C:\Users\someuser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Qt\6.x.y\MSVC 20zz (64-bit)\Qt 6.x.y (MSVC 20zz 64-bit).lnk
1777 ' C:\Windows\System32\cmd.exe
1778 ' /A /Q /K E:\qt\installed\6.x.y\msvc20zz_64\bin\qtenv2.bat
1780 dim arrCandidates
, strCandidate
1781 arrCandidates
= CollectFromProgramItemLinks(GetRef("QtProgramItemCallback"), strPathQt
)
1782 LogPrint
"Testing qtenv2.bat links (" & ArraySize(arrCandidates
) & ") ..."
1784 ' VC infixes/subdir names to consider (ASSUMES 64bit)
1785 if g_strVCCVersion
= "VCC142" or g_strVCCVersion
= "" then
1786 arrVccInfixes
= Array("msvc2019_64", "msvc2017_64", "msvc2015_64")
1788 MsgFatal
"Unexpected VC version: " & g_strVCCVersion
1789 arrVccInfixes
= Array()
1791 for each strVccInfix
in arrVccInfixes
1792 for each strCandidate
in arrCandidates
1793 if InStr(1, LCase(strCandidate
), strVccInfix
) > 0 then
1794 strPathQt
= CheckForQtSub(strCandidate
, strOptInfix
, strInfixQt
)
1795 if strPathQt
<> "" then exit for
1798 if strPathQt
<> "" then exit for
1802 ' Check the dev tools - prefer ones matching the compiler.
1803 if strPathQt
= "" and g_blnInternalFirst
= false then strPathQt
= CheckForQtInternal(strOptInfix
, strInfixQt
)
1806 ' Display the result and output the config.
1808 if strPathQt
<> "" then
1809 PrintResult
"Qt", strPathQt
1810 PrintResultMsg
"Qt infix", strInfixQt
1811 CfgPrintAssign
"PATH_SDK_QT6", strPathQt
1812 CfgPrintAssign
"PATH_TOOL_QT6", "$(PATH_SDK_QT6)"
1813 CfgPrintAssign "VBOX_PATH_QT
", "$(PATH_SDK_QT6)"
1814 CfgPrintAssign
"VBOX_QT_INFIX", strInfixQt
1815 CfgPrintAssign
"VBOX_WITH_QT_PAYLOAD", "1"
1817 PrintResultMsg
"Qt", "not found"
1818 CfgPrintAssign
"VBOX_WITH_QTGUI", ""
1822 function CheckForQtInternal(strOptInfix
, ByRef strInfixQt
)
1823 dim strPathDev
, arrFolders
, arrVccInfixes
, strVccInfix
, i
1824 CheckForQtInternal
= ""
1825 for each strPathDev
in g_arrPathDev
1826 LogPrint
"Testing tools dir (" & strPathDev
& "/win." & g_strTargetArch
& "/qt/v6*) ..."
1827 arrFolders
= GetSubdirsStartingWithVerSorted(strPathDev
& "/win." & g_strTargetArch
& "/qt", "v6")
1828 arrVccInfixes
= Array(LCase(g_strVCCVersion
), Left(LCase(g_strVCCVersion
), Len(g_strVCCVersion
) - 1), "")
1829 for each strVccInfix
in arrVccInfixes
1830 for i
= UBound(arrFolders
) to LBound(arrFolders
) step
-1
1831 if strVccInfix
= "" or InStr(1, LCase(arrFolders(i
)), strVccInfix
) > 0 then
1832 LogPrint
"i="&i
&" strVccInfix="&strVccInfix
1833 strPathQt
= CheckForQtSub(strPathDev
& "/win." & g_strTargetArch
& "/qt/" & arrFolders(i
), strOptInfix
, strInfixQt
)
1834 if strPathQt
<> "" then
1835 CheckForQtInternal
= strPathQt
1844 function QtProgramItemCallback(ByRef arrStrings
, cStrings
, ByRef strUnused
)
1846 QtProgramItemCallback
= ""
1847 if cStrings
>= 3 then
1848 str
= Trim(arrStrings(UBound(arrStrings
)))
1849 if LCase(Right(str
, Len("\bin\qtenv2.bat"))) = "\bin\qtenv2.bat" _
1850 and InStr(1, LCase(str
), "\msvc20") > 0 _
1851 and InStr(1, str
, ":") > 0 _
1853 off
= InStr(1, str
, ":") - 1
1854 QtProgramItemCallback
= Mid(str
, off
, Len(str
) - off
- Len("\bin\qtenv2.bat") + 1)
1859 function CheckForQtSub(strPathQt
, strOptInfix
, ByRef strInfixQt
)
1861 if strPathQt
<> "" then
1862 LogPrint
"Trying: strPathQt=" & strPathQt
1864 if LogFileExists(strPathQt
, "bin/moc.exe") _
1865 and LogFileExists(strPathQt
, "bin/uic.exe") _
1866 and LogFileExists(strPathQt
, "include/QtWidgets/qwidget.h") _
1867 and LogFileExists(strPathQt
, "include/QtWidgets/QApplication") _
1868 and LogFileExists(strPathQt
, "include/QtGui/QImage") _
1869 and LogFileExists(strPathQt
, "include/QtNetwork/QHostAddress") _
1872 if LogFileExists(strPathQt
, "lib/Qt6Core.lib") _
1873 and LogFileExists(strPathQt
, "lib/Qt6Network.lib") then
1874 LogPrint
"found it w/o infix"
1876 CheckForQtSub
= UnixSlashes(PathAbs(strPathQt
))
1877 elseif LogFileExists(strPathQt
, "lib/Qt6Core" & strOptInfix
& ".lib") _
1878 and LogFileExists(strPathQt
, "lib/Qt6Network" & strOptInfix
& ".lib") then
1879 LogPrint
"found it w/ infix: " & strOptInfix
& " (option)"
1880 strInfixQt
= strOptInfix
1881 CheckForQtSub
= UnixSlashes(PathAbs(strPathQt
))
1882 elseif LogFileExists(strPathQt
, "lib/Qt6CoreVBox.lib") _
1883 and LogFileExists(strPathQt
, "lib/Qt6NetworkVBox.lib") then
1884 LogPrint
"found it w/ infix: VBox"
1886 CheckForQtSub
= UnixSlashes(PathAbs(strPathQt
))
1894 ' Checks for python.
1896 function CheckForPython(strOptPython
)
1897 dim strPathPython
, arrVersions
, strVer
, str
1899 CheckForPython
= False
1904 strPathPython
= CheckForPythonSub(strOptPython
)
1905 if strPathPython
= "" then
1906 arrVersions
= Array("3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6", "3.5", "2.7")
1907 for each strVer
in arrVersions
1908 strPathPython
= CheckForPythonSub(LogRegGetString("HKLM\SOFTWARE\Python\PythonCore\" & strVer
& "\InstallPath\"))
1909 if strPathPython
<> "" then exit for
1912 if strPathPython
= "" then strPathPython
= CheckForPythonSub(PathStripFilename(Which("python.exe")))
1915 ' Output config & result.
1917 CheckForPython
= strPathPython
<> ""
1918 if CheckForPython
then
1919 CfgPrintAssign
"VBOX_BLD_PYTHON", strPathPython
1920 PrintResult
"Python", strPathPython
1922 PrintResultMsg
"Python", "not found"
1926 function CheckForPythonSub(strPathPython
)
1927 CheckForPythonSub
= ""
1928 if strPathPython
<> "" then
1929 if LogFileExists(strPathPython
, "python.exe") _
1931 CheckForPythonSub
= UnixSlashes(PathAbs(strPathPython
& "/python.exe"))
1937 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1938 ' Main function and usage '
1939 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1945 Print
"Usage: cscript configure.vbs [options]"
1947 Print
"Configuration:"
1948 Print
" -h, --help Display this."
1949 Print
" --target-arch=x86|amd64 The target architecture."
1950 Print
" --continue-on-error Do not stop on errors."
1951 Print
" --internal-last Check internal tools (tools/win.*) last."
1952 Print
" --internal-first Check internal tools (tools/win.*) first (default)."
1955 Print
" --disable-COM Disables all frontends and API."
1956 Print
" --disable-SDL Disables the SDL frontend."
1957 Print
" --disable-UDPTunnel"
1958 Print
" --disable-pylint Disable use of pylint."
1961 Print
" --with-kBuild=PATH Where kBuild is to be found."
1962 Print
" --with-libSDL=PATH Where libSDL is to be found."
1963 Print
" --with-Qt=PATH Where Qt is to be found (optional)."
1964 Print
" --with-DDK=PATH Where the WDK is to be found."
1965 Print
" --with-SDK=PATH Where the Windows SDK is to be found."
1966 Print
" --with-SDK10=PATH Where the Windows 10 SDK/WDK is to be found."
1967 Print
" --with-VC=PATH Where the Visual C++ compiler is to be found."
1968 Print
" (Expecting bin, include and lib subdirs.)"
1969 Print
" --with-VC-Common=PATH Maybe needed for 2015 and older to"
1970 Print
" locate the Common7 directory."
1971 Print
" --with-python=PATH The python to use."
1972 Print
" --with-midl=PATH Where midl.exe is to be found."
1973 Print
" --with-yasm=PATH Where YASM is to be found."
1974 Print
" --with-nasm=PATH Where NASM is to be found (optional)"
1975 Print
" --with-openwatcom=PATH Where OpenWatcom 1.9 is to be found (optional)."
1976 Print
" --with-libxml2=PATH To use a libxml2 other than the VBox one (opt)."
1977 Print
" --with-openssl=PATH To use an openssl other than the VBox one (opt)."
1978 Print
" --with-openssl32=PATH The 32-bit variant of openssl (optional)."
1979 Print
" --with-libcurl=PATH To use a cURL other than the VBox one (optional)."
1980 Print
" --with-libcurl32=PATH The 32-bit variant of cURL (optional)."
1982 Print
" --append-tools-dir=PATH, --prepend-tools-dir=PATH"
1983 Print
" Adds an alternative tools directory to search."
1984 Print
" --append-tools-dir=PATH, --prepend-prog-files=PATH"
1985 Print
" Adds an alternative Program Files dir to search."
1986 Print
" --append-ewdk-drive=DRIVE, --prepend-ewdk-drive=DRIVE"
1987 Print
" Adds an EWDK drive the search list."
1992 ' The main() like function.
1998 ' Write the log header and check that we're not using wscript.
2001 if UCase(Right(Wscript
.FullName
, 11)) = "WSCRIPT.EXE" then
2002 Wscript
.Echo
"This script must be run under CScript."
2017 strOptSDK10Version
= ""
2023 strOptOpenWatcom
= ""
2030 blnOptDisableCOM
= False
2031 blnOptDisableUDPTunnel
= False
2032 blnOptDisableSDL
= False
2033 for i
= 1 to Wscript
.Arguments
.Count
2034 dim str
, strArg
, strPath
2036 ' Separate argument and path value
2037 str
= Wscript
.Arguments
.item(i
- 1)
2038 if InStr(1, str
, "=") > 0 then
2039 strArg
= Mid(str
, 1, InStr(1, str
, "=") - 1)
2040 strPath
= Mid(str
, InStr(1, str
, "=") + 1)
2041 if strPath
= "" then MsgFatal
"Syntax error! Argument #" & i
& " is missing the path."
2047 ' Process the argument
2048 select case LCase(strArg
)
2053 MsgWarning
"Ignoring --with-dxsdk (the DirectX SDK is no longer required)."
2054 case "--with-kbuild"
2055 strOptkBuild
= strPath
2056 case "--with-libsdl"
2057 strOptlibSDL
= strPath
2058 case "--with-mingw32"
2060 case "--with-mingw-w64"
2064 case "--with-qt-infix"
2065 strOptQtInfix
= strPath
2067 MsgWarning
"Ignoring --with-sdk (the legacy Platform SDK is no longer required)."
2069 strOptSDK10
= strPath
2070 case "--with-sdk10-version"
2071 strOptSDK10Version
= strPath
2074 case "--with-vc-common"
2075 strOptVCCommon
= strPath
2076 case "--with-vc-express-edition"
2078 case "--with-w32api"
2081 strOptMidl
= strPath
2083 strOptYasm
= strPath
2085 strOptNasm
= strPath
2086 case "--with-openwatcom"
2087 strOptOpenWatcom
= strPath
2088 case "--with-libxml2"
2089 strOptXml2
= strPath
2090 case "--with-openssl"
2092 case "--with-openssl32"
2093 strOptSsl32
= strPath
2094 case "--with-libcurl"
2095 strOptCurl
= strPath
2096 case "--with-libcurl32"
2097 strOptCurl32
= strPath
2098 case "--with-python"
2099 strOptPython
= strPath
2102 case "--append-tools-dir"
2103 g_arrToolsDirs
= ArrayAppend(g_arrPathDev
, strPath
)
2104 case "--prepend-tools-dir"
2105 g_arrToolsDirs
= ArrayPrepend(g_arrPathDev
, strPath
)
2106 case "--append-prog-files"
2107 g_arrProgramFiles
= ArrayAppend(g_arrProgramFiles
, strPath
)
2108 case "--prepend-prog-files"
2109 g_arrProgramFiles
= ArrayPrepend(g_arrProgramFiles
, strPath
)
2110 case "--append-ewdk-drive"
2111 g_arrProgramFiles
= ArrayAppend(g_arrProgramFiles
, strPath
& "\Program Files")
2112 case "--prepend-ewdk-drive"
2113 g_arrProgramFiles
= ArrayPrepend(g_arrProgramFiles
, strPath
& "\Program Files")
2115 ' --disable-something/--enable-something
2116 case "--disable-com"
2117 blnOptDisableCOM
= True
2119 blnOptDisableCOM
= False
2120 case "--disable-udptunnel"
2121 blnOptDisableUDPTunnel
= True
2122 case "--enable-udptunnel"
2123 blnOptDisableUDPTunnel
= False
2124 case "--disable-sdl"
2125 blnOptDisableSDL
= True
2126 case "--endable-sdl"
2127 blnOptDisableSDL
= False
2128 case "--disable-pylint"
2129 blnOptDisablePylint
= True
2130 case "--enable-pylint"
2131 blnOptDisablePylint
= False
2134 case "--continue-on-error"
2135 g_blnContinueOnError
= True
2136 case "--internal-first"
2137 g_blnInternalFirst
= True
2138 case "--internal-last"
2139 g_blnInternalFirst
= False
2140 case "--target-arch"
2141 g_strTargetArch
= strPath
2142 case "-h", "--help", "-?"
2147 Wscript
.echo
"syntax error: Unknown option '" & str
&"'."
2155 ' Initialize output files.
2161 ' Check that the Shell function is sane.
2163 g_objShell
.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
2164 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False, strOutput
) <> 0 then ' The 'E' is missing on purpose (4nt).
2165 MsgFatal
"shell execution test failed!"
2167 if strOutput
<> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
2168 Print
"Shell test Test -> '" & strOutput
& "'"
2169 MsgFatal
"shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."
2171 g_objShell
.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
2172 Print
"Shell inheritance test: OK"
2177 if blnOptDisableCOM
= True then
2178 DisableCOM
"--disable-com"
2180 if blnOptDisableUDPTunnel
= True then
2181 DisableUDPTunnel
"--disable-udptunnel"
2183 if blnOptDisablePylint
= True then
2184 CfgPrintAssign
"override VBOX_WITH_PYLINT", ""
2187 CheckForkBuild strOptkBuild
2188 CheckForWinDDK strOptDDK
2189 CheckForVisualCPP strOptVC
, strOptVCCommon
2190 CheckForSDK10 strOptSDK10
, strOptSDK10Version
2191 CheckForMidl strOptMidl
2192 CheckForYasm strOptYasm
2193 CheckForNasm strOptNasm
2194 CheckForOpenWatcom strOptOpenWatcom
2195 if blnOptDisableSDL
= True then
2196 DisableSDL
"--disable-sdl"
2198 CheckForlibSDL strOptlibSDL
2200 CheckForXml2 strOptXml2
2201 CheckForSsl strOptSsl
, False
2202 if g_strTargetArch
= "amd64" then
2203 ' 32-bit openssl required as well
2204 CheckForSsl strOptSsl32
, True
2206 CheckForCurl strOptCurl
, False
2207 if g_strTargetArch
= "amd64" then
2208 ' 32-bit Curl required as well
2209 CheckForCurl strOptCurl32
, True
2211 CheckForQt strOptQt
, strOptQtInfix
2212 CheckForPython strOptPython
2213 CfgPrintAssign
"VBOX_WITH_LIBVPX", "" '' @todo look for libvpx 1.1.0+
2214 CfgPrintAssign
"VBOX_WITH_LIBOGG", "" '' @todo look for libogg 1.3.5+
2215 CfgPrintAssign
"VBOX_WITH_LIBVORBIS", "" '' @todo look for libvorbis 1.3.7+
2217 EnvPrintAppend
"PATH", DosSlashes(g_strPath
& "\tools\win." & g_strHostArch
& "\bin"), ";"
2218 if g_strHostArch
= "amd64" then
2219 EnvPrintAppend
"PATH", DosSlashes(g_strPath
& "\tools\win.x86\bin"), ";"
2221 EnvPrintCleanup
"PATH", DosSlashes(g_strPath
& "\tools\win.amd64\bin"), ";"
2225 Print
"Execute env.bat once before you start to build VBox:"
2230 if g_rcScript
<> 0 then
2231 Print
"Warning: ignored errors. See above or in configure.log."
2238 ' What crt0.o typically does:
2240 WScript
.Quit(Main())