VirtualBox

source: vbox/trunk/configure.vbs@ 87304

Last change on this file since 87304 was 86249, checked in by vboxsync, 4 years ago

configure.vbs: compiler version mapping fix.

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