-
Notifications
You must be signed in to change notification settings - Fork 10
/
owconfig.vbs
138 lines (131 loc) · 5.14 KB
/
owconfig.vbs
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
'*****************************************************************
' OWCONFIG.VBS - automatically generate batch file to set
' environment variables
'*****************************************************************
WScript.StdOut.WriteLine "Open Watcom Build Configurator"
' Initialize boolean variables for command line switches to the default values.
ShowUsage = False
DebugBuild = False
DefaultWindowing = False
Documentation = True
OutFileName = "myvars.cmd"
' Parse the command line.
For i = 0 To WScript.Arguments.Count - 1
Select Case WScript.Arguments(i)
Case "-d", "/d"
DebugBuild = True
Case "-w", "/w"
DefaultWindowing = True
Case "-n", "/n"
Documentation = False
Case Else
If Left(WScript.Arguments(i), 1) = "-" Or Left(WScript.Arguments(i), 1) = "/" Then
ShowUsage = True
Else
OutFileName = WScript.Arguments(i)
End If
End Select
Next
' If there was an invalid command line option, print the usage message.
If ShowUsage Then
WScript.StdOut.WriteLine "Usage: owconfig [options] [filename] [options]"
WScript.StdOut.WriteLine "Options:"
WScript.StdOut.WriteLine " ( /option is also accepted )"
WScript.StdOut.WriteLine "-d debug build"
WScript.StdOut.WriteLine "-n suppress documentation build"
WScript.StdOut.WriteLine "-w default windowing support in clib"
WScript.StdOut.WriteLine
Else
' Otherwise, do the work.
' Check for each needed tool in the path.
WScript.StdOut.Write "Checking for Open Watcom... "
OpenWatcomPath = FindFile("wcc386.exe")
WScript.StdOut.WriteLine OpenWatcomPath
If Len(OpenWatcomPath) = 0 Then
WScript.StdOut.WriteLine "You must place the binnt folder of your Open Watcom installation in"
WScript.StdOut.WriteLine "the PATH environment variable before running owconfig."
WScript.Quit 1
End If
WScript.StdOut.Write "Checking for hcrtf... "
HcrtfPath = FindFile("hcrtf.exe")
WScript.StdOut.WriteLine HcrtfPath
WScript.StdOut.Write "Checking for hhc... "
HhcPath = FindFile("hhc.exe")
WScript.StdOut.WriteLine HhcPath
' Output a batch file to set the environment.
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set OutFile = FSO.CreateTextFile(OutFileName)
OutFile.WriteLine "@echo off"
OutFile.WriteLine "REM *****************************************************************"
OutFile.WriteLine "REM " + UCase(OutFileName) + " - Windows NT version"
OutFile.WriteLine "REM *****************************************************************"
OutFile.WriteLine "REM NOTE: This batch file was automatically generated by owconfig."
OutFile.WriteLine "REM DO NOT EDIT!"
OutFile.WriteLine
OutFile.WriteLine "set OWROOT=" + WshShell.CurrentDirectory
OutFile.WriteLine "set WATCOM=" + Left(OpenWatcomPath, InStrRev(OpenWatcomPath, "\") - 1)
OutFile.WriteLine
OutFile.WriteLine "REM Set this variable to 1 to get debug build"
If DebugBuild Then
OutFile.WriteLine "set DEBUG_BUILD=1"
Else
OutFile.WriteLine "set DEBUG_BUILD=0"
End If
OutFile.WriteLine
OutFile.WriteLine "REM Set this variable to 1 to get default windowing support in clib"
If DefaultWindowing Then
OutFile.WriteLine "set DEFAULT_WINDOWING=1"
Else
OutFile.WriteLine "set DEFAULT_WINDOWING=0"
End If
OutFile.WriteLine
OutFile.WriteLine "REM Set this variable to 0 to suppress documentation build"
If Documentation Then
OutFile.WriteLine "set DOC_BUILD=1"
Else
OutFile.WriteLine "set DOC_BUILD=0"
End If
OutFile.WriteLine
OutFile.WriteLine "REM Documentation related variables"
If Len(HcrtfPath) > 0 Then
OutFile.WriteLine "set WIN95HC=hcrtf"
OutFile.WriteLine "set PATH=%PATH%;" + HcrtfPath
Else
OutFile.WriteLine "set WIN95HC="
End If
If Len(HhcPath) > 0 Then
OutFile.WriteLine "set HHC=hhc"
OutFile.WriteLine "set PATH=%PATH%;" + HhcPath
Else
OutFile.WriteLine "set HHC="
End If
OutFile.WriteLine
OutFile.WriteLine "REM Subdirectory to be used for bootstrapping"
OutFile.WriteLine "set OBJDIR=bootstrp"
OutFile.WriteLine
OutFile.WriteLine "REM Subdirectory to be used for building prerequisite utilities"
OutFile.WriteLine "set PREOBJDIR=prebuild"
OutFile.WriteLine
OutFile.WriteLine "REM Invoke the batch file for the common environment"
OutFile.WriteLine "call %OWROOT%\cmnvars.bat"
OutFile.WriteLine
OutFile.WriteLine "cd %DEVDIR%"
OutFile.Close
End If
Function FindFile(FileName)
'**************************
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
PathDirs = Split(WshShell.ExpandEnvironmentStrings("%PATH%"), ";")
For Each Dir In PathDirs
If Right(Dir, 1) = "\" Then
Dir = Left(Dir, Len(Dir) - 1)
End If
If FSO.FileExists(Dir + "\" + FileName) Then
FindFile = Dir
Exit Function
End If
Next
FindFile = ""
End Function