2
0

options.bmx 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. ' Copyright (c) 2013-2017 Bruce A Henderson
  2. '
  3. ' Based on the public domain Monkey "trans" by Mark Sibly
  4. '
  5. ' This software is provided 'as-is', without any express or implied
  6. ' warranty. In no event will the authors be held liable for any damages
  7. ' arising from the use of this software.
  8. '
  9. ' Permission is granted to anyone to use this software for any purpose,
  10. ' including commercial applications, and to alter it and redistribute it
  11. ' freely, subject to the following restrictions:
  12. '
  13. ' 1. The origin of this software must not be misrepresented; you must not
  14. ' claim that you wrote the original software. If you use this software
  15. ' in a product, an acknowledgment in the product documentation would be
  16. ' appreciated but is not required.
  17. '
  18. ' 2. Altered source versions must be plainly marked as such, and must not be
  19. ' misrepresented as being the original software.
  20. '
  21. ' 3. This notice may not be removed or altered from any source
  22. ' distribution.
  23. '
  24. SuperStrict
  25. Import "base.configmap.bmx"
  26. Const version:String = "0.92"
  27. Const BUILDTYPE_APP:Int = 0
  28. Const BUILDTYPE_MODULE:Int = 1
  29. Const APPTYPE_NONE:Int = 0
  30. Const APPTYPE_CONSOLE:Int = 1
  31. Const APPTYPE_GUI:Int = 2
  32. Global WORD_SIZE:Int = 4
  33. ' buildtype
  34. ' module
  35. ' app
  36. Global opt_buildtype:Int = BUILDTYPE_APP
  37. ' modulename
  38. ' name of the module to build
  39. Global opt_modulename:String
  40. ' arch
  41. ' x86
  42. ' ppc
  43. ' x64
  44. ' arm
  45. ' armeabi
  46. ' armeabiv7a
  47. ' armv7
  48. ' arm64
  49. Global opt_arch:String
  50. ' platform
  51. ' win32
  52. ' macos
  53. ' osx
  54. ' ios
  55. ' linux
  56. ' android
  57. ' raspberrypi
  58. Global opt_platform:String
  59. ' framework
  60. Global opt_framework:String
  61. ' filename
  62. ' the base filename for app/module to compile against
  63. Global opt_filename:String
  64. ' outfile
  65. ' full path to the outputfile (excluding final extension - there will be a .h, .c and .i generated)
  66. Global opt_outfile:String
  67. ' apptype
  68. ' console
  69. ' gui
  70. Global opt_apptype:Int = APPTYPE_NONE
  71. ' debug
  72. Global opt_debug:Int = True
  73. ' threaded
  74. Global opt_threaded:Int = True
  75. ' release
  76. Global opt_release:Int = False
  77. ' quiet
  78. Global opt_quiet:Int = False
  79. ' verbose
  80. Global opt_verbose:Int = False
  81. ' ismain
  82. ' this is the main file for either the module, or the application.
  83. Global opt_ismain:Int = False
  84. ' issuperstrict
  85. '
  86. Global opt_issuperstrict:Int = False
  87. ' gdbdebug
  88. ' output debug useful for gdb, #line <bmx line> <bmx file>
  89. Global opt_gdbdebug:Int = False
  90. '
  91. ' upgrade strict subclass method/function return types to match superstrict superclass.
  92. ' default is to auto-upgrade. Set flag if you want to throw an error - because of mismatch. (strict is Int, superstrict is Void).
  93. Global opt_strictupgrade:Int = True
  94. ' overload warnings
  95. ' generate warnings (and accept) instead of errors for calling methods with arguments that need to be cast down.
  96. ' May cause issues using overloaded methods.
  97. Global opt_warnover:Int = False
  98. ' musl libc support
  99. '
  100. Global opt_musl:Int = False
  101. Global opt_filepath:String
  102. Function CmdError(details:String = Null, fullUsage:Int = False)
  103. Local s:String = "Compile Error"
  104. If details Then
  105. s:+ ": " + details
  106. End If
  107. s:+ "~n"
  108. 's:+ Usage(fullUsage)
  109. Throw s
  110. End Function
  111. Function ParseArgs:String[](args:String[])
  112. DefaultOptions()
  113. CheckConfig()
  114. Local count:Int
  115. While count < args.length
  116. Local arg:String = args[count]
  117. If arg[..1] <> "-" Then
  118. Exit
  119. End If
  120. Select arg[1..]
  121. Case "q"
  122. opt_quiet=True
  123. Case "v"
  124. opt_verbose=True
  125. Case "r"
  126. opt_debug=False
  127. opt_release=True
  128. Case "h"
  129. opt_threaded=True
  130. Case "s"
  131. ' disable with option
  132. opt_strictupgrade=False
  133. Case "g"
  134. count:+1
  135. If count = args.length Then
  136. CmdError "Command line error - Missing arg for '-g'"
  137. End If
  138. opt_arch = args[count].ToLower()
  139. Case "m"
  140. count:+1
  141. If count = args.length Then
  142. CmdError "Command line error - Missing arg for '-m'"
  143. End If
  144. opt_buildtype = BUILDTYPE_MODULE
  145. opt_modulename = args[count].ToLower()
  146. Case "o"
  147. count:+1
  148. If count = args.length Then
  149. CmdError "Command line error - Missing arg for '-o'"
  150. End If
  151. opt_outfile = args[count]
  152. Case "p"
  153. count:+1
  154. If count = args.length Then
  155. CmdError "Command line error - Missing arg for '-p'"
  156. End If
  157. opt_platform = args[count].ToLower()
  158. Case "t"
  159. count:+1
  160. If count = args.length Then
  161. CmdError "Command line error - Missing arg for '-t'"
  162. End If
  163. Local apptype:String = args[count].ToLower()
  164. Select apptype
  165. Case "console"
  166. opt_apptype = APPTYPE_CONSOLE
  167. Case "gui"
  168. opt_apptype = APPTYPE_GUI
  169. Default
  170. CmdError "Command line error - Invalid app type '" + opt_apptype + "'"
  171. End Select
  172. Case "f"
  173. count:+1
  174. If count = args.length Then
  175. CmdError "Command line error - Missing arg for '-f'"
  176. End If
  177. opt_framework = args[count]
  178. Case "d"
  179. opt_gdbdebug=True
  180. Case "w"
  181. opt_warnover=True
  182. Case "musl"
  183. opt_musl=True
  184. End Select
  185. count:+ 1
  186. Wend
  187. If opt_buildtype = BUILDTYPE_MODULE Then
  188. opt_apptype = APPTYPE_NONE
  189. End If
  190. If opt_arch = "x64" Or opt_arch = "arm64v8a" Or opt_arch = "arm64" Then
  191. WORD_SIZE = 8
  192. End If
  193. Return args[count..]
  194. End Function
  195. Function DefaultOptions()
  196. ?x86
  197. opt_arch = "x86"
  198. ?ppc
  199. opt_arch = "ppc"
  200. ?x64
  201. opt_arch = "x64"
  202. ?arm
  203. opt_arch = "arm"
  204. ?arm64
  205. opt_arch = "arm64"
  206. ?armeabi
  207. opt_arch = "armeabi"
  208. ?armeabiv7a
  209. opt_arch = "armeabiv7a"
  210. ?arm64v8a
  211. opt_arch = "arm64v8a"
  212. ?js
  213. opt_arch = "js"
  214. ?
  215. ?win32
  216. opt_platform = "win32"
  217. ?macos
  218. opt_platform = "macos"
  219. ?linux
  220. opt_platform = "linux"
  221. ?android
  222. opt_platform = "android"
  223. ?raspberrypi
  224. opt_platform = "raspberrypi"
  225. ?emscripten
  226. opt_platform = "emscripten"
  227. ?
  228. End Function
  229. Function CheckConfig()
  230. Local config:TConfigMap = New TConfigMap.Init("bcc.conf")
  231. 'try to load an OS-specific path (so all bcc builds could share
  232. 'one single bcc.conf)
  233. Local osBmxPath:String = ""
  234. ?win32
  235. osBmxPath = config.GetString("BMXPATH_WIN32")
  236. ?linux
  237. osBmxPath = config.GetString("BMXPATH_LINUX")
  238. ?macos
  239. osBmxPath = config.GetString("BMXPATH_MACOS")
  240. ?android
  241. ' override BMXPATH_LINUX if available
  242. Local tmp:String = config.GetString("BMXPATH_ANDROID")
  243. If tmp Then
  244. osBmxPath = tmp
  245. End If
  246. ?raspberrypi
  247. ' override BMXPATH_LINUX if available
  248. Local tmp:String = config.GetString("BMXPATH_RASPBERRYPI")
  249. If tmp Then
  250. osBmxPath = tmp
  251. End If
  252. ?
  253. 'load default/generic path
  254. If osBmxPath = "" Then osBmxPath = config.GetString("BMXPATH")
  255. 'replace windows backslashes with crossplatform slashes
  256. osBmxPath = osBmxPath.Replace("\", "/")
  257. If osBmxPath <> "" Then putenv_("BMXPATH="+osBmxPath)
  258. End Function