forked from open-watcom/open-watcom-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
owconfig.vbs
108 lines (101 loc) · 4.04 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
'*****************************************************************
' 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
Documentation = True
OutFileName = "myvars.cmd"
' Parse the command line.
For i = 0 To WScript.Arguments.Count - 1
Select Case WScript.Arguments(i)
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 "-n suppress documentation build"
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 0 to suppress documentation build"
If Documentation Then
OutFile.WriteLine "set OWDOCBUILD=1"
Else
OutFile.WriteLine "set OWDOCBUILD=0"
End If
OutFile.WriteLine
OutFile.WriteLine "REM Documentation related variables"
If Len(HcrtfPath) > 0 Then
OutFile.WriteLine "set OWWIN95HC=" + HcrtfPath + "\" + "hcrtf"
Else
OutFile.WriteLine "set OWWIN95HC="
End If
If Len(HhcPath) > 0 Then
OutFile.WriteLine "set OWHHC=" + HhcPath + "\" + "hhc"
Else
OutFile.WriteLine "set OWHHC="
End If
OutFile.WriteLine
OutFile.WriteLine "REM Invoke the batch file for the common environment"
OutFile.WriteLine "call %OWROOT%\cmnvars.bat"
OutFile.WriteLine
OutFile.WriteLine "cd %OWROOT%"
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