forked from bmx-ng/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.bmx
216 lines (187 loc) · 4.8 KB
/
options.bmx
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
' Copyright (c) 2013-2014 Bruce A Henderson
'
' Based on the public domain Monkey "trans" by Mark Sibly
'
' This software is provided 'as-is', without any express or implied
' warranty. In no event will the authors be held liable for any damages
' arising from the use of this software.
'
' Permission is granted to anyone to use this software for any purpose,
' including commercial applications, and to alter it and redistribute it
' freely, subject to the following restrictions:
'
' 1. The origin of this software must not be misrepresented; you must not
' claim that you wrote the original software. If you use this software
' in a product, an acknowledgment in the product documentation would be
' appreciated but is not required.
'
' 2. Altered source versions must be plainly marked as such, and must not be
' misrepresented as being the original software.
'
' 3. This notice may not be removed or altered from any source
' distribution.
'
SuperStrict
Import "base.configmap.bmx"
Const version:String = "0.17"
Const BUILDTYPE_APP:Int = 0
Const BUILDTYPE_MODULE:Int = 1
Const APPTYPE_NONE:Int = 0
Const APPTYPE_CONSOLE:Int = 1
Const APPTYPE_GUI:Int = 2
Global WORD_SIZE:Int = 4
' buildtype
' module
' app
Global opt_buildtype:Int = BUILDTYPE_APP
' modulename
' name of the module to build
Global opt_modulename:String
' arch
' x86
' ppc
' x64
' arm
Global opt_arch:String
' platform
' win32
' macos
' linux
Global opt_platform:String
' framework
Global opt_framework:String
' filename
' the base filename for app/module to compile against
Global opt_filename:String
' outfile
' full path to the outputfile (excluding final extension - there will be a .h, .c and .i generated)
Global opt_outfile:String
' apptype
' console
' gui
Global opt_apptype:Int = APPTYPE_NONE
' debug
Global opt_debug:Int = True
' threaded
Global opt_threaded:Int = False
' release
Global opt_release:Int = False
' quiet
Global opt_quiet:Int = False
' verbose
Global opt_verbose:Int = False
' ismain
' this is the main file for either the module, or the application.
Global opt_ismain:Int = False
' issuperstrict
'
Global opt_issuperstrict:Int = False
Global opt_filepath:String
Function CmdError(details:String = Null, fullUsage:Int = False)
Local s:String = "Compile Error"
If details Then
s:+ ": " + details
End If
s:+ "~n"
's:+ Usage(fullUsage)
Throw s
End Function
Function ParseArgs:String[](args:String[])
DefaultOptions()
CheckConfig()
Local count:Int
While count < args.length
Local arg:String = args[count]
If arg[..1] <> "-" Then
Exit
End If
Select arg[1..]
Case "q"
opt_quiet=True
Case "v"
opt_verbose=True
Case "r"
opt_debug=False
opt_release=True
Case "h"
opt_threaded=True
Case "g"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-g'"
End If
opt_arch = args[count].ToLower()
Case "m"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-m'"
End If
opt_buildtype = BUILDTYPE_MODULE
opt_modulename = args[count].ToLower()
Case "o"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-o'"
End If
opt_outfile = args[count]
Case "p"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-p'"
End If
opt_platform = args[count].ToLower()
Case "t"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-t'"
End If
Local apptype:String = args[count].ToLower()
Select apptype
Case "console"
opt_apptype = APPTYPE_CONSOLE
Case "gui"
opt_apptype = APPTYPE_GUI
Default
CmdError "Command line error - Invalid app type '" + opt_apptype + "'"
End Select
Case "f"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-f'"
End If
opt_framework = args[count]
End Select
count:+ 1
Wend
If opt_buildtype = BUILDTYPE_MODULE Then
opt_apptype = APPTYPE_NONE
End If
If opt_arch = "x64" Then
WORD_SIZE = 8
End If
Return args[count..]
End Function
Function DefaultOptions()
?x86
opt_arch = "x86"
?ppc
opt_arch = "ppc"
?x64
opt_arch = "x64"
?arm
opt_arch = "arm"
?
?win32
opt_platform = "win32"
?macos
opt_platform = "macos"
?linux
opt_platform = "linux"
?
End Function
Function CheckConfig()
Local config:TConfigMap = New TConfigMap.Init("bcc.conf")
If config.GetString("BMXPATH") <> ""
putenv_("BMXPATH="+config.GetString("BMXPATH"))
EndIf
End Function