bmk_config.bmx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. Strict
  2. Import BRL.MaxUtil
  3. Import BRL.StandardIO
  4. ?macos
  5. Import Pub.MacOS
  6. ?
  7. Import brl.map
  8. Import "stringbuffer_core.bmx"
  9. Const BMK_VERSION:String = "3.45"
  10. Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc;asm;S"
  11. Global opt_arch$
  12. Global opt_arch_set=False
  13. Global opt_outfile$
  14. Global opt_infile:String
  15. Global opt_framework$
  16. Global opt_apptype$="console"
  17. Global opt_debug=False
  18. Global opt_threaded=False
  19. Global opt_release=False
  20. Global opt_configmung$=""
  21. Global opt_kill=False
  22. Global opt_modfilter$="."
  23. Global opt_all=False
  24. Global opt_quiet=False
  25. Global opt_verbose=False
  26. Global opt_execute=False
  27. Global opt_appstub$="brl.appstub" ' BaH 28/9/2007
  28. Global opt_universal=False
  29. Global opt_target_platform:String
  30. Global opt_target_platform_set=False
  31. Global opt_gdbdebug=False
  32. Global opt_gdbdebug_set=False
  33. Global opt_standalone=False
  34. Global opt_standalone_set=False
  35. Global opt_nolog
  36. Global opt_quickscan=False
  37. Global opt_quickscan_set=False
  38. Global opt_nostrictupgrade=False
  39. Global opt_nostrictupgrade_set=False
  40. Global opt_warnover=False
  41. Global opt_warnover_set=False
  42. Global opt_musl=False
  43. Global opt_musl_set=False
  44. Global opt_static=False
  45. Global opt_static_set=False
  46. Global opt_boot:Int
  47. Global opt_manifest:Int = True
  48. Global opt_single:Int
  49. Global opt_nodef:Int
  50. Global opt_nohead:Int
  51. Global opt_require_override:Int
  52. Global opt_override_error:Int
  53. Global opt_nopie:Int
  54. Global opt_nopie_set:Int
  55. Global opt_upx:Int
  56. Global opt_userdefs:String
  57. Global opt_gprof:Int
  58. Global opt_hi:Int
  59. Global opt_dumpbuild
  60. 'Global cfg_platform$
  61. Global macos_version:Int=2784 ' 10.14
  62. Global app_main$
  63. Global app_type$
  64. ?MacOS
  65. Function GetVersion:Int()
  66. Local major:Int
  67. Local minor:Int
  68. Local patch:Int
  69. NSOSVersion(major, minor, patch)
  70. Return major Shl 8 | minor Shl 4 | patch
  71. End Function
  72. macos_version = GetVersion()
  73. ?MacOsPPC
  74. If is_pid_native(0) opt_arch="ppc" Else opt_arch="x86"
  75. ?MacOsX86
  76. If is_pid_native(0) opt_arch="x86" Else opt_arch="ppc"
  77. ?MacOsx64
  78. opt_arch="x64"
  79. ?MacOsarm64
  80. opt_arch="arm64"
  81. ?win32x64
  82. opt_arch="x64"
  83. ?Win32x86
  84. opt_arch="x86"
  85. ?Win32
  86. 'Fudge PATH so exec sees our MinGW first!
  87. Local mingw$=getenv_( "MINGW" )
  88. If mingw
  89. Local path$=getenv_( "PATH" )
  90. If path
  91. path=mingw+"\bin;"+path
  92. putenv_ "PATH="+path
  93. EndIf
  94. EndIf
  95. ?Linuxx86
  96. opt_arch="x86"
  97. ?linuxx64
  98. opt_arch="x64"
  99. ?linuxarm
  100. opt_arch="arm"
  101. ?linuxarm64
  102. opt_arch="arm64"
  103. ?raspberrypi
  104. opt_arch="arm"
  105. ?raspberrypi64
  106. opt_arch="arm64"
  107. ?haikux86
  108. opt_arch="x86"
  109. ?haikux64
  110. opt_arch="x64"
  111. ?
  112. TStringBuffer.initialCapacity = 128
  113. ChangeDir LaunchDir
  114. Function CmdError(details:String = Null, fullUsage:Int = False)
  115. Local s:String = "Command line error"
  116. If details Then
  117. s:+ " : " + details
  118. End If
  119. s:+ "~n"
  120. s:+ Usage(fullUsage)
  121. Throw s
  122. End Function
  123. Function MissingArg(arg:String)
  124. CmdError "Missing arg for '-" + arg + "'"
  125. End Function
  126. Function ParseConfigArgs$[]( args$[], legacyMax:Int = False )
  127. Local n
  128. If getenv_( "BMKDUMPBUILD" )
  129. opt_dumpbuild=1
  130. opt_quiet=True
  131. EndIf
  132. For n=0 Until args.length
  133. Local arg$=args[n]
  134. If arg[..1]<>"-" Exit
  135. Local argv:String = arg[1..]
  136. Select argv
  137. Case "a", "all"
  138. opt_all=True
  139. Case "q"
  140. opt_quiet=True
  141. Case "v"
  142. opt_verbose=True
  143. Case "x"
  144. opt_execute=True
  145. Case "d", "debug"
  146. opt_debug=True
  147. opt_release=False
  148. Case "r", "release"
  149. opt_debug=False
  150. opt_release=True
  151. Case "h"
  152. opt_threaded=True
  153. Case "k"
  154. opt_kill=True
  155. Case "g", "arch"
  156. n:+1
  157. If n=args.length MissingArg(argv)
  158. opt_arch=args[n].ToLower()
  159. ValidateArch(opt_arch)
  160. opt_arch_set = True
  161. Case "t", "type"
  162. n:+1
  163. If n=args.length MissingArg(argv)
  164. opt_apptype=args[n].ToLower()
  165. Case "o", "output"
  166. n:+1
  167. If n=args.length MissingArg(argv)
  168. opt_outfile=args[n]
  169. Case "f", "framework"
  170. n:+1
  171. If n=args.length MissingArg(argv)
  172. opt_framework=args[n]
  173. Case "b"
  174. n:+1
  175. If n=args.length MissingArg(argv)
  176. opt_appstub=args[n]
  177. Case "i"
  178. ?macos
  179. ' this is mac/ios only... pah!
  180. opt_universal = True
  181. ?
  182. Case "l", "platform"
  183. n:+1
  184. If n=args.length MissingArg(argv)
  185. opt_target_platform=args[n].ToLower()
  186. ValidatePlatform(opt_target_platform)
  187. opt_target_platform_set = True
  188. Case "gdb"
  189. opt_gdbdebug = True
  190. opt_gdbdebug_set = True
  191. Case "standalone"
  192. opt_standalone = True
  193. opt_standalone_set = True
  194. Case "quick"
  195. opt_quickscan = True
  196. opt_quickscan_set = True
  197. Case "nostrictupgrade"
  198. opt_nostrictupgrade = True
  199. opt_nostrictupgrade_set = True
  200. Case "w"
  201. opt_warnover = True
  202. opt_warnover_set = True
  203. Case "musl"
  204. opt_musl = True
  205. opt_musl_set = True
  206. Case "static"
  207. opt_static = True
  208. opt_static_set = True
  209. Case "nomanifest"
  210. opt_manifest = False
  211. Case "single"
  212. opt_single = True
  213. Case "nodef"
  214. opt_nodef = True
  215. Case "nohead"
  216. opt_nohead = True
  217. Case "override"
  218. opt_require_override = True
  219. Case "overerr"
  220. opt_override_error = True
  221. Case "no-pie"
  222. opt_nopie = True
  223. opt_nopie_set = True
  224. Case "upx"
  225. opt_upx = True
  226. Case "ud"
  227. n:+1
  228. If n=args.length MissingArg(argv)
  229. opt_userdefs=args[n]
  230. Case "gprof"
  231. opt_gprof = True
  232. Case "hi"
  233. opt_hi = True
  234. Default
  235. CmdError "Invalid option '" + argv + "'"
  236. End Select
  237. Next
  238. If Not legacyMax Then
  239. If opt_threaded And opt_verbose Then
  240. Print "Note: NG builds are threaded by default."
  241. End If
  242. opt_threaded=True
  243. End If
  244. Return args[n..]
  245. End Function
  246. Function CQuote$( t$ )
  247. If t And t[0]=Asc("-") Return t
  248. For Local i=0 Until t.length
  249. If t[i]=Asc(".") Continue
  250. If t[i]=Asc("/") Continue
  251. 'If processor.Platform() = "win32"
  252. If t[i]=Asc("\") Continue
  253. 'End If
  254. If t[i]=Asc("_") Or t[i]=Asc("-") Continue
  255. If t[i]>=Asc("0") And t[i]<=Asc("9") Continue
  256. If t[i]>=Asc("A") And t[i]<=Asc("Z") Continue
  257. If t[i]>=Asc("a") And t[i]<=Asc("z") Continue
  258. Return "~q"+t+"~q"
  259. Next
  260. Return t
  261. End Function
  262. Function ReQuote:String(t:String)
  263. Return t.Replace("~~q", "~q")
  264. End Function
  265. Function CharIsDigit:Int( ch:Int )
  266. Return ch>=Asc("0") And ch<=Asc("9")
  267. End Function
  268. Function CharIsAlpha:Int( ch:Int )
  269. Return ch=Asc("_") Or (ch>=Asc("a") And ch<=Asc("z")) Or (ch>=Asc("A") And ch<=Asc("Z"))
  270. End Function
  271. Function EscapeSpaces:String(path:String)
  272. Return path.Replace(" ", "\\ ")
  273. End Function
  274. Function Usage:String(fullUsage:Int = False)
  275. Local s:String = "~nUsage: bmk <operation> [options] source~n~n"
  276. If Not fullUsage Then
  277. s:+ "(start bmk with no parameters for more usage information)~n~n"
  278. Else
  279. s:+ "Operations :~n"
  280. s:+ "~tmakeapp~n"
  281. s:+ "~t~tBuilds an application from a single root source file."
  282. s:+ "~n~n"
  283. s:+ "~tmakelib~n"
  284. s:+ "~t~tBuilds a shared library/DLL file from a single root source file."
  285. s:+ "~n~n"
  286. s:+ "~tmakemods~n"
  287. s:+ "~t~tBuilds a set of modules."
  288. s:+ "~n~n"
  289. s:+ "Options :~n"
  290. s:+ "~t-a | -all~n"
  291. s:+ "~t~tRecompile all source/modules regardless of timestamp. By default, only those modified~n" + ..
  292. "~t~tsince the last build are recompiled."
  293. s:+ "~n~n"
  294. s:+ "~t-b <custom appstub module>~n"
  295. s:+ "~t~tBuilds an app using a custom appstub (i.e. not BRL.Appstub).~n"
  296. s:+ "~t~tThis can be useful when you want more control over low-level application state."
  297. s:+ "~n~n"
  298. s:+ "~t-d | -debug~n"
  299. s:+ "~t~tBuilds a debug version. (This is the default for makeapp)."
  300. s:+ "~n~n"
  301. s:+ "~t-g <architecture> | -arch <architecture>~n"
  302. s:+ "~t~tCompiles to the specified architecture. (the default is the native for this binary - "
  303. ?x86
  304. s:+ "x86"
  305. ?x64
  306. s:+ "x64"
  307. ?ppc
  308. s:+ "ppc"
  309. ?arm
  310. s:+ "arm"
  311. ?arm64
  312. s:+ "arm64"
  313. ?armeabi
  314. s:+ "armeabi"
  315. ?armeabiv7a
  316. s:+ "armeabiv7a"
  317. ?arm64v8a
  318. s:+ "arm64v8a"
  319. ?js
  320. s:+ "js"
  321. ?
  322. s:+ ")~n"
  323. s:+ "~t~tOptions vary depending on the current OS/architecture/installed toolchain and version of bcc.~n"
  324. s:+ "~t~t~tMacOS : x86, x64, arm64~n"
  325. s:+ "~t~t~tWin32 : x86, x64~n"
  326. s:+ "~t~t~tLinux : x86, x64, arm, arm64~n"
  327. s:+ "~t~t~tiOS : x86, x64 (simulator), armv7, arm64~n"
  328. s:+ "~t~t~tAndroid : x86, x64, arm, armeabi, armeabiv7a, arm64v8a~n"
  329. s:+ "~t~t~tRaspberryPi : arm, arm64~n"
  330. s:+ "~t~t~tnx : arm64~n"
  331. s:+ "~t~t~thaiku : x86, x64~n"
  332. s:+ "~n~n"
  333. s:+ "~t-gdb~n"
  334. s:+ "~t~tGenerates line mappings suitable for GDB debugging.~n"
  335. s:+ "~t~tBacktrace (etc.) will show .bmx relative source lines rather than that of the generated code."
  336. s:+ "~n~n"
  337. s:+ "~t-gprof~n"
  338. s:+ "~t~tCompiles for gprof profiling.~n"
  339. s:+ "~n~n"
  340. s:+ "~t-h~n"
  341. s:+ "~t~tBuild multithreaded version. (This is the default on NG)~n"
  342. s:+ "~t~tThe default on legacy BlitzMax is to build non-threaded. On legacy, using this option will also~n"
  343. s:+ "~t~tadd a .mt suffix to the executable."
  344. s:+ "~n~n"
  345. s:+ "~t-hi~n"
  346. s:+ "~t~tSpecifies that the application supports high-resolution screens (HiDPI). (GUI only)~n"
  347. s:+ "~t~tThis will, for example, configure the macOS bundle with the appropriate plist settings."
  348. s:+ "~n~n"
  349. s:+ "~t-i~n"
  350. s:+ "~t~tCreates a Universal build for supported platforms.~n"
  351. s:+ "~t~t(see documentation for full list of requirements)"
  352. s:+ "~n~n"
  353. s:+ "~t-l <target platfom> | -platform <target platform>~n"
  354. s:+ "~t~tCross-compiles to the specific target platform.~n"
  355. s:+ "~t~tValid targets are win32, linux, macos, ios, android, raspberrypi and haiku.~n"
  356. s:+ "~t~t(see documentation for full list of requirements)"
  357. s:+ "~n~n"
  358. s:+ "~t-musl~n"
  359. s:+ "~t~tEnable musl libc compatibility. (Linux NG only)"
  360. s:+ "~n~n"
  361. s:+ "~t-nomanifest~n"
  362. s:+ "~t~tDon't add an automatically generated manifest and resources to a Win32 application. (Win32 only)~n"
  363. s:+ "~t~tName .ico file as <app name>.ico to be included in the the resource.~n"
  364. s:+ "~t~tConfigurable application details are placed in the file <app name>.settings"
  365. s:+ "~n~n"
  366. s:+ "~t-nostrictupgrade~n"
  367. s:+ "~t~tDon't upgrade strict method void return types, if required. (NG only)~n"
  368. s:+ "~t~tIf a Strict sub type overrides the method of a SuperStrict type and the return type is void,~n"
  369. s:+ "~t~tdon't upgrade the return type to void (i.e. none), and default it to Int."
  370. s:+ "~n~n"
  371. s:+ "~t-o <output file> | -output <output file>~n"
  372. s:+ "~t~tSpecify output file. (makeapp only)~n"
  373. s:+ "~t~tBy default, the output file is placed into the same directory as the root source file."
  374. s:+ "~n~n"
  375. s:+ "~t-override~n"
  376. s:+ "~t~tWarn if overriding methods are not declared with Override property (NG only)~n"
  377. s:+ "~n~n"
  378. s:+ "~t-overerr~n"
  379. s:+ "~t~tUpgrades -override warnings to errors. (NG only)~n"
  380. s:+ "~n~n"
  381. s:+ "~t-no-pie~n"
  382. s:+ "~t~tDisables option to compile position independent executables. (NG & Linux only)~n"
  383. s:+ "~n~n"
  384. s:+ "~t-q~n"
  385. s:+ "~t~tQuiet build."
  386. s:+ "~n~n"
  387. s:+ "~t-quick~n"
  388. s:+ "~t~tQuick build.~n"
  389. s:+ "~t~tDoes not scans modules for changes. May result in quicker build times on some systems.~n"
  390. s:+ "~t~tThe default behaviour is to scan and build all requirements for the application,~n"
  391. s:+ "~t~tincluding modules."
  392. s:+ "~n~n"
  393. s:+ "~t-r | -release~n"
  394. s:+ "~t~tBuilds a release version."
  395. s:+ "~n~n"
  396. s:+ "~t-standalone~n"
  397. s:+ "~t~tGenerate but do not compile into binary form.~n"
  398. s:+ "~t~tUseful for creating ready-to-build source for a different platform/architecture."
  399. s:+ "~n~n"
  400. s:+ "~t-static~n"
  401. s:+ "~t~tStatically link binary. (Linux NG only)"
  402. s:+ "~n~n"
  403. s:+ "~t-t <app type> | -type <app type>~n"
  404. s:+ "~t~tSpecify application type. (makeapp only)~n"
  405. s:+ "~t~tShould be either 'console' or 'gui' (without single quote!).~n"
  406. s:+ "~t~tThe default is console."
  407. s:+ "~n~n"
  408. s:+ "~t-ud <definitions>~n"
  409. s:+ "~t~tAdd user defined compiler options. (NG only).~n"
  410. s:+ "~t~tA comma-separated list of compiler options that can be used in addition to the defaults.~n"
  411. s:+ "~t~tAlternatively, the option 'adddef' can be used in build scripts to provide the same.~n"
  412. s:+ "~n~n"
  413. s:+ "~t-upx~n"
  414. s:+ "~t~tPack binary using UPX. (makeapp only)."
  415. s:+ "~n~n"
  416. s:+ "~t-v~n"
  417. s:+ "~t~tVerbose (noisy) build."
  418. s:+ "~n~n"
  419. s:+ "~t-w~n"
  420. s:+ "~t~tWarn about function argument casting issues rather than error. (NG only)~n"
  421. s:+ "~t~tWith this warning enabled you may have issues with method overloading."
  422. s:+ "~n~n"
  423. s:+ "~t-x~n"
  424. s:+ "~t~tExecute built application. (makeapp only)"
  425. s:+ "~n~n"
  426. End If
  427. Return s
  428. End Function
  429. Function VersionInfo(gcc:String, cores:Int, xcode:String)
  430. Local s:String = "bmk "
  431. s:+ BMK_VERSION + " "
  432. ?threaded
  433. s:+ "mt-"
  434. ?
  435. ?win32
  436. s:+ "win32"
  437. ?linux
  438. s:+ "linux"
  439. ?macos
  440. s:+ "macos"
  441. ?osx
  442. s:+ "-osx"
  443. ?ios
  444. s:+ "-ios"
  445. ?android
  446. s:+ "-android"
  447. ?raspberrypi
  448. s:+ "-raspberrypi"
  449. ?haiku
  450. s:+ "haiku"
  451. ?emscripten
  452. s:+ "-emscripten"
  453. ?
  454. s:+ "-"
  455. ?x86
  456. s:+ "x86"
  457. ?ppc
  458. s:+ "ppc"
  459. ?x64
  460. s:+ "x64"
  461. ?arm
  462. s:+ "arm"
  463. ?arm64
  464. s:+ "arm64"
  465. ?armeabi
  466. s:+ "armeabi"
  467. ?armeabiv7a
  468. s:+ "armeabiv7a"
  469. ?arm64v8a
  470. s:+ "arm64v8a"
  471. ?js
  472. s:+ "js"
  473. ?
  474. s:+ " / " + gcc
  475. If xcode Then
  476. s:+ " / xcode " + xcode
  477. End If
  478. s:+ " (cpu x" + cores + ")"
  479. Print s + "~n"
  480. End Function
  481. Function AsConfigurable:Int(key:String, value:String)
  482. Local config:Int = False
  483. Local set:Int = 0
  484. Select key
  485. Case "opt_warnover"
  486. If Not opt_warnover_set Then
  487. opt_warnover = Int(value)
  488. set = 1
  489. Else
  490. If opt_warnover <> Int(value) Then
  491. set = 2
  492. End If
  493. End If
  494. config = True
  495. Case "opt_quickscan"
  496. If Not opt_quickscan_set Then
  497. opt_quickscan = Int(value)
  498. set = 1
  499. Else
  500. If opt_quickscan <> Int(value) Then
  501. set = 2
  502. End If
  503. End If
  504. config = True
  505. Case "opt_gdbdebug"
  506. If Not opt_gdbdebug_set Then
  507. opt_gdbdebug = Int(value)
  508. set = 1
  509. Else
  510. If opt_gdbdebug <> Int(value) Then
  511. set = 2
  512. End If
  513. End If
  514. config = True
  515. Case "opt_standalone"
  516. If Not opt_standalone_set Then
  517. opt_standalone = Int(value)
  518. set = 1
  519. Else
  520. If opt_standalone <> Int(value) Then
  521. set = 2
  522. End If
  523. End If
  524. config = True
  525. Case "opt_nostrictupgrade"
  526. If Not opt_nostrictupgrade_set Then
  527. opt_nostrictupgrade = Int(value)
  528. set = 1
  529. Else
  530. If opt_nostrictupgrade <> Int(value) Then
  531. set = 2
  532. End If
  533. End If
  534. config = True
  535. Case "opt_arch"
  536. If Not opt_arch_set Then
  537. opt_arch = value.ToLower()
  538. ValidateArch(opt_arch)
  539. set = 1
  540. Else
  541. If opt_arch <> value.ToLower() Then
  542. set = 2
  543. End If
  544. End If
  545. config = True
  546. Case "opt_target_platform"
  547. If Not opt_target_platform_set Then
  548. opt_target_platform = value.ToLower()
  549. ValidatePlatform(opt_target_platform)
  550. set = 1
  551. Else
  552. If opt_target_platform <> value.ToLower() Then
  553. set = 2
  554. End If
  555. End If
  556. config = True
  557. Case "opt_musl"
  558. If Not opt_musl_set Then
  559. opt_musl = Int(value)
  560. set = 1
  561. Else
  562. If opt_musl <> Int(value) Then
  563. set = 2
  564. End If
  565. End If
  566. config = True
  567. Case "opt_static"
  568. If Not opt_static_set Then
  569. opt_static = Int(value)
  570. set = 1
  571. Else
  572. If opt_static <> Int(value) Then
  573. set = 2
  574. End If
  575. End If
  576. config = True
  577. Case "opt_nopie"
  578. If Not opt_nopie_set Then
  579. opt_nopie = Int(value)
  580. set = 1
  581. Else
  582. If opt_nopie <> Int(value) Then
  583. set = 2
  584. End If
  585. End If
  586. config = True
  587. End Select
  588. If set And opt_verbose Then
  589. If set = 1 Then
  590. Print "Using " + key.ToUpper() + " = " + value
  591. Else
  592. Print "Config " + key.ToUpper() + " = " + value + " was NOT used because command-line arguments override it"
  593. End If
  594. End If
  595. Return config
  596. End Function
  597. Function ValidateArch(arch:String)
  598. Select arch
  599. Case "ppc"
  600. Case "x86"
  601. Case "x64"
  602. Case "arm"
  603. Case "armeabi"
  604. Case "armeabiv7a"
  605. Case "arm64v8a"
  606. Case "armv7"
  607. Case "arm64"
  608. Case "js"
  609. Default
  610. CmdError "Not a valid architecture : '" + arch + "'"
  611. End Select
  612. End Function
  613. Function ValidatePlatform(platform:String)
  614. Select platform
  615. Case "win32"
  616. Case "macos"
  617. Case "osx"
  618. Case "ios"
  619. Case "linux"
  620. Case "android"
  621. Case "raspberrypi"
  622. Case "emscripten"
  623. Case "nx"
  624. Case "haiku"
  625. Default
  626. ' oops
  627. CmdError "Not valid platform : '" + platform + "'"
  628. End Select
  629. End Function
  630. Function ParseApplicationIniFile:TMap()
  631. Local ids:String[] = [StripDir(StripExt(opt_outfile)), StripDir(StripExt(opt_infile))]
  632. Local appId:String = ids[0]
  633. Local buildDir:String = ExtractDir(opt_infile)
  634. Local path:String
  635. Local found:Int
  636. Local settings:TMap = New TMap
  637. For Local id:String = EachIn ids
  638. path = buildDir + "/" + id + ".settings"
  639. If Not FileType(path) Then
  640. If opt_verbose Then
  641. Print "Not Found : application settings file '" + id + ".settings'."
  642. End If
  643. Continue
  644. End If
  645. found = True
  646. Exit
  647. Next
  648. If Not found Then
  649. If opt_verbose Then
  650. Print "Using defaults."
  651. End If
  652. Return DefaultApplicationSettings()
  653. End If
  654. Local file:TStream = ReadFile(path)
  655. If Not file
  656. Return Null
  657. EndIf
  658. Local line:String
  659. Local pos:Int
  660. While Not Eof(file)
  661. line = ReadLine(file).Trim()
  662. If line.Find("#") = 0 Then
  663. Continue
  664. End If
  665. pos = line.Find("=")
  666. If pos = -1 Then
  667. Continue
  668. End If
  669. settings.Insert(line[..pos], line[pos+1..])
  670. Wend
  671. file.Close()
  672. Local id:String = StripDir(StripExt(opt_outfile))
  673. If opt_debug And opt_outfile.EndsWith(".debug") Then
  674. id :+ ".debug"
  675. End If
  676. settings.Insert("app.id", id)
  677. If Not settings.Contains("app.version.major") Then
  678. Local version:String = String(settings.ValueForKey("app.version.name"))
  679. If version Then
  680. Local parts:String[] = version.Split(".")
  681. For Local i:Int = 0 Until parts.length
  682. Select i
  683. Case 0
  684. settings.Insert("app.version.major", String.FromInt(parts[i].ToInt()))
  685. Case 1
  686. settings.Insert("app.version.minor", String.FromInt(parts[i].ToInt()))
  687. Case 2
  688. settings.Insert("app.version.patch", String.FromInt(parts[i].ToInt()))
  689. Case 3
  690. settings.Insert("app.version.build", String.FromInt(parts[i].ToInt()))
  691. End Select
  692. Next
  693. End If
  694. End If
  695. Return settings
  696. End Function
  697. Function DefaultApplicationSettings:TMap()
  698. Local appId:String = StripDir(StripExt(opt_outfile))
  699. If opt_debug And opt_outfile.EndsWith(".debug") Then
  700. appId :+ ".debug"
  701. End If
  702. Local settings:TMap = New TMap
  703. settings.Insert("app.package", "com.blitzmax.app")
  704. settings.Insert("app.version.code", "1")
  705. settings.Insert("app.version.name", "1.0.0")
  706. settings.Insert("app.name", appId)
  707. settings.Insert("app.orientation", "landscape")
  708. settings.Insert("app.comments", "BlitzMax Application")
  709. settings.Insert("app.company", "My company")
  710. settings.Insert("app.description", appId)
  711. settings.Insert("app.copyright", "Copyright")
  712. settings.Insert("app.trademarks", "All rights reserved")
  713. settings.Insert("app.id", appId)
  714. Return settings
  715. End Function