VirtualBox

source: vbox/trunk/configure.vbs@ 85829

Last change on this file since 85829 was 85824, checked in by vboxsync, 5 years ago

configure.vbs,helpers.vbs: Added options for appending & prepending extra 'tools' and 'Program Files' directories to search for tools and libs, extending and adjusting checker functions accordingly. Added ArrayFindString[I], ArrayPrepend, ArrayRemove and ArrayToString. Reworte ArrayAppend to work ByRef.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Id
File size: 89.0 KB
Line 
1' $Id: configure.vbs 85824 2020-08-18 21:24:38Z vboxsync $
2'' @file
3' The purpose of this script is to check for all external tools, headers, and
4' libraries VBox OSE depends on.
5'
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'.
9'
10
11'
12' Copyright (C) 2006-2020 Oracle Corporation
13'
14' This file is part of VirtualBox Open Source Edition (OSE), as
15' available from http://www.virtualbox.org. This file is free software;
16' you can redistribute it and/or modify it under the terms of the GNU
17' General Public License (GPL) as published by the Free Software
18' Foundation, in version 2 as it comes in the "COPYING" file of the
19' VirtualBox OSE distribution. VirtualBox OSE is distributed in the
20' hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
21'
22
23
24''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
25' Header Files
26''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
27
28''
29' Includes a vbscript file relative to the script.
30sub IncludeFile(strFilename)
31 dim objFile, objFileSys
32 set objFileSys = WScript.CreateObject("Scripting.FileSystemObject")
33 dim strPath : strPath = objFileSys.BuildPath(objFileSys.GetParentFolderName(Wscript.ScriptFullName), strFilename)
34 set objFile = objFileSys.openTextFile(strPath)
35 executeglobal objFile.readAll()
36 objFile.close
37 set objFileSys = nothing
38end sub
39
40IncludeFile "tools\win\vbscript\helpers.vbs"
41
42
43''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
44' Global Variables '
45''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
46dim g_strPath, g_strEnvFile, g_strLogFile, g_strCfgFile
47g_strPath = Left(Wscript.ScriptFullName, Len(Wscript.ScriptFullName) - Len("\configure.vbs"))
48g_strEnvFile = g_strPath & "\env.bat"
49g_strCfgFile = g_strPath & "\AutoConfig.kmk"
50g_strLogFile = g_strPath & "\configure.log"
51'g_strTmpFile = g_strPath & "\configure.tmp"
52
53
54' kBuild stuff.
55dim g_strPathkBuild, g_strPathkBuildBin, g_strPathDev, g_arrPathDev
56g_strPathkBuild = ""
57g_strPathkBuildBin = ""
58g_strPathDev = ""
59g_arrPathDev = Array(":placeholder:")
60
61dim g_strTargetArch, g_StrTargetArchWin
62g_strTargetArch = ""
63g_StrTargetArchWin = ""
64
65dim g_strHostArch, g_strHostArchWin
66g_strHostArch = ""
67g_strHostArchWin = ""
68
69' Visual C++ info.
70dim g_strPathVCC, g_strVCCVersion
71g_strPathVCC = ""
72g_strVCCVersion = ""
73
74' SDK and DDK.
75dim g_strPathSDK10, g_strPathPSDK, g_strVerPSDK, g_strPathDDK
76g_strPathSDK10 = ""
77g_strPathPSDK = ""
78g_strVerPSDK = ""
79g_strPathDDK = ""
80
81' COM disabling.
82dim g_blnDisableCOM, g_strDisableCOM
83g_blnDisableCOM = False
84g_strDisableCOM = ""
85
86' Whether to ignore (continue) on errors.
87dim g_blnContinueOnError, g_rcExit
88g_blnContinueOnError = False
89
90' The script's exit code (for ignored errors).
91dim g_rcScript
92g_rcScript = 0
93
94' Whether to try the internal stuff first or last.
95dim g_blnInternalFirst
96g_blnInternalFirst = True
97
98' List of program files locations.
99dim g_arrProgramFiles
100if EnvGet("ProgramFiles(x86)") <> "" then
101 g_arrProgramFiles = Array(EnvGet("ProgramFiles"), EnvGet("ProgramFiles(x86)"))
102else
103 g_arrProgramFiles = Array(EnvGet("ProgramFiles"))
104end if
105
106
107
108''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
109' Helpers: Logging and Logged operations '
110''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
111
112''
113' Write a log header with some basic info.
114sub LogInit
115 FileDelete g_strLogFile
116 LogPrint "# Log file generated by " & Wscript.ScriptFullName
117 for i = 1 to WScript.Arguments.Count
118 LogPrint "# Arg #" & i & ": " & WScript.Arguments.Item(i - 1)
119 next
120 if Wscript.Arguments.Count = 0 then
121 LogPrint "# No arguments given"
122 end if
123 LogPrint "# Reconstructed command line: " & GetCommandline()
124
125 ' some Wscript stuff
126 LogPrint "# Wscript properties:"
127 LogPrint "# ScriptName: " & Wscript.ScriptName
128 LogPrint "# Version: " & Wscript.Version
129 LogPrint "# Build: " & Wscript.BuildVersion
130 LogPrint "# Name: " & Wscript.Name
131 LogPrint "# Full Name: " & Wscript.FullName
132 LogPrint "# Path: " & Wscript.Path
133 LogPrint "#"
134
135
136 ' the environment
137 LogPrint "# Environment:"
138 dim objEnv
139 for each strVar in g_objShell.Environment("PROCESS")
140 LogPrint "# " & strVar
141 next
142 LogPrint "#"
143end sub
144
145
146''
147' Append text to the log file.
148sub LogPrint(str)
149 FileAppendLine g_strLogFile, str
150 'Wscript.Echo "dbg: " & str
151end sub
152
153
154''
155' Checks if the file exists and logs failures.
156function LogFileExists(strPath, strFilename)
157 LogFileExists = FileExists(strPath & "/" & strFilename)
158 if LogFileExists = False then
159 LogPrint "Testing '" & strPath & "': " & strFilename & " not found"
160 end if
161end function
162
163
164''
165' Checks if the file exists and logs failures.
166function LogFileExists1(strPath)
167 LogFileExists1 = FileExists(strPath)
168 if LogFileExists1 = False then
169 LogPrint "Testing '" & strPath & "': file not found"
170 end if
171end function
172
173
174''
175' Checks if the directory exists and logs failures.
176function LogDirExists(strPath)
177 LogDirExists = DirExists(strPath)
178 if LogDirExists = False then
179 LogPrint "Testing '" & strPath & "': not found (or not dir)"
180 end if
181end function
182
183
184''
185' Finds the first file matching the pattern.
186' If no file is found, log the failure.
187function LogFindFile(strPath, strPattern)
188 dim str, strOutput
189
190 '
191 ' Yes, there are some facy database kinda interface to the filesystem
192 ' however, breaking down the path and constructing a usable query is
193 ' too much hassle. So, we'll do it the unix way...
194 '
195 if Shell("dir /B """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True, strOutput) = 0 _
196 And InStr(1, strOutput, Chr(13)) > 1 _
197 then
198 ' return the first word.
199 LogFindFile = Left(strOutput, InStr(1, strOutput, Chr(13)) - 1)
200 else
201 LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
202 LogFindFile = ""
203 end if
204end function
205
206
207''
208' Finds the first directory matching the pattern.
209' If no directory is found, log the failure,
210' else return the complete path to the found directory.
211function LogFindDir(strPath, strPattern)
212 dim str, strOutput
213
214 '
215 ' Yes, there are some facy database kinda interface to the filesystem
216 ' however, breaking down the path and constructing a usable query is
217 ' too much hassle. So, we'll do it the unix way...
218 '
219
220 ' List the alphabetically last names as first entries (with /O-N).
221 if Shell("dir /B /AD /O-N """ & DosSlashes(strPath) & "\" & DosSlashes(strPattern) & """", True, strOutput) = 0 _
222 And InStr(1, strOutput, Chr(13)) > 1 _
223 then
224 ' return the first word.
225 LogFindDir = strPath & "/" & Left(strOutput, InStr(1, strOutput, Chr(13)) - 1)
226 else
227 LogPrint "Testing '" & strPath & "': " & strPattern & " not found"
228 LogFindDir = ""
229 end if
230end function
231
232
233''
234' Wrapper around RegGetString that logs successes.
235function LogRegGetString(strName)
236 LogRegGetString = RegGetString(strName)
237 if LogRegGetString <> "" then LogPrint "RegGetString(" & strName & ") -> " & LogRegGetString
238end function
239
240
241''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
242' Helpers: Configuration and Batch Script Writers '
243''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
244
245''
246' Initializes the config file.
247sub CfgInit
248 FileDelete g_strCfgFile
249 CfgPrint "# -*- Makefile -*-"
250 CfgPrint "#"
251 CfgPrint "# Build configuration generated by " & GetCommandline()
252 CfgPrint "#"
253 CfgPrintAssign "VBOX_OSE", "1"
254 CfgPrintAssignRecursive "VBOX_VCC_WERR", "$(NO_SUCH_VARIABLE)"
255end sub
256
257
258''
259' Prints a string to the config file.
260sub CfgPrint(str)
261 FileAppendLine g_strCfgFile, str
262end sub
263
264''
265' Prints a simple assignment to the config file.
266sub CfgPrintAssign(strVar, strValue)
267 if strValue = "" then
268 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " :="
269 else
270 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " := " & strValue
271 end if
272end sub
273
274''
275' Prints a recursive assignment to the config file.
276sub CfgPrintAssignRecursive(strVar, strValue)
277 FileAppendLine g_strCfgFile, RightPad(strVar, 23) & " = " & strValue
278end sub
279
280
281''
282' Initializes the environment batch script.
283sub EnvInit
284 FileDelete g_strEnvFile
285 EnvPrint "@echo off"
286 EnvPrint "rem"
287 EnvPrint "rem Environment setup script generated by " & GetCommandline()
288 EnvPrint "rem"
289end sub
290
291
292''
293' Prints a string to the environment batch script.
294sub EnvPrint(str)
295 FileAppendLine g_strEnvFile, str
296end sub
297
298
299''
300' Helper for EnvPrintPrepend and EnvPrintAppend.
301sub EnvPrintCleanup(strEnv, strValue, strSep)
302 dim cchValueAndSep
303 FileAppendLine g_strEnvFile, "set " & strEnv & "=%" & strEnv & ":" & strSep & strValue & strSep & "=" & strSep & "%"
304 cchValueAndSep = Len(strValue) + Len(strSep)
305 FileAppendLine g_strEnvFile, "if ""%" & strEnv & "%""==""" & strValue & """ set " & strEnv & "="
306 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0," & cchValueAndSep & "%""==""" & strValue & strSep & """ set " & strEnv & "=%" & strEnv & ":~" & cchValueAndSep & "%"
307 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-" & cchValueAndSep & "%""==""" & strSep & strValue & """ set " & strEnv & "=%" & strEnv & ":~0,-" & cchValueAndSep & "%"
308end sub
309
310
311'' Use by EnvPrintPrepend to skip ';' stripping.
312dim g_strPrependCleanEnvVars
313
314''
315' Print a statement prepending strValue to strEnv, removing duplicate values.
316sub EnvPrintPrepend(strEnv, strValue, strSep)
317 ' Remove old values and any leading separators.
318 EnvPrintCleanup strEnv, strValue, strSep
319 if InStr(1, g_strPrependCleanEnvVars, "|" & strEnv & "|") = 0 then
320 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0,1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~1%"
321 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~0,1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~1%"
322 g_strPrependCleanEnvVars = g_strPrependCleanEnvVars & "|" & strEnv & "|"
323 end if
324 ' Do the setting
325 FileAppendLine g_strEnvFile, "set " & strEnv & "=" & strValue & strSep & "%" & strEnv & "%"
326end sub
327
328
329'' Use by EnvPrintPrepend to skip ';' stripping.
330dim g_strAppendCleanEnvVars
331
332''
333' Print a statement appending strValue to strEnv, removing duplicate values.
334sub EnvPrintAppend(strEnv, strValue, strSep)
335 ' Remove old values and any trailing separators.
336 EnvPrintCleanup strEnv, strValue, strSep
337 if InStr(1, g_strAppendCleanEnvVars, "|" & strEnv & "|") = 0 then
338 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~0,-1%"
339 FileAppendLine g_strEnvFile, "if ""%" & strEnv & ":~-1%""==""" & strSep & """ set " & strEnv & "=%" & strEnv & ":~0,-1%"
340 g_strAppendCleanEnvVars = g_strAppendCleanEnvVars & "|" & strEnv & "|"
341 end if
342 ' Do the setting.
343 FileAppendLine g_strEnvFile, "set " & strEnv & "=%" & strEnv & "%" & strSep & strValue
344end sub
345
346
347''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
348' Feature disabling '
349''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
350
351''
352' No COM
353sub DisableCOM(strReason)
354 if g_blnDisableCOM = False then
355 LogPrint "Disabled COM components: " & strReason
356 g_blnDisableCOM = True
357 g_strDisableCOM = strReason
358 CfgPrintAssign "VBOX_WITH_MAIN", ""
359 CfgPrintAssign "VBOX_WITH_QTGUI", ""
360 CfgPrintAssign "VBOX_WITH_VBOXSDL", ""
361 CfgPrintAssign "VBOX_WITH_DEBUGGER_GUI", ""
362 end if
363end sub
364
365
366''
367' No UDPTunnel
368sub DisableUDPTunnel(strReason)
369 if g_blnDisableUDPTunnel = False then
370 LogPrint "Disabled UDPTunnel network transport: " & strReason
371 g_blnDisableUDPTunnel = True
372 g_strDisableUDPTunnel = strReason
373 CfgPrintAssign "VBOX_WITH_UDPTUNNEL", ""
374 end if
375end sub
376
377
378''
379' No SDL
380sub DisableSDL(strReason)
381 if g_blnDisableSDL = False then
382 LogPrint "Disabled SDL frontend: " & strReason
383 g_blnDisableSDL = True
384 g_strDisableSDL = strReason
385 CfgPrintAssign "VBOX_WITH_VBOXSDL", ""
386 end if
387end sub
388
389
390''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
391' Tool/Library Locating and Checking '
392''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
393
394''
395' Generic helper for looking for a tools under g_strPathDev.
396'
397' The callback function takes the '.../tools/win.arch/tool/version' dir and
398' varUser as arguments, returning an non-empty string if it was found suitable.
399'
400function SearchToolsEx(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser, ByRef arrToolsDirs)
401 dim strToolsDir, arrDirs, strDir
402 SearchToolsEx = ""
403 for each strToolsDir in arrToolsDirs
404 arrDirs = GetSubdirsStartingWithRVerSorted(strToolsDir, strVerPrefix)
405 for each strDir in arrDirs
406 SearchToolsEx = fnCallback(strToolsDir & "/" & strDir, varUser)
407 if SearchToolsEx <> "" then
408 exit function
409 end if
410 next
411 next
412end function
413
414'' Search under g_strPathDev for a tool, target arch only.
415function SearchTargetTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
416 dim i
417 redim arrToolsDirs(ArraySize(g_arrPathDev) - 1)
418 for i = 0 to UBound(g_arrPathDev)
419 arrToolsDirs(i) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
420 next
421 SearchTargetTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
422end function
423
424'' Search under g_strPathDev for a tool, target arch and alternative arches.
425function SearchTargetPlusTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
426 dim i
427 redim arrToolsDirs(ArraySize(g_arrPathDev)*3 - 1)
428 for i = 0 to UBound(g_arrPathDev)
429 arrToolsDirs(i*3 + 0) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
430 arrToolsDirs(i*3 + 1) = g_arrPathDev(i) & "/win.x86/" & strTool
431 arrToolsDirs(i*3 + 2) = g_arrPathDev(i) & "/win.amd64/" & strTool
432 next
433 SearchTargetPlusTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
434end function
435
436'' Search under g_strPathDev for a tool, host arch first.
437function SearchHostTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
438 dim i
439 redim arrToolsDirs(ArraySize(g_arrPathDev) * 3 - 1)
440 for i = 0 to UBound(g_arrPathDev)
441 arrToolsDirs(i*3 + 0) = g_arrPathDev(i) & "/win." & g_strHostArch & "/" & strTool
442 arrToolsDirs(i*3 + 1) = g_arrPathDev(i) & "/win.x86/" & strTool
443 arrToolsDirs(i*3 + 2) = g_arrPathDev(i) & "/win.amd64/" & strTool
444 next
445 SearchHostTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
446end function
447
448'' Search under g_strPathDev for a tool, common dir first.
449function SearchCommonTools(strTool, strVerPrefix, ByRef fnCallback, ByRef varUser)
450 dim i
451 redim arrToolsDirs(ArraySize(g_arrPathDev) * 4 - 1)
452 for i = 0 to UBound(g_arrPathDev)
453 arrToolsDirs(i*4 + 0) = g_arrPathDev(i) & "/win.common/" & strTool
454 arrToolsDirs(i*4 + 1) = g_arrPathDev(i) & "/win." & g_strTargetArch & "/" & strTool
455 arrToolsDirs(i*4 + 2) = g_arrPathDev(i) & "/win.x86/" & strTool
456 arrToolsDirs(i*4 + 3) = g_arrPathDev(i) & "/win.amd64/" & strTool
457 next
458 SearchCommonTools = SearchToolsEx(strTool, strVerPrefix, fnCallback, varUser, arrToolsDirs)
459end function
460
461''
462' Checks the the path doesn't contain characters the tools cannot deal with.
463'
464sub CheckSourcePath
465 dim sPwd
466
467 sPwd = PathAbsLong(g_strPath) ' Must check the long version.
468 if InStr(1, sPwd, " ") > 0 then
469 MsgError "Source path contains spaces! Please move it. (" & sPwd & ")"
470 end if
471 if InStr(1, sPwd, "$") > 0 then
472 MsgError "Source path contains the '$' char! Please move it. (" & sPwd & ")"
473 end if
474 if InStr(1, sPwd, "%") > 0 then
475 MsgError "Source path contains the '%' char! Please move it. (" & sPwd & ")"
476 end if
477 if InStr(1, sPwd, Chr(10)) > 0 _
478 or InStr(1, sPwd, Chr(13)) > 0 _
479 or InStr(1, sPwd, Chr(9)) > 0 _
480 then
481 MsgError "Source path contains control characters! Please move it. (" & sPwd & ")"
482 end if
483 Print "Source path: OK"
484end sub
485
486
487''
488' Checks for kBuild - very simple :)
489'
490sub CheckForkBuild(strOptkBuild)
491 dim blnNeedEnvVars, strOutput
492 PrintHdr "kBuild"
493
494 '
495 ' Check if there is a 'kmk' in the path somewhere without
496 ' any KBUILD_*PATH stuff around.
497 '
498 blnNeedEnvVars = True
499 g_strPathkBuild = strOptkBuild
500 g_strPathkBuildBin = ""
501 if (g_strPathkBuild = "") _
502 And (EnvGetFirst("KBUILD_PATH", "PATH_KBUILD") = "") _
503 And (EnvGetFirst("KBUILD_BIN_PATH", "PATH_KBUILD_BIN") = "") _
504 And (Shell("kmk.exe --version", True, strOutput) = 0) _
505 And (InStr(1,strOutput, "kBuild Make 0.1") > 0) _
506 And (InStr(1,strOutput, "KBUILD_PATH") > 0) _
507 And (InStr(1,strOutput, "KBUILD_BIN_PATH") > 0) then
508 '' @todo Need to parse out the KBUILD_PATH and KBUILD_BIN_PATH values to complete the other tests.
509 'blnNeedEnvVars = False
510 MsgWarning "You've installed kBuild it seems. configure.vbs hasn't been updated to " _
511 & "deal with that yet and will use the one it ships with. Sorry."
512 end if
513
514 '
515 ' Check for the KBUILD_PATH env.var. and fall back on root/kBuild otherwise.
516 '
517 if g_strPathkBuild = "" then
518 g_strPathkBuild = EnvGetFirst("KBUILD_PATH", "PATH_KBUILD")
519 if (g_strPathkBuild <> "") and (FileExists(g_strPathkBuild & "/footer.kmk") = False) then
520 MsgWarning "Ignoring incorrect kBuild path (KBUILD_PATH=" & g_strPathkBuild & ")"
521 g_strPathkBuild = ""
522 end if
523
524 if g_strPathkBuild = "" then
525 g_strPathkBuild = g_strPath & "/kBuild"
526 end if
527 end if
528
529 g_strPathkBuild = UnixSlashes(PathAbs(g_strPathkBuild))
530
531 '
532 ' Check for env.vars that kBuild uses (do this early to set g_strTargetArch).
533 '
534 str = EnvGetFirst("KBUILD_TYPE", "BUILD_TYPE")
535 if (str <> "") _
536 And (InStr(1, "|release|debug|profile|kprofile", str) <= 0) then
537 EnvPrint "set KBUILD_TYPE=release"
538 EnvSet "KBUILD_TYPE", "release"
539 MsgWarning "Found unknown KBUILD_TYPE value '" & str &"' in your environment. Setting it to 'release'."
540 end if
541
542 str = EnvGetFirst("KBUILD_TARGET", "BUILD_TARGET")
543 if (str <> "") _
544 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
545 EnvPrint "set KBUILD_TARGET=win"
546 EnvSet "KBUILD_TARGET", "win"
547 MsgWarning "Found unknown KBUILD_TARGET value '" & str &"' in your environment. Setting it to 'win32'."
548 end if
549
550 str = EnvGetFirst("KBUILD_TARGET_ARCH", "BUILD_TARGET_ARCH")
551 if (str <> "") _
552 And (InStr(1, "x86|amd64", str) <= 0) then
553 EnvPrint "set KBUILD_TARGET_ARCH=x86"
554 EnvSet "KBUILD_TARGET_ARCH", "x86"
555 MsgWarning "Found unknown KBUILD_TARGET_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
556 str = "x86"
557 end if
558 if g_strTargetArch = "" then '' command line parameter --target-arch=x86|amd64 has priority
559 if str <> "" then
560 g_strTargetArch = str
561 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
562 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
563 g_strTargetArch = "amd64"
564 else
565 g_strTargetArch = "x86"
566 end if
567 else
568 if InStr(1, "x86|amd64", g_strTargetArch) <= 0 then
569 EnvPrint "set KBUILD_TARGET_ARCH=x86"
570 EnvSet "KBUILD_TARGET_ARCH", "x86"
571 MsgWarning "Unknown --target-arch=" & str &". Setting it to 'x86'."
572 end if
573 end if
574 LogPrint " Target architecture: " & g_strTargetArch & "."
575 Wscript.Echo " Target architecture: " & g_strTargetArch & "."
576 EnvPrint "set KBUILD_TARGET_ARCH=" & g_strTargetArch
577
578 ' Windows variant of the arch name.
579 g_strTargetArchWin = g_strTargetArch
580 if g_strTargetArchWin = "amd64" then g_strTargetArchWin = "x64"
581
582 str = EnvGetFirst("KBUILD_TARGET_CPU", "BUILD_TARGET_CPU")
583 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
584 if (str <> "") _
585 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
586 EnvPrint "set BUILD_TARGET_CPU=i386"
587 EnvSet "KBUILD_TARGET_CPU", "i386"
588 MsgWarning "Found unknown KBUILD_TARGET_CPU value '" & str &"' in your environment. Setting it to 'i386'."
589 end if
590
591 str = EnvGetFirst("KBUILD_HOST", "BUILD_PLATFORM")
592 if (str <> "") _
593 And (InStr(1, "win|win32|win64", str) <= 0) then '' @todo later only 'win' will be valid. remember to fix this check!
594 EnvPrint "set KBUILD_HOST=win"
595 EnvSet "KBUILD_HOST", "win"
596 MsgWarning "Found unknown KBUILD_HOST value '" & str &"' in your environment. Setting it to 'win32'."
597 end if
598
599 str = EnvGetFirst("KBUILD_HOST_ARCH", "BUILD_PLATFORM_ARCH")
600 if str <> "" then
601 if InStr(1, "x86|amd64", str) <= 0 then
602 str = "x86"
603 MsgWarning "Found unknown KBUILD_HOST_ARCH value '" & str &"' in your environment. Setting it to 'x86'."
604 end if
605 elseif (EnvGet("PROCESSOR_ARCHITEW6432") = "AMD64" ) _
606 Or (EnvGet("PROCESSOR_ARCHITECTURE") = "AMD64" ) then
607 str = "amd64"
608 else
609 str = "x86"
610 end if
611 LogPrint " Host architecture: " & str & "."
612 Wscript.Echo " Host architecture: " & str & "."
613 EnvPrint "set KBUILD_HOST_ARCH=" & str
614 g_strHostArch = str
615
616 ' Windows variant of the arch name.
617 g_strHostArchWin = g_strHostArch
618 if g_strHostArchWin = "amd64" then g_strHostArchWin = "x64"
619
620
621 str = EnvGetFirst("KBUILD_HOST_CPU", "BUILD_PLATFORM_CPU")
622 ' perhaps a bit pedantic this since this isn't clearly define nor used much...
623 if (str <> "") _
624 And (InStr(1, "i386|i486|i686|i786|i868|k5|k6|k7|k8", str) <= 0) then
625 EnvPrint "set KBUILD_HOST_CPU=i386"
626 EnvSet "KBUILD_HOST_CPU", "i386"
627 MsgWarning "Found unknown KBUILD_HOST_CPU value '" & str &"' in your environment. Setting it to 'i386'."
628 end if
629
630 '
631 ' Determin the location of the kBuild binaries.
632 '
633 if g_strPathkBuildBin = "" then
634 g_strPathkBuildBin = g_strPathkBuild & "/bin/win." & g_strHostArch
635 if FileExists(g_strPathkBuildBin & "/kmk.exe") = False then
636 g_strPathkBuildBin = g_strPathkBuild & "/bin/win.x86"
637 end if
638 end if
639 g_strPathkBuildBin = UnixSlashes(PathAbs(g_strPathkBuildBin))
640
641 '
642 ' Perform basic validations of the kBuild installation.
643 '
644 if (FileExists(g_strPathkBuild & "/footer.kmk") = False) _
645 Or (FileExists(g_strPathkBuild & "/header.kmk") = False) _
646 Or (FileExists(g_strPathkBuild & "/rules.kmk") = False) then
647 MsgFatal "Can't find valid kBuild at '" & g_strPathkBuild & "'. Either there is an " _
648 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
649 exit sub
650 end if
651 if (FileExists(g_strPathkBuildBin & "/kmk.exe") = False) _
652 Or (FileExists(g_strPathkBuildBin & "/kmk_ash.exe") = False) then
653 MsgFatal "Can't find valid kBuild binaries at '" & g_strPathkBuildBin & "'. Either there is an " _
654 & "incorrect KBUILD_PATH in the environment or the checkout didn't succeed."
655 exit sub
656 end if
657
658 if (Shell(DosSlashes(g_strPathkBuildBin & "/kmk.exe") & " --version", True, strOutput) <> 0) then
659 MsgFatal "Can't execute '" & g_strPathkBuildBin & "/kmk.exe --version'. check configure.log for the out."
660 exit sub
661 end if
662
663 '
664 ' If KBUILD_DEVTOOLS is set, check that it's pointing to something useful.
665 '
666 str = UnixSlashes(EnvGet("KBUILD_DEVTOOLS"))
667 g_strPathDev = str
668 if str <> "" _
669 and LogDirExists(str & "/bin") _
670 and LogDirExists(str & "/win.amd64/bin") _
671 and LogDirExists(str & "/win.x86/bin") _
672 then
673 LogPrint "Found KBUILD_DEVTOOLS='" & str & "'."
674 elseif str <> "" then
675 MsgWarning "Ignoring bogus KBUILD_DEVTOOLS='" & str &"' in your environment!"
676 g_strPathDev = strNew
677 end if
678 if g_strPathDev = "" then
679 g_strPathDev = UnixSlashes(g_strPath & "/tools")
680 LogPrint "Using KBUILD_DEVTOOLS='" & g_strPathDev & "'."
681 if str <> "" then
682 EnvPrint "set KBUILD_DEVTOOLS=" & g_strPathDev
683 EnvSet "KBUILD_DEVTOOLS", g_strPathDev
684 end if
685 end if
686 g_arrPathDev(ArrayFindString(g_arrPathDev, ":placeholder:")) = g_strPathDev
687
688 '
689 ' Write KBUILD_PATH and updated PATH to the environment script if necessary.
690 '
691 if blnNeedEnvVars = True then
692 EnvPrint "set KBUILD_PATH=" & g_strPathkBuild
693 EnvSet "KBUILD_PATH", g_strPathkBuild
694
695 if Right(g_strPathkBuildBin, 7) = "win.x86" then
696 EnvPrintCleanup "PATH", DosSlashes(Left(g_strPathkBuildBin, Len(g_strPathkBuildBin) - 7) & "win.amd64"), ";"
697 end if
698 if Right(g_strPathkBuildBin, 9) = "win.amd64" then
699 EnvPrintCleanup "PATH", DosSlashes(Left(g_strPathkBuildBin, Len(g_strPathkBuildBin) - 9) & "win.x86"), ";"
700 end if
701 EnvPrintPrepend "PATH", DosSlashes(g_strPathkBuildBin), ";"
702 EnvPrepend "PATH", g_strPathkBuildBin & ";"
703 end if
704
705 PrintResult "kBuild", g_strPathkBuild
706 PrintResult "kBuild binaries", g_strPathkBuildBin
707end sub
708
709
710''
711' Checks for Visual C++ version 16 (2019), 15 (2017), 14 (2015), 12 (2013), 11 (2012) or 10 (2010).
712'
713sub CheckForVisualCPP(strOptVC, strOptVCCommon)
714 PrintHdr "Visual C++"
715
716 '
717 ' Try find it...
718 '
719 dim objState, strProgFiles
720 set objState = new VisualCPPState
721 objState.check strOptVC, strOptVCCommon
722 if g_blnInternalFirst = True then objState.checkInternal
723 objState.checkProgItems "2019"
724 objState.checkProgFiles "Microsoft Visual Studio\2019\BuildTools\VC"
725 objState.checkProgFiles "Microsoft Visual Studio\2019\Professional\VC"
726 objState.checkProgFiles "Microsoft Visual Studio\2019\Community\VC"
727 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\16.0", "VC", "" ' doesn't work.
728 objState.checkProgItems "2017"
729 objState.checkProgFiles "Microsoft Visual Studio\2017\BuildTools\VC"
730 objState.checkProgFiles "Microsoft Visual Studio\2017\Professional\VC"
731 objState.checkProgFiles "Microsoft Visual Studio\2017\Community\VC"
732 objState.checkProgFiles "Microsoft Visual Studio\2017\Express\VC"
733 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\15.0", "VC", ""
734 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\14.0", "VC", "Common7"
735 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\12.0", "VC", "Common7" '?
736 objState.checkRegistry "Microsoft\VisualStudio\SxS\VS7\11.0", "VC", "Common7" '?
737 objState.checkProg "cl.exe"
738 objState.checkRegistry "Microsoft\VisualStudio\10.0\Setup\VS\ProductDir", "VC", "Common7"
739 if g_blnInternalFirst = False then objState.checkInternal
740
741 if objState.m_blnFound = False then
742 MsgError "Cannot find cl.exe (Visual C++) anywhere on your system. Check the build requirements."
743 exit sub
744 end if
745 g_strPathVCC = objState.m_strPathVC
746 g_strVCCVersion = objState.m_strVersion
747
748 '
749 ' Ok, emit build config variables.
750 '
751 CfgPrintAssign "VBOX_VCC_TOOL_STEM", objState.m_strVersion
752 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion, g_strPathVCC
753 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion & "X86", "$(PATH_TOOL_" & objState.m_strVersion & ")"
754 CfgPrintAssign "PATH_TOOL_" & objState.m_strVersion & "AMD64", "$(PATH_TOOL_" & objState.m_strVersion & ")"
755
756 if objState.m_strVersion = "VCC100" _
757 or objState.m_strVersion = "VCC110" _
758 or objState.m_strVersion = "VCC120" _
759 or objState.m_strVersion = "VCC140" _
760 then
761 CfgPrintAssign "VBOX_WITH_NEW_VCC", "" '?? for VCC110+
762 else
763 CfgPrintAssign "VBOX_WITH_NEW_VCC", "1"
764 end if
765 PrintResult "Visual C++ " & objState.m_strVersion, g_strPathVCC
766
767 ' And the env.bat path fix.
768 if objState.m_strPathVCCommon <> "" then
769 EnvPrintAppend "PATH", DosSlashes(objState.m_strPathVCCommon) & "\IDE", ";"
770 end if
771end sub
772
773'' Class we use for detecting Visual C++
774class VisualCPPState
775 public m_blnFound
776 public m_strPathVC
777 public m_strPathVCCommon
778 public m_strVersion
779 public m_strClVersion
780 public m_blnNewLayout
781
782 private sub Class_Initialize
783 m_blnFound = False
784 m_strPathVC = ""
785 m_strPathVCCommon = ""
786 m_strVersion = ""
787 m_strClVersion = ""
788 m_blnNewLayout = false
789 end sub
790
791 public function checkClExe(strClExe)
792 ' We'll have to make sure mspdbXX.dll is somewhere in the PATH.
793 dim strSavedPath, rcExit, strOutput
794
795 strSavedPath = EnvGet("PATH")
796 if (m_strPathVCCommon <> "") then
797 EnvAppend "PATH", ";" & m_strPathVCCommon & "/IDE"
798 end if
799 rcExit = Shell(DosSlashes(strClExe), True, strOutput)
800 EnvSet "PATH", strSavedPath
801
802 checkClExe = False
803 if rcExit = 0 then
804 ' Extract the ' Version xx.yy.build.zz for arch' bit.
805 dim offVer, offEol, strVer
806 strVer = ""
807 offVer = InStr(1, strOutput, " Version ")
808 if offVer > 0 then
809 offVer = offVer + Len(" Version ")
810 offEol = InStr(offVer, strOutput, Chr(13))
811 if offEol > 0 then
812 strVer = Trim(Mid(strOutput, offVer, offEol - offVer))
813 end if
814 end if
815
816 ' Check that it's a supported version
817 checkClExe = True
818 if InStr(1, strVer, "16.") = 1 then
819 m_strVersion = "VCC110"
820 elseif InStr(1, strVer, "17.") = 1 then
821 m_strVersion = "VCC111"
822 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer
823 elseif InStr(1, strVer, "18.") = 1 then
824 m_strVersion = "VCC112"
825 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer
826 elseif InStr(1, strVer, "19.0") = 1 then
827 m_strVersion = "VCC140"
828 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer
829 elseif InStr(1, strVer, "19.1") = 1 then
830 m_strVersion = "VCC141"
831 LogPrint "The Visual C++ compiler ('" & strClExe & "') version isn't really supported, but may work: " & strVer
832 elseif InStr(1, strVer, "19.2") = 1 then
833 m_strVersion = "VCC142"
834 else
835 LogPrint "The Visual C++ compiler we found ('" & strClExe & "') isn't in the 10.0-19.2x range (" & strVer & ")."
836 LogPrint "Check the build requirements and select the appropriate compiler version."
837 checkClExe = False
838 exit function
839 end if
840 LogPrint "'" & strClExe & "' = " & m_strVersion & " (" & strVer & ")"
841 else
842 LogPrint "Executing '" & strClExe & "' (which we believe to be the Visual C++ compiler driver) failed (rcExit=" & rcExit & ")."
843 end if
844 end function
845
846 public function checkInner(strPathVC) ' For the new layout only
847 if m_blnFound = False then
848 if LogDirExists(strPathVC & "/bin") _
849 and LogDirExists(strPathVC & "/lib") _
850 and LogDirExists(strPathVC & "/include") _
851 and LogFileExists(strPathVC, "include/stdarg.h") _
852 and LogFileExists(strPathVC, "lib/x64/libcpmt.lib") _
853 and LogFileExists(strPathVC, "lib/x86/libcpmt.lib") _
854 and LogFileExists(strPathVC, "bin/Host" & g_strHostArchWin & "/" & g_strTargetArchWin & "/cl.exe") _
855 and LogFileExists(strPathVC, "bin/Host" & g_strHostArchWin & "/" & g_strHostArchWin & "/cl.exe") _
856 then
857 LogPrint " => seems okay. new layout."
858 m_blnFound = checkClExe(strPathVC & "/bin/Host" & g_strHostArchWin & "/" & g_strTargetArchWin & "/cl.exe")
859 if m_blnFound then
860 m_strPathVC = strPathVC
861 end if
862 end if
863 end if
864 checkInner = m_blnFound
865 end function
866
867 public function check(strPathVC, strPathVCommon)
868 if (m_blnFound = False) and (strPathVC <> "") then
869 m_strPathVC = UnixSlashes(PathAbs(strPathVC))
870 m_strPathVCCommon = strPathVCCommon
871 m_strVersion = ""
872
873 LogPrint "Trying: strPathVC=" & m_strPathVC & " strPathVCCommon=" & m_strPathVCCommon
874 if LogDirExists(m_strPathVC) then
875 ' 15.0+ layout? This is fun because of the multiple CL versions (/tools/msvc/xx.yy.bbbbb/).
876 ' OTOH, the user may have pointed us directly to one of them.
877 if LogDirExists(m_strPathVC & "/Tools/MSVC") then
878 m_blnNewLayout = True
879 LogPrint " => seems okay. new layout."
880 dim arrFolders, i
881 arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "14.2")
882 if UBound(arrFolders) < 0 then arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "14.1")
883 if UBound(arrFolders) < 0 then arrFolders = GetSubdirsStartingWithVerSorted(m_strPathVC & "/Tools/MSVC", "1")
884 for i = UBound(arrFolders) to LBound(arrFolders) step -1
885 if checkInner(m_strPathVC & "/Tools/MSVC/" & arrFolders(i)) then exit for ' modifies m_strPathVC on success
886 next
887 elseif LogDirExists(m_strPathVC & "/bin/HostX64") _
888 or LogDirExists(m_strPathVC & "/bin/HostX86") then
889 checkInner(m_strPathVC)
890 ' 14.0 and older layout?
891 elseif LogFileExists(m_strPathVC, "/bin/cl.exe") then
892 m_blnNewLayout = False
893 if LogFileExists(m_strPathVC, "bin/link.exe") _
894 and LogFileExists(m_strPathVC, "include/string.h") _
895 and LogFileExists(m_strPathVC, "lib/libcmt.lib") _
896 and LogFileExists(m_strPathVC, "lib/msvcrt.lib") _
897 then
898 LogPrint " => seems okay. old layout."
899 m_blnFound = checkClExe(m_strPathVC & "/bin/cl.exe")
900 end if
901 end if
902 end if
903 end if
904 check = m_bldFound
905 end function
906
907 public function checkProg(strProg)
908 if m_blnFound = False then
909 dim str, i, offNewLayout
910 str = Which(strProg)
911 if str <> "" then
912 LogPrint "checkProg: '" & strProg & "' -> '" & str & "'"
913 if FileExists(PathStripFilename(str) & "/build.exe") then
914 Warning "Ignoring DDK cl.exe (" & str & ")." ' don't know how to deal with this cl.
915 else
916 ' Assume we've got cl.exe from somewhere under the 'bin' directory..
917 m_strPathVC = PathParent(PathStripFilename(str))
918 for i = 1 To 5
919 if LogDirExists(m_strPathVC & "/include") then
920 m_strPathVCCommon = PathParent(m_strPathVC) & "/Common7"
921 if DirExists(m_strPathVCCommon) = False then
922 m_strPathVCCommon = ""
923 ' New layout?
924 offNewLayout = InStr(1, LCase(DosSlashes(m_strPathVC)), "\tools\msvc\")
925 if offNewLayout > 0 then m_strPathVC = Left(m_strPathVC, offNewLayout)
926 end if
927 check m_strPathVC, m_strPathVCCommon
928 exit for
929 end if
930 m_strPathVC = PathParent(m_strPathVC)
931 next
932 end if
933 end if
934 end if
935 checkProg = m_bldFound
936 end function
937
938 public function checkProgFiles(strSubdir)
939 if m_blnFound = False then
940 dim strProgFiles
941 for each strProgFiles in g_arrProgramFiles
942 check strProgFiles & "/" & strSubdir, ""
943 next
944 end if
945 checkProgFiles = m_blnFound
946 end function
947
948 public function checkRegistry(strValueNm, strVCSubdir, strVCommonSubdir)
949 if m_blnFound = False then
950 dim str, strPrefix, arrPrefixes
951 arrPrefixes = Array("HKLM\SOFTWARE\Wow6432Node\", "HKLM\SOFTWARE\", "HKCU\SOFTWARE\Wow6432Node\", "HKCU\SOFTWARE\")
952 for each strPrefix in arrPrefixes
953 str = LogRegGetString(strPrefix & strValueNm)
954 if str <> "" then
955 LogPrint "checkRegistry: '" & strPrefix & strValueNm & "' -> '" & str & "'"
956 if check(str & strVCSubdir, str & strVCommonSubdir) = True then
957 exit for
958 end if
959 end if
960 next
961 end if
962 checkRegistry = m_bldFound
963 end function
964
965 public function checkProgItems(strVersionYear)
966 if m_blnFound = False then
967 dim strCandidate
968 for each strCandidate in CollectFromProgramItemLinks(GetRef("VisualCPPCallback"), strVersionYear)
969 check strCandidate, ""
970 next
971 end if
972 checkProgItems = m_blnFound
973 end function
974
975 public function checkInternal
976 dim strPathDev
977 for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.2", "" : next
978 for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.2", "" : next
979 for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.1", "" : next
980 for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v14.0", "" : next
981 for each strPathDev in g_arrPathDev : check strPathDev & "/win.amd64/vcc/v10sp1", "" : next
982 for each strPathDev in g_arrPathDev : check strPathDev & "/win.x86/vcc/v10sp1", "" : next
983 checkInternal = m_blnFound
984 end function
985end class
986
987' See checkProgItems()
988function VisualCPPCallback(ByRef arrStrings, cStrings, ByRef strVersionYear)
989 VisualCPPCallback = ""
990 ' We're looking for items with three strings like this:
991 ' C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2019.lnk
992 ' C:\Windows\system32\cmd.exe
993 ' /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvars64.bat"
994 if cStrings >= 3 then
995 if InStr(1, arrStrings(0), strVersionYear) > 0 then
996 dim strTail : strTail = "\Auxiliary\Build\vcvars64.bat"""
997 dim str : str = arrStrings(UBound(arrStrings))
998 if StrComp(Right(str, Len(strTail)), strTail, vbTextCompare) = 0 then
999 dim offColon : offColon = InStr(1, str, ":")
1000 if offColon > 1 then
1001 VisualCPPCallback = Mid(str, offColon - 1, Len(str) - (offColon - 2) - Len(strTail))
1002 end if
1003 end if
1004 end if
1005 end if
1006end function
1007
1008
1009''
1010' Checks for a platform SDK that works with the compiler
1011'
1012sub CheckForPlatformSDK(strOptSDK)
1013 dim strPathPSDK, strVersion, strSubKey, str, strHkey
1014 PrintHdr "Windows Platform SDK (recent)"
1015
1016 '
1017 ' Search for it.
1018 '
1019
1020 ' Check the supplied argument first.
1021 strPathPSDK = CheckForPlatformSDKSub(strOptSDK, strVersion)
1022
1023 ' The tools location (first).
1024 if strPathPSDK = "" and g_blnInternalFirst = true then strPathPSDK = SearchTargetPlusTools("sdk", "v7.1", GetRef("CheckForPlatformSDKSub"), strVersion)
1025 if strPathPSDK = "" and g_blnInternalFirst = true then strPathPSDK = SearchTargetPlusTools("sdk", "v8.0", GetRef("CheckForPlatformSDKSub"), strVersion)
1026
1027 ' Look for it in the environment
1028 if strPathPSDK = "" then strPathPSDK = CheckForPlatformSDKSub(EnvGet("MSSdk"), strVersion)
1029 if strPathPSDK = "" then strPathPSDK = CheckForPlatformSDKSub(EnvGet("Mstools"), strVersion)
1030
1031 ' Check if there is one installed with the compiler.
1032 if strPathPSDK = "" then strPathPSDK = CheckForPlatformSDKSub(g_strPathVCC & "/PlatformSDK", strVersion)
1033
1034 ' Check the registry next (ASSUMES sorting).
1035 if strPathPSDK = "" then
1036 for each strHkey in Array("HKLM", "HKCU")
1037 for each strSubKey in RegEnumSubKeysRVerSorted(strHkey, "SOFTWARE\Microsoft\Microsoft SDKs\Windows")
1038 str = LogRegGetString(strHkey & "\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder")
1039 strPathPSDK = CheckForPlatformSDKSub(str, strVersion)
1040 if strPathPSDK <> "" then exit for
1041 next
1042 if strPathPSDK <> "" then exit for
1043 next
1044 end if
1045
1046 ' The tools location (post).
1047 if strPathPSDK = "" and g_blnInternalFirst = false then strPathPSDK = SearchTargetPlusTools("sdk", "v7.1", GetRef("CheckForPlatformSDKSub"), strVersion)
1048 if strPathPSDK = "" and g_blnInternalFirst = false then strPathPSDK = SearchTargetPlusTools("sdk", "v8.0", GetRef("CheckForPlatformSDKSub"), strVersion)
1049
1050 ' Give up.
1051 if strPathPSDK = "" then
1052 MsgError "Cannot find a suitable Platform SDK. Check configure.log and the build requirements."
1053 exit sub
1054 end if
1055
1056 '
1057 ' Emit the config.
1058 '
1059 strPathPSDK = UnixSlashes(PathAbs(strPathPSDK))
1060 CfgPrintAssign "PATH_SDK_WINPSDK" & strVersion, strPathPSDK
1061 CfgPrintAssign "VBOX_WINPSDK", "WINPSDK" & strVersion
1062
1063 PrintResult "Windows Platform SDK", strPathPSDK
1064 PrintResultMsg "Windows Platform SDK version", strVersion
1065 g_strVerPSDK = strVersion
1066 g_strPathPSDK = strPathPSDK
1067end sub
1068
1069'' Checks if the specified path points to a usable PSDK.
1070function CheckForPlatformSDKSub(strPathPSDK, ByRef strVersion)
1071 dim strOutput
1072 CheckForPlatformSDKSub = ""
1073 if strPathPSDK <> "" then
1074 LogPrint "Trying: strPathPSDK=" & strPathPSDK
1075 if LogFileExists(strPathPSDK, "include/Windows.h") _
1076 and LogFileExists(strPathPSDK, "lib/Kernel32.Lib") _
1077 and LogFileExists(strPathPSDK, "lib/User32.Lib") _
1078 and LogFileExists(strPathPSDK, "bin/rc.exe") _
1079 and Shell("""" & DosSlashes(strPathPSDK & "/bin/rc.exe") & """" , True, strOutput) <> 0 _
1080 then
1081 if InStr(1, strOutput, "Resource Compiler Version 6.2.") > 0 then
1082 strVersion = "80"
1083 CheckForPlatformSDKSub = UnixSlashes(PathAbs(strPathPSDK))
1084 elseif InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 then
1085 strVersion = "71"
1086 CheckForPlatformSDKSub = UnixSlashes(PathAbs(strPathPSDK))
1087 end if
1088 end if
1089 end if
1090end function
1091
1092
1093''
1094' Checks for a windows 10 SDK (later also WDK).
1095'
1096sub CheckForSDK10(strOptSDK10, strOptSDK10Version)
1097 dim strPathSDK10, strSDK10Version, str
1098 PrintHdr "Windows 10 SDK/WDK"
1099 '' @todo implement strOptSDK10Version
1100
1101 '
1102 ' Try find the Windows 10 kit.
1103 '
1104 strSDK10Version = ""
1105 strPathSDK10 = CheckForSDK10Sub(strOptSDK10, strSDK10Version)
1106 if strPathSDK10 = "" and g_blnInternalFirst = true then
1107 strPathSDK10 = SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version)
1108 end if
1109
1110 if strPathSDK10 = "" then
1111 str = LogRegGetString("HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots\KitsRoot10")
1112 strPathSDK10 = CheckForSDK10Sub(str, strSDK10Version)
1113 end if
1114 if strPathSDK10 = "" then
1115 for each str in g_arrProgramFiles
1116 strPathSDK10 = CheckForSDK10Sub(str & "/Windows Kits/10", strSDK10Version)
1117 if strPathSDK10 <> "" then exit for
1118 next
1119 end if
1120 if strPathSDK10 = "" and g_blnInternalFirst = true then
1121 strPathSDK10 = SearchTargetPlusTools("sdk", "v10.", GetRef("CheckForSDK10Sub"), strSDK10Version)
1122 end if
1123
1124 if strPathSDK10 = "" then
1125 MsgError "Cannot find a suitable Windows 10 SDK. Check configure.log and the build requirements."
1126 exit sub
1127 end if
1128
1129 '
1130 ' Emit the config.
1131 '
1132 strPathSDK10 = UnixSlashes(PathAbs(strPathSDK10))
1133 CfgPrintAssign "PATH_SDK_WINSDK10", strPathSDK10
1134 CfgPrintAssign "SDK_WINSDK10_VERSION", strSDK10Version
1135
1136 PrintResult "Windows 10 SDK", strPathSDK10
1137 PrintResultMsg "Windows 10 SDK version", strSDK10Version
1138 g_strPathSDK10 = strPathSDK10
1139end sub
1140
1141'' Checks if the specified path points to a usable Windows 10 SDK/WDK.
1142function CheckForSDK10Sub(strPathSDK10, ByRef strSDK10Version)
1143 CheckForSDK10Sub = ""
1144 if strPathSDK10 <> "" then
1145 LogPrint "Trying: strPathSDK10=" & strPathSDK10
1146 if LogDirExists(strPathSDK10) then
1147 if LogDirExists(strPathSDK10 & "/Bin") _
1148 and LogDirExists(strPathSDK10 & "/Include") _
1149 and LogDirExists(strPathSDK10 & "/Lib") _
1150 and LogDirExists(strPathSDK10 & "/Redist") _
1151 then
1152 ' Only testing the highest one, for now. '' @todo incorporate strOptSDK10Version
1153 dim arrVersions
1154 arrVersions = GetSubdirsStartingWithVerSorted(strPathSDK10 & "/Include", "10.0.")
1155 if UBound(arrVersions) >= 0 then
1156 dim strVersion
1157 strVersion = arrVersions(UBound(arrVersions))
1158 LogPrint "Trying version: " & strVersion
1159 if LogFileExists(strPathSDK10, "include/" & strVersion & "/um/Windows.h") _
1160 and LogFileExists(strPathSDK10, "include/" & strVersion & "/ucrt/malloc.h") _
1161 and LogFileExists(strPathSDK10, "include/" & strVersion & "/ucrt/stdio.h") _
1162 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/um/" & g_strTargetArchWin & "/kernel32.lib") _
1163 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/um/" & g_strTargetArchWin & "/user32.lib") _
1164 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/ucrt/" & g_strTargetArchWin & "/libucrt.lib") _
1165 and LogFileExists(strPathSDK10, "lib/" & strVersion & "/ucrt/" & g_strTargetArchWin & "/ucrt.lib") _
1166 and LogFileExists(strPathSDK10, "bin/" & strVersion & "/" & g_strHostArchWin & "/rc.exe") _
1167 and LogFileExists(strPathSDK10, "bin/" & strVersion & "/" & g_strHostArchWin & "/midl.exe") _
1168 then
1169 if StrComp(strVersion, "10.0.17134.0") >= 0 then
1170 strSDK10Version = strVersion
1171 CheckForSDK10Sub = strPathSDK10
1172 else
1173 LogPrint "Version " & strVersion & " is too low, minimum: 10.0.17134.0"
1174 end if
1175 end if
1176 else
1177 LogPrint "Found no 10.0.* subdirectories under '" & strPathSDK10 & "/Include'!"
1178 end if
1179 end if
1180 end if
1181 end if
1182end function
1183
1184
1185''
1186' Locating a Windows 7 Driver Kit.
1187'
1188sub CheckForWinDDK(strOptDDK)
1189 dim strPathDDK, str, strSubKeys
1190 PrintHdr "Windows DDK v7.1"
1191
1192 '
1193 ' Find the DDK.
1194 '
1195 strPathDDK = CheckForWinDDKSub(strOptDDK, True)
1196
1197 ' The tools location (first).
1198 if strPathDDK = "" and g_blnInternalFirst = true then
1199 for each str in g_arrPathDev
1200 strPathDDK = CheckForWinDDKSub(str & "/win.x86/ddk/7600.16385.1", False)
1201 if strPathDDK <> "" then exit for
1202 next
1203 end if
1204
1205 ' Check the environment
1206 if strPathDDK = "" then strPathDDK = CheckForWinDDKSub(PathParent(PathParent(EnvGet("DDK_INC_PATH"))), True)
1207 if strPathDDK = "" then strPathDDK = CheckForWinDDKSub(EnvGet("BASEDIR"), True)
1208
1209 ' Some array constants to ease the work.
1210 arrSoftwareKeys = array("SOFTWARE", "SOFTWARE\Wow6432Node")
1211 arrRoots = array("HKLM", "HKCU")
1212
1213 ' Windows 7 WDK.
1214 if strPathDDK = "" then
1215 arrLocations = array()
1216 for each strSoftwareKey in arrSoftwareKeys
1217 for each strSubKey in RegEnumSubKeysFull("HKLM", strSoftwareKey & "\Microsoft\KitSetup\configured-kits")
1218 for each strSubKey2 in RegEnumSubKeysFull("HKLM", strSubKey)
1219 str = LogRegGetString("HKLM\" & strSubKey2 & "\setup-install-location")
1220 if str <> "" then
1221 arrLocations = ArrayAppend(arrLocations, PathAbsLong(str))
1222 end if
1223 next
1224 next
1225 next
1226 arrLocations = ArrayRVerSortStrings(arrLocations)
1227
1228 ' Check the locations we've gathered.
1229 for each str in arrLocations
1230 strPathDDK = CheckForWinDDKSub(str, True)
1231 if strPathDDK <> "" then exit for
1232 next
1233 end if
1234
1235 ' The tools location (post).
1236 if strPathDDK = "" and g_blnInternalFirst = false then
1237 for each str in g_arrPathDev
1238 strPathDDK = CheckForWinDDKSub(str & "/win.x86/ddk/7600.16385.1", False)
1239 if strPathDDK <> "" then exit for
1240 next
1241 end if
1242
1243 ' Give up.
1244 if strPathDDK = "" then
1245 MsgError "Cannot find the Windows DDK v7.1. Check configure.log and the build requirements."
1246 exit sub
1247 end if
1248
1249 '
1250 ' Emit the config.
1251 '
1252 strPathDDK = UnixSlashes(PathAbs(strPathDDK))
1253 CfgPrintAssign "PATH_SDK_WINDDK71", strPathDDK
1254
1255 PrintResult "Windows DDK v7.1", strPathDDK
1256 g_strPathDDK = strPathDDK
1257end sub
1258
1259'' Quick check if the DDK is in the specified directory or not.
1260function CheckForWinDDKSub(strPathDDK, blnCheckBuild)
1261 CheckForWinDDKSub = ""
1262 if strPathDDK <> "" then
1263 dim strOutput
1264 LogPrint "Trying: strPathDDK=" & strPathDDK & " blnCheckBuild=" & blnCheckBuild
1265 if LogFileExists(strPathDDK, "inc/api/ntdef.h") _
1266 And LogFileExists(strPathDDK, "lib/win7/i386/int64.lib") _
1267 And LogFileExists(strPathDDK, "lib/wlh/i386/int64.lib") _
1268 And LogFileExists(strPathDDK, "lib/wnet/i386/int64.lib") _
1269 And LogFileExists(strPathDDK, "lib/wxp/i386/int64.lib") _
1270 And Not LogFileExists(strPathDDK, "lib/win8/i386/int64.lib") _
1271 And LogFileExists(strPathDDK, "bin/x86/rc.exe") _
1272 then
1273 if Not blnCheckBuild then
1274 CheckForWinDDKSub = strPathDDK
1275 '' @todo Find better build check.
1276 elseif Shell("""" & DosSlashes(strPathDDK & "/bin/x86/rc.exe") & """" , True, strOutput) <> 0 _
1277 and InStr(1, strOutput, "Resource Compiler Version 6.1.") > 0 _
1278 then
1279 CheckForWinDDKSub = strPathDDK
1280 end if
1281 end if
1282 end if
1283end function
1284
1285
1286''
1287' Locating midl.exe
1288'
1289sub CheckForMidl(strOptMidl)
1290 dim strMidl, str
1291 PrintHdr "Midl.exe"
1292
1293 ' Skip if no COM/ATL.
1294 if g_blnDisableCOM then
1295 PrintResultMsg "Midl.exe", "Skipped (" & g_strDisableCOM & ")"
1296 exit sub
1297 end if
1298
1299 strMidl = CheckForMidlSub(strOptMidl)
1300 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathSDK10 & "/bin/" & g_strHostArchWin & "/Midl.exe")
1301 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathSDK10 & "/bin/x86/Midl.exe")
1302 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathPSDK & "/bin/Midl.exe")
1303 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathVCC & "/Common7/Tools/Bin/Midl.exe")
1304 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/" & g_strHostArchWin & "/Midl.exe")
1305 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/x86/Midl.exe")
1306 if strMidl = "" then strMidl = CheckForMidlSub(g_strPathDDK & "/bin/Midl.exe")
1307 if strMidl = "" then
1308 for each str in g_arrPathDev
1309 strMidl = CheckForMidlSub(str & "/win." & g_strHostArchWin & "/bin/Midl.exe")
1310 if strMidl <> "" then exit for
1311 strMidl = CheckForMidlSub(str & "/win.x86/bin/Midl.exe")
1312 if strMidl <> "" then exit for
1313 next
1314 end if
1315
1316 if strMidl = "" then
1317 PrintResultMsg "Midl.exe", "not found"
1318 else
1319 CfgPrintAssign "VBOX_MAIN_IDL", strMidl
1320 PrintResult "Midl.exe", strMidl
1321 end if
1322end sub
1323
1324function CheckForMidlSub(strMidl)
1325 CheckForMidlSub = ""
1326 if strMidl <> "" then
1327 if LogFileExists1(strMidl) then
1328 CheckForMidlSub = UnixSlashes(PathAbs(strMidl))
1329 end if
1330 end if
1331end function
1332
1333
1334''
1335' Locating yasm.exe
1336'
1337sub CheckForYasm(strOptYasm)
1338 dim strPathYasm, strVersion
1339 PrintHdr "yasm"
1340
1341 strVersion = ""
1342 strPathYasm = CheckForYasmSub(strOptYasm, strVersion)
1343 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(strOptYasm), strVersion)
1344 if strPathYasm = "" and g_blnInternalFirst = true then
1345 strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion)
1346 end if
1347 if strPathYasm = "" then strPathYasm = CheckForYasmSub(PathStripFilename(Which("yasm.exe")), strVersion)
1348 if strPathYasm = "" and g_blnInternalFirst = false then
1349 strPathYasm = SearchHostTools("yasm", "v", GetRef("CheckForYasmSub"), strVersion)
1350 end if
1351
1352 if strPathYasm = "" then
1353 PrintResultMsg "yasm", "not found"
1354 MsgError "Unable to locate yasm!"
1355 else
1356 CfgPrintAssign "PATH_TOOL_YASM", strPathYasm
1357 PrintResult "yasm v" & strVersion, strPathYasm
1358 end if
1359end sub
1360
1361function CheckForYasmSub(strPathYasm, ByRef strVersion)
1362 CheckForYasmSub = ""
1363 if strPathYasm <> "" then
1364 if LogFileExists(strPathYasm, "yasm.exe") then
1365 dim strOutput
1366 if Shell("""" & DosSlashes(strPathYasm & "\yasm.exe") & """ --version", True, strOutput) = 0 then
1367 dim strPreamble : strPreamble = "yasm"
1368 dim strVer : strVer = Trim(StrGetFirstLine(strOutput))
1369 if StrComp(Left(strVer, Len(strPreamble)), strPreamble, vbTextCompare) = 0 then
1370 strVersion = StrGetFirstWord(Trim(Mid(strVer, Len(strPreamble) + 1)))
1371 if StrVersionCompare(strVersion, "1.3.0") >= 0 and strVersion <> "" then
1372 LogPrint "Found yasm version: " & strVer
1373 CheckForYasmSub = UnixSlashes(PathAbs(strPathYasm))
1374 else
1375 LogPrint "yasm version is older than 1.3.0: " & strVersion
1376 end if
1377 else
1378 LogPrint "Not yasm: " & strVer
1379 end if
1380 end if
1381 end if
1382 end if
1383end function
1384
1385
1386''
1387' Locating nasm.exe
1388'
1389sub CheckForNasm(strOptNasm)
1390 dim strPathNasm, strVersion
1391 PrintHdr "nasm"
1392
1393 strPathNasm = CheckForNasmSub(strOptNasm, strVersion)
1394 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(strOptNasm), strVersion)
1395 if strPathNasm = "" and g_blnInternalFirst = true then
1396 strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion)
1397 end if
1398 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKLM\SOFTWARE\nasm\"), strVersion)
1399 if strPathNasm = "" then strPathNasm = CheckForNasmSub(LogRegGetString("HKCU\SOFTWARE\nasm\"), strVersion)
1400 if strPathNasm = "" then
1401 for each strCandidate in CollectFromProgramItemLinks(GetRef("NasmProgramItemCallback"), strPathNasm)
1402 strPathNasm = CheckForNasmSub(strCandidate, strVersion)
1403 next
1404 end if
1405 if strPathNasm = "" then strPathNasm = CheckForNasmSub(PathStripFilename(Which("nasm.exe")), strVersion)
1406 if strPathNasm = "" and g_blnInternalFirst = false then
1407 strPathNasm = SearchHostTools("nasm", "v", GetRef("CheckForNasmSub"), strVersion)
1408 end if
1409
1410 if strPathNasm = "" then
1411 PrintResultMsg "nasm", "not found"
1412 else
1413 CfgPrintAssign "PATH_TOOL_NASM", strPathNasm
1414 PrintResult "nasm v" & strVersion, strPathNasm
1415 end if
1416end sub
1417
1418function NasmProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)
1419 dim str, off
1420 NasmProgramItemCallback = ""
1421 if cStrings > 1 then
1422 str = arrStrings(1)
1423 off = InStr(1, str, "\nasm.exe", vbTextCompare)
1424 if off > 0 then
1425 NasmProgramItemCallback = Left(str, off - 1)
1426 end if
1427 end if
1428end function
1429
1430function CheckForNasmSub(strPathNasm, ByRef strVersion)
1431 CheckForNasmSub = ""
1432 if strPathNasm <> "" then
1433 if LogFileExists(strPathNasm, "nasm.exe") then
1434 dim strOutput
1435 if Shell("""" & DosSlashes(strPathNasm & "\nasm.exe") & """ -version", True, strOutput) = 0 then
1436 dim strPreamble : strPreamble = "NASM version"
1437 dim strVer : strVer = Trim(StrGetFirstLine(strOutput))
1438 if StrComp(Left(strVer, Len(strPreamble)), strPreamble, vbTextCompare) = 0 then
1439 strVersion = StrGetFirstWord(Trim(Mid(strVer, Len(strPreamble) + 1)))
1440 if StrVersionCompare(strVersion, "2.12.0") >= 0 and strVersion <> "" then
1441 LogPrint "Found nasm version: " & strVersion
1442 CheckForNasmSub = UnixSlashes(PathAbs(strPathNasm))
1443 else
1444 LogPrint "nasm version is older than 2.12.0: " & strVersion
1445 end if
1446 else
1447 LogPrint "Not nasm: " & strVer
1448 end if
1449 end if
1450 end if
1451 end if
1452end function
1453
1454
1455''
1456' Locating OpenWatcom 1.9
1457'
1458sub CheckForOpenWatcom(strOptOpenWatcom)
1459 dim strPathOW, strCandidate, strVersion
1460 PrintHdr "OpenWatcom"
1461
1462 strPathOW = CheckForOpenWatcomSub(strOptOpenWatcom, strVersion)
1463 if strPathOW = "" and g_blnInternalFirst = true then
1464 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion)
1465 end if
1466 if strPathOW = "" then
1467 for each strCandidate in CollectFromProgramItemLinks(GetRef("OpenWatcomProgramItemCallback"), strPathOW)
1468 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(strCandidate, strVersion)
1469 next
1470 end if
1471 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(EnvGet("WATCOM"), strVersion)
1472 if strPathOW = "" then strPathOW = CheckForOpenWatcomSub(PathParent(PathStripFilename(Which("wcc386.exe"))), strVersion)
1473 if strPathOW = "" and g_blnInternalFirst = false then
1474 strPathOW = SearchCommonTools("openwatcom", "v", GetRef("CheckForOpenWatcomSub"), strVersion)
1475 end if
1476
1477 if strPathOW = "" then
1478 PrintResultMsg "OpenWatcom", "not found"
1479 CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", ""
1480 exit sub
1481 end if
1482
1483 CfgPrintAssign "VBOX_WITH_OPEN_WATCOM", "1"
1484 CfgPrintAssign "PATH_TOOL_OPENWATCOM", strPathOW
1485 PrintResult "OpenWatcom v" & strVersion, strPathOW
1486 if StrVersionCompare(strVersion, "2.0") >= 0 then
1487 MsgWarning "We only test building with OpenWatcom 1.9."
1488 end if
1489end sub
1490
1491function OpenWatcomProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)
1492 dim str, off
1493 OpenWatcomProgramItemCallback = ""
1494 if cStrings > 1 then
1495 str = arrStrings(1)
1496 off = InStr(1, str, "\binnt\", vbTextCompare)
1497 if off > 0 then
1498 OpenWatcomProgramItemCallback = Left(str, off - 1)
1499 end if
1500 end if
1501end function
1502
1503function CheckForOpenWatcomSub(strPathOW, ByRef strVersion)
1504 CheckForOpenWatcomSub = ""
1505 if strPathOW <> "" then
1506 LogPrint "Trying: " & strPathOW
1507 if LogDirExists(strPathOW) then
1508 if LogDirExists(strPathOW & "/binnt") _
1509 and LogDirExists(strPathOW & "/h") _
1510 and LogDirExists(strPathOW & "/eddat") _
1511 and LogFileExists(strPathOW, "binnt/wcc386.exe") _
1512 and LogFileExists(strPathOW, "binnt/wcc.exe") _
1513 and LogFileExists(strPathOW, "binnt/wlink.exe") _
1514 and LogFileExists(strPathOW, "binnt/wcl386.exe") _
1515 and LogFileExists(strPathOW, "binnt/wcl.exe") _
1516 and LogFileExists(strPathOW, "binnt/wlib.exe") _
1517 and LogFileExists(strPathOW, "binnt/wasm.exe") _
1518 and LogFileExists(strPathOW, "h/stdarg.h") _
1519 then
1520 ' Some wcl/wcl386 option parsing quirk allows us to specify /whatever
1521 ' and just get the logo text and exit code 0. We use /y as it's a valid option.
1522 dim strOutput
1523 if Shell("""" & DosSlashes(strPathOW & "\binnt\wcl.exe") & """ /y", True, strOutput) = 0 then
1524 dim strPreamble : strPreamble = "Open Watcom C/C++16 Compile and Link Utility Version"
1525 strOutput = StrGetFirstLine(strOutput)
1526 if StrStartsWithI(strOutput, strPreamble) then
1527 strVersion = StrGetFirstWord(Trim(Mid(strOutput, Len(strPreamble) + 1)))
1528 if StrVersionCompare(strVersion, "1.9") >= 0 then
1529 CheckForOpenWatcomSub = UnixSlashes(PathAbs(strPathOW))
1530 else
1531 LogPrint "OpenWatcom version id older than 1.9: " & strVersion
1532 end if
1533 else
1534 LogPrint "Not OpenWatcom: " & strOutput
1535 end if
1536 end if
1537 end if
1538 end if
1539 end if
1540end function
1541
1542
1543''
1544' Checks for any libSDL binaries.
1545'
1546sub CheckForlibSDL(strOptlibSDL)
1547 dim strPathLibSDL, strVersion
1548 PrintHdr "libSDL"
1549
1550 '
1551 ' Try find some SDL library.
1552 '
1553 strPathLibSDL = CheckForLibSDLSub(strOptlibSDL, strVersion)
1554 if strPathlibSDL = "" and g_blnInternalFirst = true then
1555 strPathLibSDL = SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion)
1556 end if
1557
1558 ' Poke about in the LIB and PATH env.vars.
1559 if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(WhichEx("LIB", "SDLmain.lib"))), strVersion)
1560 if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("..\lib\SDLmain.lib"))), strVersion)
1561 if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDLmain.lib"))), strVersion)
1562 if strPathlibSDL = "" then strPathLibSDL = CheckForlibSDLSub(PathParent(PathStripFilename(Which("SDL.dll"))), strVersion)
1563
1564 ' The tools again.
1565 if strPathlibSDL = "" and g_blnInternalFirst = false then
1566 strPathLibSDL = SearchTargetTools("libsdl", "v", GetRef("CheckForLibSDLSub"), strVersion)
1567 end if
1568
1569 ' Success?
1570 if strPathlibSDL = "" then
1571 if strOptlibSDL = "" then
1572 MsgError "Can't locate libSDL. Try specify the path with the --with-libSDL=<path> argument. " _
1573 & "If still no luck, consult the configure.log and the build requirements."
1574 else
1575 MsgError "Can't locate libSDL. Please consult the configure.log and the build requirements."
1576 end if
1577 exit sub
1578 end if
1579
1580 strPathLibSDL = UnixSlashes(PathAbs(strPathLibSDL))
1581 CfgPrintAssign "PATH_SDK_LIBSDL", strPathlibSDL
1582
1583 PrintResult "libSDL", strPathlibSDL
1584end sub
1585
1586'' Checks if the specified path points to an usable libSDL or not.
1587function CheckForLibSDLSub(strPathlibSDL, strVersion)
1588 CheckForlibSDLSub = ""
1589 if strPathLibSDL <> "" then
1590 LogPrint "Trying: strPathLibSDL=" & strPathLibSDL
1591 if LogFileExists(strPathLibSDL, "lib/SDL.lib") _
1592 and LogFileExists(strPathLibSDL, "lib/SDLmain.lib") _
1593 and LogFileExists(strPathLibSDL, "lib/SDL.dll") _
1594 then
1595 dim strIncSub : strIncSub = "include"
1596 if DirExists(strPathlibSDL & "/include/SDL") then strIncSub = "include/SDL"
1597 if LogFileExists(strPathLibSDL, strIncSub & "/SDL.h") _
1598 and LogFileExists(strPathLibSDL, strIncSub & "/SDL_syswm.h") _
1599 and LogFileExists(strPathLibSDL, strIncSub & "/SDL_version.h") _
1600 then
1601 strVersion = ""
1602 CheckForLibSDLSub = strPathLibSDL
1603 end if
1604 end if
1605 end if
1606end function
1607
1608
1609''
1610' Checks for libxml2.
1611'
1612sub CheckForXml2(strOptXml2)
1613 dim strPathXml2, str
1614 PrintHdr "libxml2"
1615
1616 '
1617 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1618 '
1619 if (strOptXml2 = "") then
1620 PrintResultMsg "libxml2", "src/lib/libxml2-*"
1621 exit sub
1622 end if
1623
1624 ' Skip if no COM/ATL.
1625 if g_blnDisableCOM then
1626 PrintResultMsg "libxml2", "Skipped (" & g_strDisableCOM & ")"
1627 exit sub
1628 end if
1629
1630 '
1631 ' Try find some xml2 dll/lib.
1632 '
1633 strPathXml2 = ""
1634 if (strPathXml2 = "") And (strOptXml2 <> "") then
1635 if CheckForXml2Sub(strOptXml2) then strPathXml2 = strOptXml2
1636 end if
1637
1638 if strPathXml2 = "" then
1639 str = Which("libxml2.lib")
1640 if str <> "" then
1641 str = PathParent(PathStripFilename(str))
1642 if CheckForXml2Sub(str) then strPathXml2 = str
1643 end if
1644 end if
1645
1646 ' Success?
1647 if strPathXml2 = "" then
1648 if strOptXml2 = "" then
1649 MsgError "Can't locate libxml2. Try specify the path with the --with-libxml2=<path> argument. " _
1650 & "If still no luck, consult the configure.log and the build requirements."
1651 else
1652 MsgError "Can't locate libxml2. Please consult the configure.log and the build requirements."
1653 end if
1654 exit sub
1655 end if
1656
1657 strPathXml2 = UnixSlashes(PathAbs(strPathXml2))
1658 CfgPrintAssign "SDK_VBOX_LIBXML2_DEFS", "_REENTRANT"
1659 CfgPrintAssign "SDK_VBOX_LIBXML2_INCS", strPathXml2 & "/include"
1660 CfgPrintAssign "SDK_VBOX_LIBXML2_LIBS", strPathXml2 & "/lib/libxml2.lib"
1661
1662 PrintResult "libxml2", strPathXml2
1663end sub
1664
1665'' Checks if the specified path points to an usable libxml2 or not.
1666function CheckForXml2Sub(strPathXml2)
1667 dim str
1668
1669 CheckForXml2Sub = False
1670 LogPrint "trying: strPathXml2=" & strPathXml2
1671 if LogFileExists(strPathXml2, "include/libxml/xmlexports.h") _
1672 And LogFileExists(strPathXml2, "include/libxml/xmlreader.h") _
1673 then
1674 str = LogFindFile(strPathXml2, "bin/libxml2.dll")
1675 if str <> "" then
1676 if LogFindFile(strPathXml2, "lib/libxml2.lib") <> "" then
1677 CheckForXml2Sub = True
1678 end if
1679 end if
1680 end if
1681end function
1682
1683
1684'' Checks for openssl
1685sub CheckForSsl(strOptSsl, bln32Bit)
1686 dim strPathSsl, str
1687 PrintHdr "openssl"
1688
1689 strOpenssl = "openssl"
1690 if bln32Bit = True then
1691 strOpenssl = "openssl32"
1692 end if
1693
1694 '
1695 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1696 '
1697 if (strOptSsl = "") then
1698 PrintResult strOpenssl, "src/libs/openssl-*"
1699 exit sub
1700 end if
1701
1702 '
1703 ' Try find some openssl dll/lib.
1704 '
1705 strPathSsl = ""
1706 if (strPathSsl = "") And (strOptSsl <> "") then
1707 if CheckForSslSub(strOptSsl) then strPathSsl = strOptSsl
1708 end if
1709
1710 if strPathSsl = "" then
1711 str = Which("libssl.lib")
1712 if str <> "" then
1713 str = PathParent(PathStripFilename(str))
1714 if CheckForSslSub(str) then strPathSsl = str
1715 end if
1716 end if
1717
1718 ' Success?
1719 if strPathSsl = "" then
1720 if strOptSsl = "" then
1721 MsgError "Can't locate " & strOpenssl & ". " _
1722 & "Try specify the path with the --with-" & strOpenssl & "=<path> argument. " _
1723 & "If still no luck, consult the configure.log and the build requirements."
1724 else
1725 MsgError "Can't locate " & strOpenssl & ". " _
1726 & "Please consult the configure.log and the build requirements."
1727 end if
1728 exit sub
1729 end if
1730
1731 strPathSsl = UnixSlashes(PathAbs(strPathSsl))
1732 if bln32Bit = True then
1733 CfgPrintAssign "SDK_VBOX_OPENSSL-x86_INCS", strPathSsl & "/include"
1734 CfgPrintAssign "SDK_VBOX_OPENSSL-x86_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1735 CfgPrintAssign "SDK_VBOX_BLD_OPENSSL-x86_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1736 else
1737 CfgPrintAssign "SDK_VBOX_OPENSSL_INCS", strPathSsl & "/include"
1738 CfgPrintAssign "SDK_VBOX_OPENSSL_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1739 CfgPrintAssign "SDK_VBOX_BLD_OPENSSL_LIBS", strPathSsl & "/lib/libcrypto.lib" & " " & strPathSsl & "/lib/libssl.lib"
1740 end if
1741
1742 PrintResult strOpenssl, strPathSsl
1743end sub
1744
1745'' Checks if the specified path points to an usable openssl or not.
1746function CheckForSslSub(strPathSsl)
1747
1748 CheckForSslSub = False
1749 LogPrint "trying: strPathSsl=" & strPathSsl
1750 if LogFileExists(strPathSsl, "include/openssl/md5.h") _
1751 And LogFindFile(strPathSsl, "lib/libssl.lib") <> "" _
1752 then
1753 CheckForSslSub = True
1754 end if
1755end function
1756
1757
1758''
1759' Checks for libcurl
1760'
1761sub CheckForCurl(strOptCurl, bln32Bit)
1762 dim strPathCurl, str
1763 PrintHdr "libcurl"
1764
1765 strCurl = "libcurl"
1766 if bln32Bit = True then
1767 strCurl = "libcurl32"
1768 end if
1769
1770 '
1771 ' Part of tarball / svn, so we can exit immediately if no path was specified.
1772 '
1773 if (strOptCurl = "") then
1774 PrintResult strCurl, "src/libs/curl-*"
1775 exit sub
1776 end if
1777
1778 '
1779 ' Try find some cURL dll/lib.
1780 '
1781 strPathCurl = ""
1782 if (strPathCurl = "") And (strOptCurl <> "") then
1783 if CheckForCurlSub(strOptCurl) then strPathCurl = strOptCurl
1784 end if
1785
1786 if strPathCurl = "" then
1787 str = Which("libcurl.lib")
1788 if str <> "" then
1789 str = PathParent(PathStripFilename(str))
1790 if CheckForCurlSub(str) then strPathCurl = str
1791 end if
1792 end if
1793
1794 ' Success?
1795 if strPathCurl = "" then
1796 if strOptCurl = "" then
1797 MsgError "Can't locate " & strCurl & ". " _
1798 & "Try specify the path with the --with-" & strCurl & "=<path> argument. " _
1799 & "If still no luck, consult the configure.log and the build requirements."
1800 else
1801 MsgError "Can't locate " & strCurl & ". " _
1802 & "Please consult the configure.log and the build requirements."
1803 end if
1804 exit sub
1805 end if
1806
1807 strPathCurl = UnixSlashes(PathAbs(strPathCurl))
1808 if bln32Bit = True then
1809 CfgPrintAssign "SDK_VBOX_LIBCURL-x86_INCS", strPathCurl & "/include"
1810 CfgPrintAssign "SDK_VBOX_LIBCURL-x86_LIBS.x86", strPathCurl & "/libcurl.lib"
1811 else
1812 CfgPrintAssign "SDK_VBOX_LIBCURL_INCS", strPathCurl & "/include"
1813 CfgPrintAssign "SDK_VBOX_LIBCURL_LIBS", strPathCurl & "/libcurl.lib"
1814 end if
1815
1816 PrintResult strCurl, strPathCurl
1817end sub
1818
1819'' Checks if the specified path points to an usable libcurl or not.
1820function CheckForCurlSub(strPathCurl)
1821
1822 CheckForCurlSub = False
1823 LogPrint "trying: strPathCurl=" & strPathCurl
1824 if LogFileExists(strPathCurl, "include/curl/curl.h") _
1825 And LogFindFile(strPathCurl, "libcurl.dll") <> "" _
1826 And LogFindFile(strPathCurl, "libcurl.lib") <> "" _
1827 then
1828 CheckForCurlSub = True
1829 end if
1830end function
1831
1832
1833''
1834' Checks for any Qt5 binaries.
1835'
1836sub CheckForQt(strOptQt5, strOptInfix)
1837 dim strPathQt5, strInfixQt5, arrFolders, arrVccInfixes, strVccInfix, strPathDev
1838 PrintHdr "Qt5"
1839
1840 '
1841 ' Try to find the Qt5 installation (user specified path with --with-qt5)
1842 '
1843 LogPrint "Checking for user specified path of Qt5 ... "
1844 strPathQt5 = CheckForQt5Sub(UnixSlashes(strOptQt5), strOptInfix, strInfixQt5)
1845 if strPathQt5 = "" and g_blnInternalFirst = true then strPathQt5 = CheckForQt5Internal(strOptInfix, strInfixQt5)
1846 if strPathQt5 = "" then
1847 '
1848 ' Collect links from "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\UFH\SHC"
1849 '
1850 ' Typical string list:
1851 ' 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).lnk
1852 ' C:\Windows\System32\cmd.exe
1853 ' /A /Q /K E:\qt\installed\5.x.y\msvc20zz_64\bin\qtenv2.bat
1854 '
1855 dim arrCandidates, strCandidate
1856 arrCandidates = CollectFromProgramItemLinks(GetRef("Qt5ProgramItemCallback"), strPathQt5)
1857 LogPrint "Testing qtenv2.bat links (" & ArraySize(arrCandidates) & ") ..."
1858
1859 ' VC infixes/subdir names to consider (ASSUMES 64bit)
1860 if g_strVCCVersion = "VCC142" or g_strVCCVersion = "" then
1861 arrVccInfixes = Array("msvc2019_64", "msvc2017_64", "msvc2015_64")
1862 elseif g_strVCCVersion = "VCC141" then
1863 arrVccInfixes = Array("msvc2017_64", "msvc2015_64", "msvc2019_64")
1864 elseif g_strVCCVersion = "VCC140" then
1865 arrVccInfixes = Array("msvc2015_64", "msvc2017_64", "msvc2019_64")
1866 elseif g_strVCCVersion = "VCC120" then
1867 arrVccInfixes = Array("msvc2013_64")
1868 elseif g_strVCCVersion = "VCC110" then
1869 arrVccInfixes = Array("msvc2012_64")
1870 elseif g_strVCCVersion = "VCC100" then
1871 arrVccInfixes = Array("msvc2010_64")
1872 else
1873 MsgFatal "Unexpected VC version: " & g_strVCCVersion
1874 arrVccInfixes = Array()
1875 end if
1876 for each strVccInfix in arrVccInfixes
1877 for each strCandidate in arrCandidates
1878 if InStr(1, LCase(strCandidate), strVccInfix) > 0 then
1879 strPathQt5 = CheckForQt5Sub(strCandidate, strOptInfix, strInfixQt5)
1880 if strPathQt5 <> "" then exit for
1881 end if
1882 next
1883 if strPathQt5 <> "" then exit for
1884 next
1885 end if
1886
1887 ' Check the dev tools - prefer ones matching the compiler.
1888 if strPathQt5 = "" and g_blnInternalFirst = false then strPathQt5 = CheckForQt5Internal(strOptInfix, strInfixQt5)
1889
1890 '
1891 ' Display the result and output the config.
1892 '
1893 if strPathQt5 <> "" then
1894 PrintResult "Qt5", strPathQt5
1895 PrintResultMsg "Qt5 infix", strInfixQt5
1896 CfgPrintAssign "PATH_SDK_QT5", strPathQt5
1897 CfgPrintAssign "PATH_TOOL_QT5", "$(PATH_SDK_QT5)"
1898 CfgPrintAssign "VBOX_PATH_QT", "$(PATH_SDK_QT5)"
1899 CfgPrintAssign "VBOX_QT_INFIX", strInfixQt5
1900 CfgPrintAssign "VBOX_WITH_QT_PAYLOAD", "1"
1901 else
1902 PrintResultMsg "Qt5", "not found"
1903 CfgPrintAssign "VBOX_WITH_QTGUI", ""
1904 end if
1905end sub
1906
1907function CheckForQt5Internal(strOptInfix, ByRef strInfixQt5)
1908 dim strPathDev, arrFolders, arrVccInfixes, strVccInfix, i
1909 CheckForQt5Internal = ""
1910 for each strPathDev in g_arrPathDev
1911 LogPrint "Testing tools dir (" & strPathDev & "/win." & g_strTargetArch & "/qt/v5*) ..."
1912 arrFolders = GetSubdirsStartingWithVerSorted(strPathDev & "/win." & g_strTargetArch & "/qt", "v5")
1913 arrVccInfixes = Array(LCase(g_strVCCVersion), Left(LCase(g_strVCCVersion), Len(g_strVCCVersion) - 1), "")
1914 for each strVccInfix in arrVccInfixes
1915 for i = UBound(arrFolders) to LBound(arrFolders) step -1
1916 if strVccInfix = "" or InStr(1, LCase(arrFolders(i)), strVccInfix) > 0 then
1917LogPrint "i="&i&" strVccInfix="&strVccInfix
1918 strPathQt5 = CheckForQt5Sub(strPathDev & "/win." & g_strTargetArch & "/qt/" & arrFolders(i), strOptInfix, strInfixQt5)
1919 if strPathQt5 <> "" then
1920 CheckForQt5Internal = strPathQt5
1921 exit function
1922 end if
1923 end if
1924 next
1925 next
1926 next
1927end function
1928
1929function Qt5ProgramItemCallback(ByRef arrStrings, cStrings, ByRef strUnused)
1930 dim str, off
1931 Qt5ProgramItemCallback = ""
1932 if cStrings >= 3 then
1933 str = Trim(arrStrings(UBound(arrStrings)))
1934 if LCase(Right(str, Len("\bin\qtenv2.bat"))) = "\bin\qtenv2.bat" _
1935 and InStr(1, LCase(str), "\msvc20") > 0 _
1936 and InStr(1, str, ":") > 0 _
1937 then
1938 off = InStr(1, str, ":") - 1
1939 Qt5ProgramItemCallback = Mid(str, off, Len(str) - off - Len("\bin\qtenv2.bat") + 1)
1940 end if
1941 end if
1942end function
1943
1944function CheckForQt5Sub(strPathQt5, strOptInfix, ByRef strInfixQt5)
1945 CheckForQt5Sub = ""
1946 if strPathQt5 <> "" then
1947 LogPrint "Trying: strPathQt5=" & strPathQt5
1948
1949 if LogFileExists(strPathQt5, "bin/moc.exe") _
1950 and LogFileExists(strPathQt5, "bin/uic.exe") _
1951 and LogFileExists(strPathQt5, "include/QtWidgets/qwidget.h") _
1952 and LogFileExists(strPathQt5, "include/QtWidgets/QApplication") _
1953 and LogFileExists(strPathQt5, "include/QtGui/QImage") _
1954 and LogFileExists(strPathQt5, "include/QtNetwork/QHostAddress") _
1955 then
1956 ' Infix testing.
1957 if LogFileExists(strPathQt5, "lib/Qt5Core.lib") _
1958 and LogFileExists(strPathQt5, "lib/Qt5Network.lib") then
1959 LogPrint "found it w/o infix"
1960 strInfixQt5 = ""
1961 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
1962 elseif LogFileExists(strPathQt5, "lib/Qt5Core" & strOptInfix & ".lib") _
1963 and LogFileExists(strPathQt5, "lib/Qt5Network" & strOptInfix & ".lib") then
1964 LogPrint "found it w/ infix: " & strOptInfix & " (option)"
1965 strInfixQt5 = strOptInfix
1966 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
1967 elseif LogFileExists(strPathQt5, "lib/Qt5CoreVBox.lib") _
1968 and LogFileExists(strPathQt5, "lib/Qt5NetworkVBox.lib") then
1969 LogPrint "found it w/ infix: VBox"
1970 strInfixQt5 = "VBox"
1971 CheckForQt5Sub = UnixSlashes(PathAbs(strPathQt5))
1972 end if
1973 end if
1974 end if
1975end function
1976
1977
1978''
1979' Checks for python.
1980'
1981function CheckForPython(strOptPython)
1982 dim strPathPython, arrVersions, strVer, str
1983 PrintHdr "Python"
1984 CheckForPython = False
1985
1986 '
1987 ' Locate it.
1988 '
1989 strPathPython = CheckForPythonSub(strOptPython)
1990 if strPathPython = "" then
1991 arrVersions = Array("3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6", "3.5", "2.7")
1992 for each strVer in arrVersions
1993 strPathPython = CheckForPythonSub(LogRegGetString("HKLM\SOFTWARE\Python\PythonCore\" & strVer & "\InstallPath\"))
1994 if strPathPython <> "" then exit for
1995 next
1996 end if
1997 if strPathPython = "" then strPathPython = CheckForPythonSub(PathStripFilename(Which("python.exe")))
1998
1999 '
2000 ' Output config & result.
2001 '
2002 CheckForPython = strPathPython <> ""
2003 if CheckForPython then
2004 CfgPrintAssign "VBOX_BLD_PYTHON", strPathPython
2005 PrintResult "Python", strPathPython
2006 else
2007 PrintResultMsg "Python", "not found"
2008 end if
2009end function
2010
2011function CheckForPythonSub(strPathPython)
2012 CheckForPythonSub = ""
2013 if strPathPython <> "" then
2014 if LogFileExists(strPathPython, "python.exe") _
2015 and LogDirExists(strPathPython & "/DLLs") _
2016 then
2017 CheckForPythonSub = UnixSlashes(PathAbs(strPathPython & "/python.exe"))
2018 end if
2019 end if
2020end function
2021
2022
2023''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2024' Main function and usage '
2025''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
2026
2027''
2028' Show usage.
2029'
2030sub usage
2031 Print "Usage: cscript configure.vbs [options]"
2032 Print ""
2033 Print "Configuration:"
2034 Print " -h, --help Display this."
2035 Print " --target-arch=x86|amd64 The target architecture."
2036 Print " --continue-on-error Do not stop on errors."
2037 Print " --internal-last Check internal tools (tools/win.*) last."
2038 Print " --internal-first Check internal tools (tools/win.*) first (default)."
2039 Print ""
2040 Print "Components:"
2041 Print " --disable-COM Disables all frontends and API."
2042 Print " --disable-SDL Disables the SDL frontend."
2043 Print " --disable-UDPTunnel"
2044 Print " --disable-pylint Disable use of pylint."
2045 Print ""
2046 Print "Locations:"
2047 Print " --with-kBuild=PATH Where kBuild is to be found."
2048 Print " --with-libSDL=PATH Where libSDL is to be found."
2049 Print " --with-Qt5=PATH Where Qt5 is to be found (optional)."
2050 Print " --with-DDK=PATH Where the WDK is to be found."
2051 Print " --with-SDK=PATH Where the Windows SDK is to be found."
2052 Print " --with-SDK10=PATH Where the Windows 10 SDK/WDK is to be found."
2053 Print " --with-VC=PATH Where the Visual C++ compiler is to be found."
2054 Print " (Expecting bin, include and lib subdirs.)"
2055 Print " --with-VC-Common=PATH Maybe needed for 2015 and older to"
2056 Print " locate the Common7 directory."
2057 Print " --with-python=PATH The python to use."
2058 Print " --with-midl=PATH Where midl.exe is to be found."
2059 Print " --with-yasm=PATH Where YASM is to be found."
2060 Print " --with-nasm=PATH Where NASM is to be found (optional)"
2061 Print " --with-openwatcom=PATH Where OpenWatcom 1.9 is to be found (optional)."
2062 Print " --with-libxml2=PATH To use a libxml2 other than the VBox one (opt)."
2063 Print " --with-openssl=PATH To use an openssl other than the VBox one (opt)."
2064 Print " --with-openssl32=PATH The 32-bit variant of openssl (optional)."
2065 Print " --with-libcurl=PATH To use a cURL other than the VBox one (optional)."
2066 Print " --with-libcurl32=PATH The 32-bit variant of cURL (optional)."
2067 Print ""
2068 Print " --append-tools-dir=PATH, --prepend-tools-dir=PATH"
2069 Print " Adds an alternative tools directory to search."
2070 Print " --append-tools-dir=PATH, --prepend-prog-files=PATH"
2071 Print " Adds an alternative Program Files dir to search."
2072 Print " --append-ewdk-drive=DRIVE, --prepend-ewdk-drive=DRIVE"
2073 Print " Adds an EWDK drive the search list."
2074end sub
2075
2076
2077''
2078' The main() like function.
2079'
2080function Main
2081 dim strOutput
2082
2083 '
2084 ' Write the log header and check that we're not using wscript.
2085 '
2086 LogInit
2087 if UCase(Right(Wscript.FullName, 11)) = "WSCRIPT.EXE" then
2088 Wscript.Echo "This script must be run under CScript."
2089 Main = 1
2090 exit function
2091 end if
2092 SelfTest
2093
2094 '
2095 ' Parse arguments.
2096 '
2097 strOptDDK = ""
2098 strOptDXDDK = ""
2099 strOptkBuild = ""
2100 strOptlibSDL = ""
2101 strOptQt5 = ""
2102 strOptQt5Infix = ""
2103 strOptSDK = ""
2104 strOptSDK10 = ""
2105 strOptSDK10Version = ""
2106 strOptVC = ""
2107 strOptVCCommon = ""
2108 strOptMidl = ""
2109 strOptYasm = ""
2110 strOptNasm = ""
2111 strOptOpenWatcom = ""
2112 strOptXml2 = ""
2113 strOptSsl = ""
2114 strOptSsl32 = ""
2115 strOptCurl = ""
2116 strOptCurl32 = ""
2117 strOptPython = ""
2118 blnOptDisableCOM = False
2119 blnOptDisableUDPTunnel = False
2120 blnOptDisableSDL = False
2121 for i = 1 to Wscript.Arguments.Count
2122 dim str, strArg, strPath
2123
2124 ' Separate argument and path value
2125 str = Wscript.Arguments.item(i - 1)
2126 if InStr(1, str, "=") > 0 then
2127 strArg = Mid(str, 1, InStr(1, str, "=") - 1)
2128 strPath = Mid(str, InStr(1, str, "=") + 1)
2129 if strPath = "" then MsgFatal "Syntax error! Argument #" & i & " is missing the path."
2130 else
2131 strArg = str
2132 strPath = ""
2133 end if
2134
2135 ' Process the argument
2136 select case LCase(strArg)
2137 ' --with-something:
2138 case "--with-ddk"
2139 strOptDDK = strPath
2140 case "--with-dxsdk"
2141 MsgWarning "Ignoring --with-dxsdk (the DirectX SDK is no longer required)."
2142 case "--with-kbuild"
2143 strOptkBuild = strPath
2144 case "--with-libsdl"
2145 strOptlibSDL = strPath
2146 case "--with-mingw32"
2147 ' ignore
2148 case "--with-mingw-w64"
2149 ' ignore
2150 case "--with-qt5"
2151 strOptQt5 = strPath
2152 case "--with-qt5-infix"
2153 strOptQt5Infix = strPath
2154 case "--with-sdk"
2155 strOptSDK = strPath
2156 case "--with-sdk10"
2157 strOptSDK10 = strPath
2158 case "--with-sdk10-version"
2159 strOptSDK10Version = strPath
2160 case "--with-vc"
2161 strOptVC = strPath
2162 case "--with-vc-common"
2163 strOptVCCommon = strPath
2164 case "--with-vc-express-edition"
2165 ' ignore
2166 case "--with-w32api"
2167 ' ignore
2168 case "--with-midl"
2169 strOptMidl = strPath
2170 case "--with-yasm"
2171 strOptYasm = strPath
2172 case "--with-nasm"
2173 strOptNasm = strPath
2174 case "--with-openwatcom"
2175 strOptOpenWatcom = strPath
2176 case "--with-libxml2"
2177 strOptXml2 = strPath
2178 case "--with-openssl"
2179 strOptSsl = strPath
2180 case "--with-openssl32"
2181 strOptSsl32 = strPath
2182 case "--with-libcurl"
2183 strOptCurl = strPath
2184 case "--with-libcurl32"
2185 strOptCurl32 = strPath
2186 case "--with-python"
2187 strOptPython = strPath
2188
2189 ' Search lists.
2190 case "--append-tools-dir"
2191 g_arrToolsDirs = ArrayAppend(g_arrPathDev, strPath)
2192 case "--prepend-tools-dir"
2193 g_arrToolsDirs = ArrayPrepend(g_arrPathDev, strPath)
2194 case "--append-prog-files"
2195 g_arrProgramFiles = ArrayAppend(g_arrProgramFiles, strPath)
2196 case "--prepend-prog-files"
2197 g_arrProgramFiles = ArrayPrepend(g_arrProgramFiles, strPath)
2198 case "--append-ewdk-drive"
2199 g_arrProgramFiles = ArrayAppend(g_arrProgramFiles, strPath & "\Program Files")
2200 case "--prepend-ewdk-drive"
2201 g_arrProgramFiles = ArrayPrepend(g_arrProgramFiles, strPath & "\Program Files")
2202
2203 ' --disable-something/--enable-something
2204 case "--disable-com"
2205 blnOptDisableCOM = True
2206 case "--enable-com"
2207 blnOptDisableCOM = False
2208 case "--disable-udptunnel"
2209 blnOptDisableUDPTunnel = True
2210 case "--enable-udptunnel"
2211 blnOptDisableUDPTunnel = False
2212 case "--disable-sdl"
2213 blnOptDisableSDL = True
2214 case "--endable-sdl"
2215 blnOptDisableSDL = False
2216 case "--disable-pylint"
2217 blnOptDisablePylint = True
2218 case "--enable-pylint"
2219 blnOptDisablePylint = False
2220
2221 ' Other stuff.
2222 case "--continue-on-error"
2223 g_blnContinueOnError = True
2224 case "--internal-first"
2225 g_blnInternalFirst = True
2226 case "--internal-last"
2227 g_blnInternalFirst = False
2228 case "--target-arch"
2229 g_strTargetArch = strPath
2230 case "-h", "--help", "-?"
2231 usage
2232 Main = 0
2233 exit function
2234 case else
2235 Wscript.echo "syntax error: Unknown option '" & str &"'."
2236 usage
2237 Main = 2
2238 exit function
2239 end select
2240 next
2241
2242 '
2243 ' Initialize output files.
2244 '
2245 CfgInit
2246 EnvInit
2247
2248 '
2249 ' Check that the Shell function is sane.
2250 '
2251 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = "This works"
2252 if Shell("set TESTING_ENVIRONMENT_INHERITANC", False, strOutput) <> 0 then ' The 'E' is missing on purpose (4nt).
2253 MsgFatal "shell execution test failed!"
2254 end if
2255 if strOutput <> "TESTING_ENVIRONMENT_INHERITANCE=This works" & CHR(13) & CHR(10) then
2256 Print "Shell test Test -> '" & strOutput & "'"
2257 MsgFatal "shell inheritance or shell execution isn't working right. Make sure you use cmd.exe."
2258 end if
2259 g_objShell.Environment("PROCESS")("TESTING_ENVIRONMENT_INHERITANCE") = ""
2260 Print "Shell inheritance test: OK"
2261
2262 '
2263 ' Do the checks.
2264 '
2265 if blnOptDisableCOM = True then
2266 DisableCOM "--disable-com"
2267 end if
2268 if blnOptDisableUDPTunnel = True then
2269 DisableUDPTunnel "--disable-udptunnel"
2270 end if
2271 if blnOptDisablePylint = True then
2272 CfgPrintAssign "override VBOX_WITH_PYLINT", ""
2273 end if
2274 CheckSourcePath
2275 CheckForkBuild strOptkBuild
2276 CheckForWinDDK strOptDDK
2277 CheckForVisualCPP strOptVC, strOptVCCommon
2278 CheckForPlatformSDK strOptSDK
2279 CheckForSDK10 strOptSDK10, strOptSDK10Version
2280 CheckForMidl strOptMidl
2281 CheckForYasm strOptYasm
2282 CheckForNasm strOptNasm
2283 CheckForOpenWatcom strOptOpenWatcom
2284 if blnOptDisableSDL = True then
2285 DisableSDL "--disable-sdl"
2286 else
2287 CheckForlibSDL strOptlibSDL
2288 end if
2289 CheckForXml2 strOptXml2
2290 CheckForSsl strOptSsl, False
2291 if g_strTargetArch = "amd64" then
2292 ' 32-bit openssl required as well
2293 CheckForSsl strOptSsl32, True
2294 end if
2295 CheckForCurl strOptCurl, False
2296 if g_strTargetArch = "amd64" then
2297 ' 32-bit Curl required as well
2298 CheckForCurl strOptCurl32, True
2299 end if
2300 CheckForQt strOptQt5, strOptQt5Infix
2301 CheckForPython strOptPython
2302 CfgPrintAssign "VBOX_WITH_LIBVPX", "" '' @todo look for libvpx 1.1.0+
2303 CfgPrintAssign "VBOX_WITH_LIBOPUS", "" '' @todo look for libopus 1.2.1+
2304
2305 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win." & g_strHostArch & "\bin"), ";"
2306 if g_strHostArch = "amd64" then
2307 EnvPrintAppend "PATH", DosSlashes(g_strPath & "\tools\win.x86\bin"), ";"
2308 else
2309 EnvPrintCleanup "PATH", DosSlashes(g_strPath & "\tools\win.amd64\bin"), ";"
2310 end if
2311
2312 Print ""
2313 Print "Execute env.bat once before you start to build VBox:"
2314 Print ""
2315 Print " env.bat"
2316 Print " kmk"
2317 Print ""
2318 if g_rcScript <> 0 then
2319 Print "Warning: ignored errors. See above or in configure.log."
2320 end if
2321
2322 Main = g_rcScript
2323end function
2324
2325'
2326' What crt0.o typically does:
2327'
2328WScript.Quit(Main())
2329
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette