bmk_config.bmx 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. Strict
  2. Import BRL.MaxUtil
  3. Import Pub.MacOS
  4. Const BMK_VERSION:String = "2.00"
  5. Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s"
  6. Global opt_arch$
  7. Global opt_server$
  8. Global opt_outfile$
  9. Global opt_framework$
  10. Global opt_apptype$="console"
  11. Global opt_debug=False
  12. Global opt_threaded=False
  13. Global opt_release=False
  14. Global opt_configmung$=""
  15. Global opt_kill=False
  16. Global opt_username$="nobody"
  17. Global opt_password$="anonymous"
  18. Global opt_modfilter$="."
  19. Global opt_all=False
  20. Global opt_quiet=False
  21. Global opt_verbose=False
  22. Global opt_execute=False
  23. Global opt_proxy$
  24. Global opt_proxyport
  25. Global opt_traceheaders
  26. Global opt_appstub$="brl.appstub" ' BaH 28/9/2007
  27. Global opt_universal=False
  28. Global opt_target_platform:String
  29. Global opt_dumpbuild
  30. 'Global cfg_platform$
  31. Global macos_version
  32. ?MacOS
  33. 'cfg_platform="macos"
  34. Gestalt Asc("s")Shl 24|Asc("y")Shl 16|Asc("s")Shl 8|Asc("v"),macos_version
  35. ?MacOsPPC
  36. If is_pid_native(0) opt_arch="ppc" Else opt_arch="x86"
  37. ?MacOsX86
  38. If is_pid_native(0) opt_arch="x86" Else opt_arch="ppc"
  39. ?Win32
  40. opt_arch="x86"
  41. 'cfg_platform="win32"
  42. ?Linux
  43. opt_arch="x86"
  44. 'cfg_platform="linux"
  45. ?
  46. ChangeDir LaunchDir
  47. Function CmdError(details:String = Null, fullUsage:Int = False)
  48. Local s:String = "Command line error"
  49. If details Then
  50. s:+ " : " + details
  51. End If
  52. s:+ "~n"
  53. s:+ Usage(fullUsage)
  54. Throw s
  55. End Function
  56. Function ParseConfigArgs$[]( args$[] )
  57. Local n
  58. If getenv_( "BMKDUMPBUILD" )
  59. opt_dumpbuild=1
  60. opt_quiet=True
  61. EndIf
  62. For n=0 Until args.length
  63. Local arg$=args[n]
  64. If arg[..1]<>"-" Exit
  65. Select arg[1..]
  66. Case "a"
  67. opt_all=True
  68. Case "q"
  69. opt_quiet=True
  70. Case "v"
  71. opt_verbose=True
  72. Case "x"
  73. opt_execute=True
  74. Case "d"
  75. opt_debug=True
  76. opt_release=False
  77. Case "r"
  78. opt_debug=False
  79. opt_release=True
  80. Case "h"
  81. opt_threaded=True
  82. Case "k"
  83. opt_kill=True
  84. Case "z"
  85. opt_traceheaders=True
  86. Case "y"
  87. n:+1
  88. If n=args.length CmdError "Missing arg for '-y'"
  89. opt_proxy=args[n]
  90. Local i=opt_proxy.Find(":")
  91. If i<>-1
  92. opt_proxyport=Int( opt_proxy[i+1..] )
  93. opt_proxy=opt_proxy[..i]
  94. EndIf
  95. Case "g"
  96. n:+1
  97. If n=args.length CmdError "Missing arg for '-g'"
  98. opt_arch=args[n].ToLower()
  99. Case "t"
  100. n:+1
  101. If n=args.length CmdError "Missing arg for '-t'"
  102. opt_apptype=args[n].ToLower()
  103. Case "o"
  104. n:+1
  105. If n=args.length CmdError "Missing arg for '-o'"
  106. opt_outfile=args[n]
  107. Case "f"
  108. n:+1
  109. If n=args.length CmdError "Missing arg for '-f'"
  110. opt_framework=args[n]
  111. Case "s"
  112. n:+1
  113. If n=args.length CmdError "Missing arg for '-s'"
  114. opt_server=args[n]
  115. Case "u"
  116. n:+1
  117. If n=args.length CmdError "Missing arg for '-u'"
  118. opt_username=args[n]
  119. Case "p"
  120. n:+1
  121. If n=args.length CmdError "Missing arg for '-p'"
  122. opt_password=args[n]
  123. Case "b"
  124. n:+1
  125. If n=args.length CmdError "Missing arg for '-b'"
  126. opt_appstub=args[n]
  127. Case "i"
  128. ?macos
  129. ' this is mac only... pah!
  130. opt_universal = True
  131. ?
  132. Case "l"
  133. n:+1
  134. If n=args.length CmdError "Missing arg for '-l'"
  135. opt_target_platform=args[n].ToLower()
  136. If opt_target_platform <> "win32" And opt_target_platform <> "mac" And opt_target_platform <> "linux" CmdError "Not valid platform : '" + opt_target_platform + "'"
  137. Default
  138. CmdError "Invalid option '" + arg[1..] + "'"
  139. End Select
  140. Next
  141. Return args[n..]
  142. End Function
  143. Function CQuote$( t$ )
  144. If t And t[0]=Asc("-") Return t
  145. For Local i=0 Until t.length
  146. If t[i]=Asc(".") Continue
  147. If t[i]=Asc("/") Continue
  148. 'If processor.Platform() = "win32"
  149. If t[i]=Asc("\") Continue
  150. 'End If
  151. If t[i]=Asc("_") Or t[i]=Asc("-") Continue
  152. If t[i]>=Asc("0") And t[i]<=Asc("9") Continue
  153. If t[i]>=Asc("A") And t[i]<=Asc("Z") Continue
  154. If t[i]>=Asc("a") And t[i]<=Asc("z") Continue
  155. Return "~q"+t+"~q"
  156. Next
  157. Return t
  158. End Function
  159. Function CharIsDigit:Int( ch:Int )
  160. Return ch>=Asc("0") And ch<=Asc("9")
  161. End Function
  162. Function CharIsAlpha:Int( ch:Int )
  163. Return ch=Asc("_") Or (ch>=Asc("a") And ch<=Asc("z")) Or (ch>=Asc("A") And ch<=Asc("Z"))
  164. End Function
  165. Function Usage:String(fullUsage:Int = False)
  166. Local s:String = "~nUsage: bmk <operation> [options] source~n~n"
  167. If Not fullUsage Then
  168. s:+ "(start bmk with no parameters for more usage information)~n~n"
  169. Else
  170. s:+ "Operations :~n"
  171. s:+ "~tmakeapp~n"
  172. s:+ "~t~tBuilds an application from a single root source file."
  173. s:+ "~n~n"
  174. s:+ "~tmakemods~n"
  175. s:+ "~t~tBuilds a set of modules."
  176. s:+ "~n~n"
  177. s:+ "Options :~n"
  178. s:+ "~t-a~n"
  179. s:+ "~t~tRecompile all source/modules regardless of timestamp. By default, only those modified~n" + ..
  180. "~t~tsince the last build are recompiled."
  181. s:+ "~n~n"
  182. s:+ "~t-b <custom appstub module>~n"
  183. s:+ "~t~tBuilds an app using a custom appstub (i.e. not BRL.Appstub).~n"
  184. s:+ "~t~tThis can be useful when you want more control over low-level application state."
  185. s:+ "~n~n"
  186. s:+ "~t-d~n"
  187. s:+ "~t~tBuilds a debug version. (This is the default for makeapp)."
  188. s:+ "~n~n"
  189. s:+ "~t-h~n"
  190. s:+ "~t~tBuild multithreaded version. (By default, the single threaded version is built.)"
  191. s:+ "~n~n"
  192. s:+ "~t-i~n"
  193. s:+ "~t~tCreates a Universal build on Mac x86 systems.~n"
  194. s:+ "~t~t(see documentation for full list of requirements)"
  195. s:+ "~n~n"
  196. s:+ "~t-l <target platfom>~n"
  197. s:+ "~t~tCross-compiles to the specific target platform.~n"
  198. s:+ "~t~tCurrently, only win32 is supported as a target platform on Mac and Linux systems.~n"
  199. s:+ "~t~t(see documentation for full list of requirements)"
  200. s:+ "~n~n"
  201. s:+ "~t-o <output file>~n"
  202. s:+ "~t~tSpecify output file. (makeapp only)~n"
  203. s:+ "~t~tBy default, the output file is placed into the same directory as the root source file."
  204. s:+ "~n~n"
  205. s:+ "~t-q~n"
  206. s:+ "~t~tQuiet build."
  207. s:+ "~n~n"
  208. s:+ "~t-r~n"
  209. s:+ "~t~tBuilds a release version."
  210. s:+ "~n~n"
  211. s:+ "~t-t <app type>~n"
  212. s:+ "~t~tSpecify application type. (makeapp only)~n"
  213. s:+ "~t~tShould be either 'console' or 'gui' (without single quote!).~n"
  214. s:+ "~t~tThe default is console."
  215. s:+ "~n~n"
  216. s:+ "~t-v~n"
  217. s:+ "~t~tVerbose (noisy) build."
  218. s:+ "~n~n"
  219. s:+ "~t-x~n"
  220. s:+ "~t~tExecute built application. (makeapp only)"
  221. s:+ "~n~n"
  222. End If
  223. Return s
  224. End Function
  225. Function VersionInfo()
  226. Local s:String = "bmk "
  227. s:+ BMK_VERSION + " "
  228. ?threaded
  229. s:+ "mt-"
  230. ?
  231. ?win32
  232. s:+ "win32"
  233. ?linux
  234. s:+ "linux"
  235. ?macos
  236. s:+ "macos"
  237. ?
  238. s:+ "-"
  239. ?x86
  240. s:+ "x86"
  241. ?ppc
  242. s:+ "ppc"
  243. ?
  244. Print s + "~n"
  245. End Function