bmk_config.bmx 19 KB

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