VirtualBox

source: vbox/trunk/configure.vbs@ 91370

Last change on this file since 91370 was 87407, checked in by vboxsync, 4 years ago

configure.vbs,tools/envSub.vbs,helpers.vbs: DbgPrint for DirExits and FileExists.

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

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