-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
options.bmx
362 lines (330 loc) · 8.47 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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
' Copyright (c) 2013-2024 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"
Import "version.bmx"
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
' armeabi
' armeabiv7a
' armv7
' arm64
Global opt_arch:String
' platform
' win32
' macos
' osx
' ios
' linux
' android
' raspberrypi
' nx
' haiku
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 = True
' 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
' gdbdebug
' output debug useful for gdb, #line <bmx line> <bmx file>
Global opt_gdbdebug:Int = False
'
' upgrade strict subclass method/function return types to match superstrict superclass.
' default is to auto-upgrade. Set flag if you want to throw an error - because of mismatch. (strict is Int, superstrict is Void).
Global opt_strictupgrade:Int = True
' overload warnings
' generate warnings (and accept) instead of errors for calling methods with arguments that need to be cast down.
' May cause issues using overloaded methods.
Global opt_warnover:Int = False
' musl libc support
'
Global opt_musl:Int = False
' def
' generate .def files for dlls
Global opt_def:Int = False
' don't generate .def files for dlls
Global opt_nodef:Int = False
' generate header for dlls
Global opt_head:Int = False
' don't generate header for dlls
Global opt_nohead:Int = False
' makelib
Global opt_makelib:Int = False
' override
' require override keyword
Global opt_require_override:Int = False
' overerr
' missing override is error
Global opt_override_error:Int = False
' ud
' user defines
Global opt_userdefs:String
'
Global opt_need_strict:Int = False
'
Global opt_legacy_incbin:Int = False
Global opt_filepath:String
Global opt_coverage:Int = False
Global opt_no_auto_superstrict:Int = False
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 "s"
' disable with option
opt_strictupgrade=False
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]
Case "d"
opt_gdbdebug=True
Case "w"
opt_warnover=True
Case "musl"
opt_musl=True
Case "nodef"
opt_nodef=True
Case "nohead"
opt_nohead=True
Case "makelib"
opt_makelib=True
Case "override"
opt_require_override=True
Case "overerr"
opt_override_error=True
Case "ud"
count:+1
If count = args.length Then
CmdError "Command line error - Missing arg for '-ud'"
End If
opt_userdefs = args[count].ToLower()
Case "strict"
opt_need_strict=True
Case "ib"
opt_legacy_incbin=True
Case "cov"
opt_coverage=True
Case "nas"
opt_no_auto_superstrict=True
End Select
count:+ 1
Wend
If opt_buildtype = BUILDTYPE_MODULE Then
opt_apptype = APPTYPE_NONE
End If
If opt_arch = "x64" Or opt_arch = "arm64v8a" Or opt_arch = "arm64" Or opt_arch = "riscv64" Then
WORD_SIZE = 8
End If
' new incbin doesn't work on win32 x86
If opt_arch = "x86" And opt_platform = "win32" Then
opt_legacy_incbin = True
End If
If opt_makelib Then
If Not opt_nodef Then
opt_def = True
End If
If Not opt_nohead Then
opt_head = True
End If
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"
?arm64
opt_arch = "arm64"
?armeabi
opt_arch = "armeabi"
?armeabiv7a
opt_arch = "armeabiv7a"
?arm64v8a
opt_arch = "arm64v8a"
?js
opt_arch = "js"
?riscv32
opt_arch = "riscv32"
?riscv64
opt_arch = "riscv64"
?
?win32
opt_platform = "win32"
?macos
opt_platform = "macos"
?linux
opt_platform = "linux"
?android
opt_platform = "android"
?raspberrypi
opt_platform = "raspberrypi"
?haiku
opt_platform = "haiku"
?emscripten
opt_platform = "emscripten"
?
End Function
Function CheckConfig()
Local config:TConfigMap = New TConfigMap.Init("bcc.conf")
'try to load an OS-specific path (so all bcc builds could share
'one single bcc.conf)
Local osBmxPath:String = ""
?win32
osBmxPath = config.GetString("BMXPATH_WIN32")
?linux
osBmxPath = config.GetString("BMXPATH_LINUX")
?macos
osBmxPath = config.GetString("BMXPATH_MACOS")
?android
' override BMXPATH_LINUX if available
Local tmp:String = config.GetString("BMXPATH_ANDROID")
If tmp Then
osBmxPath = tmp
End If
?raspberrypi
' override BMXPATH_LINUX if available
Local tmp:String = config.GetString("BMXPATH_RASPBERRYPI")
If tmp Then
osBmxPath = tmp
End If
?haiku
osBmxPath = config.GetString("BMXPATH_HAIKU")
?
'load default/generic path
If osBmxPath = "" Then osBmxPath = config.GetString("BMXPATH")
'replace windows backslashes with crossplatform slashes
osBmxPath = osBmxPath.Replace("\", "/")
If osBmxPath <> "" Then putenv_("BMXPATH="+osBmxPath)
End Function