generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 144
Expand file tree
/
Copy pathconfigure.vbs
More file actions
142 lines (127 loc) · 4.89 KB
/
configure.vbs
File metadata and controls
142 lines (127 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
' $Id: configure.vbs 112403 2026-01-11 19:29:08Z knut.osmundsen@oracle.com $
' Thin VBScript wrapper to call configure.py with passed arguments.
'
' Copyright (C) 2025-2026 Oracle and/or its affiliates.
'
' This file is part of VirtualBox base platform packages, as
' available from https://www.virtualbox.org.
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation, in version 3 of the
' License.
'
' This program is distributed in the hope that it will be useful, but
' WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
' General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, see <https://www.gnu.org/licenses>.
'
' SPDX-License-Identifier: GPL-3.0-only
'
WScript.Echo "Deprecation notice: VBScript has been marked as being deprecated and will be removed in the future."
WScript.Echo " Please either invoke configure.py via Python or use the Powershell script via configure.ps1"
WScript.Echo ""
WScript.Sleep 3000 ' Make it painful to use.
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objArgs = WScript.Arguments
' Combine passed arguments.
strArgs = ""
For i = 1 To WScript.Arguments.Count
strArgs = strArgs & " " & Chr(34) & WScript.Arguments(i-1) & Chr(34)
Next
strPythonPath = ""
strPythonBin = ""
' Returns the value of a given command line argument.
Function GetArgValue(sArgName)
Dim i, sArg, sTemp, sValue, sArgNext, idxSep
GetArgValue = ""
uArgLen = Len(sArgName)
i = 0
Do While i < objArgs.Count
sArg = Trim(objArgs(i))
If LCase(Left(sArg, uArgLen)) = LCase(sArgName) Then
sTemp = Trim(Mid(sArg, uArgLen + 1)) ' Everything after the flag.
' Remove all spaces between flag and =
If sTemp <> "" Then
sTemp = Replace(sTemp, " ", "") ' Remove ALL spaces from temp.
End If
idxSep = InStr(sTemp, "=")
If idxSep > 0 Then
' --arg=value, --arg =value, --arg= value, --arg =value
sValue = Trim(Mid(sTemp, idxSep + 1))
GetArgValue = sValue
Exit Function
ElseIf sTemp = "" Then
' Handle space after flag: --arg value or --arg = value or --arg = value
If i + 1 < objArgs.Count Then
sArgNext = Trim(objArgs(i + 1))
If Left(sArgNext, 1) = "=" Then
sValue = Trim(Mid(sArgNext, 2)) ' Remove any spaces after equal sign.
GetArgValue = sValue
Else
GetArgValue = sArgNext
End If
Exit Function
End If
End If
End If
i = i + 1
Loop
End Function
strPythonPath = GetArgValue("--with-python-path")
if strPythonPath = "" Then
strPythonPath = GetArgValue("--with-python")
End If
' Python binaries to search for. Sorted by likely-ness.
arrBin = Array("python.exe", "python3.exe")
if strPythonPath <> "" Then
For Each strCurBin In arrBin
strCurBinPath = objFSO.BuildPath(strPythonPath, strCurBin)
If objFSO.FileExists(strCurBinPath) Then
strPythonBin = strCurBinPath
Exit For
End If
Next
if strPythonBin = "" Then
WScript.Echo "Error: Not valid Python installation found at: " & strPythonPath
WScript.Quit 1
End if
End If
' Not specified above? Try python3, then just python.
If strPythonBin = "" Then
strOutput = ""
For Each strCurBin In arrBin
Set exec = objShell.Exec("cmd /c where " & strCurBin)
Do While Not exec.StdOut.AtEndOfStream
strLine = exec.StdOut.ReadLine()
If strOutput = "" Then ' Expects the path at the first line.
strOutput = strLine
Exit Do
End If
Loop
If strOutput <> "" Then
Exit For
End If
Next
strPythonBin = strOutput
End If
If strPythonBin = "" Then
WScript.Echo "Error: Python is not found."
WScript.Echo ""
WScript.Echo "Python 3 is required in order to build VirtualBox."
WScript.Echo "Please install Python 3 and ensure it is in your PATH."
WScript.Quit 1
End If
WScript.Echo "Using Python at: " & strPythonBin
' Execute configure.py with arguments.
strCmd = "cmd /c " & strPythonBin & " configure.py" & strArgs & " 2>&1"
Set oProc = objShell.Exec(strCmd)
Do While Not oProc.StdOut.AtEndOfStream
WScript.StdOut.WriteLine oProc.StdOut.ReadLine
Loop
' Pass back exit code from configure.py.
WScript.Quit oProc.ExitCode