bmk_modutil.bmx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. Strict
  2. Import BRL.MaxUtil
  3. Import BRL.TextStream
  4. Import "bmk_util.bmx"
  5. Import "options_parser.bmx"
  6. Const SOURCE_UNKNOWN:Int = 0
  7. Const SOURCE_BMX:Int = $01
  8. Const SOURCE_IFACE:Int = $02
  9. Const SOURCE_C:Int = $04
  10. Const SOURCE_HEADER:Int = $08
  11. Const SOURCE_ASM:Int = $10
  12. Const SOURCE_RES:Int = $20
  13. 'Const SOURCE_PYTHON:Int = $20
  14. 'Const SOURCE_PERL:Int = $40
  15. 'Const SOURCE_RUBY:Int = $80
  16. ' etc ?
  17. Const STAGE_GENERATE:Int = 0
  18. Const STAGE_FASM2AS:Int = 1
  19. Const STAGE_OBJECT:Int = 2
  20. Const STAGE_LINK:Int = 3
  21. Const STAGE_MERGE:Int = 4
  22. Const STAGE_APP_LINK:Int = 5
  23. Type TSourceFile
  24. Field ext$ 'one of: "bmx", "i", "c", "cpp", "m", "s", "h"
  25. Field exti:Int
  26. Field path$
  27. Field modid$
  28. Field framewk$
  29. Field info:TList=New TList
  30. Field modimports:TList=New TList
  31. Field imports:TList=New TList
  32. Field includes:TList=New TList
  33. Field incbins:TList=New TList
  34. Field hashes:TMap=New TMap
  35. Field pragmas:TList = New TList
  36. Field stage:Int
  37. Field deps:TMap = New TMap
  38. Field moddeps:TMap
  39. Field processed:Int
  40. Field arc_path:String
  41. Field iface_path:String
  42. Field iface_path2:String
  43. Field obj_path:String
  44. Field time:Int
  45. Field obj_time:Int
  46. Field arc_time:Int
  47. Field asm_time:Int
  48. Field iface_time:Int
  49. Field gen_time:Int
  50. Field requiresBuild:Int
  51. Field dontBuild:Int
  52. Field depsList:TList
  53. Field ext_files:TList
  54. Field merge_path:String
  55. Field merge_time:Int
  56. Field cc_opts:String
  57. Field bcc_opts:String
  58. Field cpp_opts:String
  59. Field c_opts:String
  60. Field mod_opts:TModOpt
  61. Field includePaths:TOrderedMap = New TOrderedMap
  62. Field includePathString:String
  63. Field pct:Int
  64. Field linksCache:TList
  65. Field optsCache:TList
  66. Field lastCache:Int = -1
  67. Field doneLinks:Int
  68. 'cache calculated MaxLinkTime()-value for faster lookups
  69. Field maxLinkTimeCache:Int = -1
  70. Field maxIfaceTimeCache:Int = -1
  71. Field isInclude:Int
  72. Field owner_path:String
  73. ' add cc_opts or ld_opts
  74. Method AddModOpt(opt:String)
  75. If Not mod_opts Then
  76. mod_opts = New TModOpt
  77. End If
  78. mod_opts.AddOption(opt, path)
  79. End Method
  80. Method MaxObjTime:Int()
  81. Local t:Int = obj_time
  82. If depsList Then
  83. For Local s:TSourceFile = EachIn depsList
  84. Local st:Int = s.MaxObjTime()
  85. If st > t Then
  86. t = st
  87. End If
  88. Next
  89. End If
  90. Return t
  91. End Method
  92. Method GetObjs(list:TList)
  93. If list Then
  94. If Not stage Then
  95. If Not list.Contains(obj_path) Then
  96. list.AddLast(obj_path)
  97. End If
  98. End If
  99. If depsList Then
  100. For Local s:TSourceFile = EachIn depsList
  101. s.GetObjs(list)
  102. Next
  103. End If
  104. End If
  105. End Method
  106. Method SetRequiresBuild(enable:Int)
  107. If requiresBuild <> enable Then
  108. requiresBuild = enable
  109. 'seems our information is outdated now
  110. If requiresBuild Then
  111. maxLinkTimeCache = -1
  112. maxIfaceTimeCache = -1
  113. End If
  114. End If
  115. End Method
  116. Method MaxLinkTime:Int(modsOnly:Int = False)
  117. If maxLinkTimeCache = -1 Then
  118. Local t:Int
  119. If modid Then
  120. t = arc_time
  121. Else
  122. t = obj_time
  123. End If
  124. If depsList Then
  125. For Local s:TSourceFile = EachIn depsList
  126. Local st:Int = s.MaxLinkTime(modsOnly)
  127. If st > t Then
  128. t = st
  129. End If
  130. Next
  131. End If
  132. If moddeps Then
  133. For Local s:TSourceFile = EachIn moddeps.Values()
  134. Local st:Int = s.MaxLinkTime(True)
  135. If st > t Then
  136. t = st
  137. End If
  138. Next
  139. End If
  140. maxLinkTimeCache = t
  141. End If
  142. Return maxLinkTimeCache
  143. End Method
  144. Method MakeFatter(list:TList, o_path:String)
  145. Local ext:String = ExtractExt(o_path)
  146. If ext = "o" Then
  147. Local file:String = StripExt(o_path)
  148. Local fp:String = StripExt(file)
  149. Select ExtractExt(file)
  150. Case "arm64"
  151. fp :+ ".armv7.o"
  152. Case "armv7"
  153. fp :+ ".arm64.o"
  154. Case "x86"
  155. fp :+ ".x64.o"
  156. Case "x64"
  157. fp :+ ".x86.o"
  158. End Select
  159. If Not list.Contains(fp) Then
  160. list.AddLast(fp)
  161. linksCache.AddLast(fp)
  162. End If
  163. End If
  164. End Method
  165. Method GetLinks(list:TList, opts:TList, modsOnly:Int = False, cList:TList = Null, cOpts:TList = Null)
  166. If linksCache Then
  167. If lastCache <> modsOnly Then
  168. linksCache = Null
  169. optsCache = Null
  170. doneLinks = False
  171. End If
  172. End If
  173. If doneLinks Then
  174. Return
  175. End If
  176. doneLinks = True
  177. If Not linksCache Then
  178. linksCache = New TList
  179. optsCache = New TList
  180. lastCache = modsOnly
  181. If list And (stage = STAGE_LINK Or stage = STAGE_APP_LINK) Then
  182. If Not modid Then
  183. If Not list.Contains(obj_path) Then
  184. list.AddLast(obj_path)
  185. linksCache.AddLast(obj_path)
  186. If opt_universal And processor.Platform() = "ios" Then
  187. MakeFatter(list, obj_path)
  188. End If
  189. End If
  190. End If
  191. End If
  192. If depsList And list Then
  193. For Local s:TSourceFile = EachIn depsList
  194. If Not modsOnly Or (modsOnly And s.modid) Then
  195. If Not stage Then
  196. If Not s.modid Then
  197. If s.obj_path And Not list.Contains(s.obj_path) Then
  198. list.AddLast(s.obj_path)
  199. linksCache.AddLast(s.obj_path)
  200. If opt_universal And processor.Platform() = "ios" Then
  201. MakeFatter(list, s.obj_path)
  202. End If
  203. End If
  204. End If
  205. End If
  206. End If
  207. If s.exti = SOURCE_BMX Or s.exti = SOURCE_IFACE Or s.modid Or s.exti = SOURCE_RES Then
  208. s.GetLinks(list, opts, modsOnly, linksCache, optsCache)
  209. End If
  210. Next
  211. End If
  212. If moddeps Then
  213. For Local s:TSourceFile = EachIn moddeps.Values()
  214. s.GetLinks(list, opts, True, linksCache, optsCache)
  215. Next
  216. End If
  217. If mod_opts Then
  218. For Local f:String = EachIn mod_opts.ld_opts
  219. Local p:String = TModOpt.SetPath(f, ExtractDir(path))
  220. If Not list.Contains(p) Then
  221. list.AddLast(p)
  222. linksCache.AddLast(p)
  223. End If
  224. Next
  225. End If
  226. If ext_files Then
  227. For Local f:String = EachIn ext_files
  228. ' remove previous link, add latest to the end...
  229. If opts.Contains(f) Then
  230. opts.Remove(f)
  231. optsCache.Remove(f)
  232. End If
  233. opts.AddLast(f)
  234. optsCache.AddLast(f)
  235. Next
  236. End If
  237. If cList Then
  238. For Local s:String = EachIn linksCache
  239. cList.AddLast(s)
  240. Next
  241. For Local f:String = EachIn optsCache
  242. If cOpts.Contains(f) Then
  243. cOpts.Remove(f)
  244. End If
  245. cOpts.AddLast(f)
  246. Next
  247. End If
  248. Else
  249. For Local s:String = EachIn linksCache
  250. list.AddLast(s)
  251. Next
  252. For Local f:String = EachIn optsCache
  253. If opts.Contains(f) Then
  254. opts.Remove(f)
  255. End If
  256. opts.AddLast(f)
  257. Next
  258. If cList Then
  259. For Local s:String = EachIn linksCache
  260. cList.AddLast(s)
  261. Next
  262. For Local f:String = EachIn optsCache
  263. If cOpts.Contains(f) Then
  264. cOpts.Remove(f)
  265. End If
  266. cOpts.AddLast(f)
  267. Next
  268. End If
  269. End If
  270. End Method
  271. Method MaxIfaceTime:Int()
  272. If maxIfaceTimeCache = -1 Then
  273. Local t:Int = iface_time
  274. If depsList Then
  275. For Local s:TSourceFile = EachIn depsList
  276. Local st:Int = s.MaxIFaceTime()
  277. If st > t Then
  278. t = st
  279. End If
  280. Next
  281. End If
  282. If moddeps Then
  283. For Local s:TSourceFile = EachIn moddeps.Values()
  284. Local st:Int = s.MaxIFaceTime()
  285. If st > t Then
  286. t = st
  287. End If
  288. Next
  289. End If
  290. maxIfaceTimeCache = t
  291. End If
  292. Return maxIfaceTimeCache
  293. End Method
  294. Method CopyInfo(source:TSourceFile)
  295. source.ext = ext
  296. source.exti = exti
  297. source.path = path
  298. source.modid = modid
  299. source.framewk = framewk
  300. source.info = info
  301. source.processed = processed
  302. source.arc_path = arc_path
  303. source.iface_path = iface_path
  304. source.iface_path2 = iface_path2
  305. source.obj_path = obj_path
  306. source.time = time
  307. source.obj_time = obj_time
  308. source.arc_time = arc_time
  309. source.iface_time = iface_time
  310. source.gen_time = gen_time
  311. source.requiresBuild = requiresBuild
  312. source.dontBuild = dontBuild
  313. source.cc_opts = cc_opts
  314. source.bcc_opts = bcc_opts
  315. source.merge_path = merge_path
  316. source.merge_time = merge_time
  317. source.cpp_opts = cpp_opts
  318. source.c_opts = c_opts
  319. source.CopyIncludePaths(includePaths)
  320. source.maxLinkTimeCache = maxLinkTimeCache
  321. source.maxIfaceTimeCache = maxIfaceTimeCache
  322. End Method
  323. Method GetSourcePath:String()
  324. Local p:String
  325. Select stage
  326. Case STAGE_GENERATE
  327. p = path
  328. Case STAGE_FASM2AS
  329. p = StripExt(obj_path) + ".s"
  330. Case STAGE_OBJECT
  331. p = StripExt(obj_path) + ".c"
  332. Case STAGE_LINK, STAGE_APP_LINK
  333. p = obj_path
  334. Case STAGE_MERGE
  335. p = arc_path
  336. End Select
  337. Return p
  338. End Method
  339. Method GetIncludePaths:String()
  340. If Not includePathString Then
  341. For Local path:String = EachIn includePaths.OrderedKeys()
  342. includePathString :+ path
  343. Next
  344. End If
  345. Return includePathString
  346. End Method
  347. Method AddIncludePath(path:String)
  348. includePaths.Insert(path, path)
  349. includePathString = ""
  350. End Method
  351. Method CopyIncludePaths(paths:TOrderedMap)
  352. For Local path:String = EachIn paths.OrderedKeys()
  353. includePaths.Insert(path, path)
  354. Next
  355. includePathString = ""
  356. End Method
  357. End Type
  358. Function ValidSourceExt( ext:Int )
  359. If ext & $FFFF Then
  360. Return True
  361. End If
  362. Return False
  363. End Function
  364. Function ParseSourceFile:TSourceFile( path$ )
  365. If FileType(path)<>FILETYPE_FILE Return
  366. Local ext$=ExtractExt( path ).ToLower()
  367. Local exti:Int = String(processor.RunCommand("source_type", [ext])).ToInt()
  368. ' don't want headers?
  369. If exti = SOURCE_HEADER Return
  370. If Not ValidSourceExt( exti ) Return
  371. Local file:TSourceFile=New TSourceFile
  372. file.ext=ext
  373. file.exti=exti
  374. file.path=path
  375. file.time = FileTime(path)
  376. Local str$=LoadText( path )
  377. Local pos,in_rem,cc=True
  378. SetCompilerValues()
  379. Local lineCount:Int
  380. While pos<Len(str)
  381. Local eol=str.Find( "~n",pos )
  382. If eol=-1 eol=Len(str)
  383. lineCount :+ 1
  384. Local line$=str[pos..eol].Trim()
  385. pos=eol+1
  386. Local pragmaLine:String
  387. Local n:Int = line.Find("@")
  388. If n <> -1 And line[n+1..n+4] = "bmk" Then
  389. pragmaLine = line[n+4..]
  390. End If
  391. Select exti
  392. Case SOURCE_BMX, SOURCE_IFACE
  393. n=line.Find( "'" )
  394. If n<>-1 line=line[..n]
  395. If Not line And Not pragmaLine Continue
  396. Local lline$=line.Tolower()
  397. If in_rem
  398. If lline[..6]="endrem" Or lline[..7]="end rem"
  399. in_rem=False
  400. EndIf
  401. Continue
  402. Else If lline[..3]="rem"
  403. in_rem=True
  404. Continue
  405. EndIf
  406. Local cmopt:String = lline.Trim()
  407. If cmopt[..1]="?"
  408. Local t$=cmopt[1..]
  409. Try
  410. cc = EvalOption(t)
  411. Catch e:String
  412. WriteStderr "Compile Error: " + e + "~n[" + path + ";" + lineCount + ";1]~n"
  413. Throw e
  414. End Try
  415. EndIf
  416. If Not cc Continue
  417. Local i:Int
  418. ' new pragma stuff
  419. If pragmaLine Then
  420. Local lpragma:String = pragmaLine.ToLower()
  421. i = 0
  422. While i<lpragma.length And Not (CharIsAlpha(lpragma[i]) Or CharIsDigit(lpragma[i]) Or lpragma[i] = Asc("@"))
  423. i:+1
  424. Wend
  425. file.pragmas.AddLast pragmaLine[i..]
  426. End If
  427. If lline.length And Not CharIsAlpha( lline[0] ) Continue
  428. i=1
  429. While i<lline.length And (CharIsAlpha(lline[i]) Or CharIsDigit(lline[i]))
  430. i:+1
  431. Wend
  432. If i=lline.length Continue
  433. Local key$=lline[..i]
  434. Local val$=line[i..].Trim(),qval$,qext$
  435. If val.length>1 And val[0]=34 And val[val.length-1]=34
  436. qval=val[1..val.length-1]
  437. EndIf
  438. Select key
  439. Case "module"
  440. file.modid=val.ToLower()
  441. Case "framework"
  442. file.framewk=val.ToLower()
  443. Case "import"
  444. If qval
  445. file.imports.AddLast ReQuote(qval)
  446. Else
  447. file.modimports.AddLast val.ToLower()
  448. EndIf
  449. Case "incbin"
  450. If qval
  451. file.incbins.AddLast qval
  452. EndIf
  453. Case "include"
  454. If qval
  455. file.includes.AddLast qval
  456. EndIf
  457. Case "moduleinfo"
  458. If qval
  459. file.info.AddLast qval
  460. file.AddModOpt(qval) ' bmk2
  461. 'If mod_opts mod_opts.addOption(qval) ' BaH
  462. EndIf
  463. End Select
  464. Case SOURCE_C, SOURCE_HEADER '"c","m","h","cpp","cxx","hpp","hxx"
  465. ' If line[..8]="#include"
  466. '' Local val$=line[8..].Trim(),qval$,qext$
  467. ' If val.length>1 And val[0]=34 And val[val.length-1]=34
  468. ' qval=val[1..val.length-1]
  469. ' EndIf
  470. ' If qval
  471. ' file.includes.AddLast qval
  472. ' EndIf
  473. 'EndIf
  474. End Select
  475. Wend
  476. Return file
  477. End Function
  478. Function ParseISourceFile:TSourceFile( path$ )
  479. If FileType(path)<>FILETYPE_FILE Return
  480. Local file:TSourceFile=New TSourceFile
  481. file.ext="i"
  482. file.exti=SOURCE_IFACE
  483. file.path=path
  484. file.time = FileTime(path)
  485. Local str$=LoadText( path )
  486. Local pos,in_rem,cc=True
  487. While pos<Len(str)
  488. Local eol=str.Find( "~n",pos )
  489. If eol=-1 eol=Len(str)
  490. Local line$=str[pos..eol].Trim()
  491. pos=eol+1
  492. Local lline$=line.Tolower()
  493. Local i:Int
  494. If lline.length And Not CharIsAlpha( lline[0] ) Continue
  495. i=1
  496. While i<lline.length And (CharIsAlpha(lline[i]) Or CharIsDigit(lline[i]))
  497. i:+1
  498. Wend
  499. If i=lline.length Continue
  500. Local key$=lline[..i]
  501. Local val$=line[i..].Trim(),qval$,qext$
  502. If val.length>1 And val[0]=34 And val[val.length-1]=34
  503. qval=val[1..val.length-1]
  504. EndIf
  505. Select key
  506. Case "module"
  507. file.modid=val.ToLower()
  508. Case "import"
  509. If qval
  510. Local q:String = ReQuote(qval)
  511. If q.StartsWith("-") Then
  512. file.imports.AddLast q
  513. End If
  514. Else
  515. file.modimports.AddLast val.ToLower()
  516. EndIf
  517. Case "moduleinfo"
  518. If qval
  519. file.info.AddLast qval
  520. file.AddModOpt(qval) ' bmk2
  521. 'If mod_opts mod_opts.addOption(qval) ' BaH
  522. EndIf
  523. End Select
  524. Wend
  525. Return file
  526. End Function
  527. Function ValidatePlatformArchitecture()
  528. Local valid:Int = False
  529. Local platform:String = processor.Platform()
  530. Local arch:String = processor.CPU()
  531. Select platform
  532. Case "win32"
  533. If arch = "x86" Or arch = "x64" or arch = "armv7" or arch = "arm64" Then
  534. valid = True
  535. End If
  536. Case "linux"
  537. If arch = "x86" Or arch = "x64" Or arch = "arm" Or arch="arm64" Or arch = "riscv32" Or arch = "riscv64" Then
  538. valid = True
  539. End If
  540. Case "macos", "osx"
  541. If arch = "x86" Or arch = "x64" Or arch = "ppc" Or arch = "arm64" Then
  542. valid = True
  543. End If
  544. Case "ios"
  545. If arch = "x86" Or arch = "x64" Or arch = "armv7" Or arch = "arm64" Then
  546. valid = True
  547. End If
  548. Case "android"
  549. If arch = "x86" Or arch = "x64" Or arch = "arm" Or arch = "armeabi" Or arch = "armeabiv7a" Or arch = "arm64v8a" Then
  550. valid = True
  551. End If
  552. Case "raspberrypi"
  553. If arch = "arm" Or arch="arm64" Then
  554. valid = True
  555. End If
  556. Case "emscripten"
  557. If arch = "js" Then
  558. valid = True
  559. End If
  560. Case "nx"
  561. If arch = "arm64" Then
  562. valid = True
  563. End If
  564. Case "haiku"
  565. If arch = "x86" Or arch = "x64" Then
  566. valid = True
  567. End If
  568. End Select
  569. If Not valid Then
  570. CmdError "Invalid Platform/Architecture configuration : " + platform + "/" + arch
  571. End If
  572. End Function
  573. Function SetCompilerValues()
  574. compilerOptions = New TValues
  575. compilerOptions.Add("debug", opt_debug)
  576. compilerOptions.Add("threaded", opt_threaded)
  577. compilerOptions.Add("x86", processor.CPU()="x86")
  578. compilerOptions.Add("ppc", processor.CPU()="ppc")
  579. compilerOptions.Add("x64", processor.CPU()="x64")
  580. compilerOptions.Add("arm", processor.CPU()="arm")
  581. compilerOptions.Add("armeabi", processor.CPU()="armeabi")
  582. compilerOptions.Add("armeabiv7a", processor.CPU()="armeabiv7a")
  583. compilerOptions.Add("arm64v8a", processor.CPU()="arm64v8a")
  584. compilerOptions.Add("armv7", processor.CPU()="armv7")
  585. compilerOptions.Add("arm64", processor.CPU()="arm64")
  586. compilerOptions.Add("riscv32", processor.CPU()="riscv32")
  587. compilerOptions.Add("riscv64", processor.CPU()="riscv64")
  588. compilerOptions.Add("js", processor.CPU()="js")
  589. compilerOptions.Add("ptr32", processor.CPU()="x86" Or processor.CPU()="ppc" Or processor.CPU()="arm" Or processor.CPU()="armeabi" Or processor.CPU()="armeabiv7a" Or processor.CPU()="armv7" Or processor.CPU()="js" Or processor.CPU()="riscv32")
  590. compilerOptions.Add("ptr64", processor.CPU()="x64" Or processor.CPU()="arm64v8a" Or processor.CPU()="arm64" Or processor.CPU()="riscv64")
  591. compilerOptions.Add("win32", processor.Platform() = "win32")
  592. compilerOptions.Add("win32x86", processor.Platform() = "win32" And processor.CPU()="x86")
  593. compilerOptions.Add("win32ppc", processor.Platform() = "win32" And processor.CPU()="ppc")
  594. compilerOptions.Add("win32x64", processor.Platform() = "win32" And processor.CPU()="x64")
  595. compilerOptions.Add("win32armv7", processor.Platform() = "win32" And processor.CPU()="armv7")
  596. compilerOptions.Add("win32arm64", processor.Platform() = "win32" And processor.CPU()="arm64")
  597. compilerOptions.Add("linux", processor.Platform() = "linux" Or processor.Platform() = "android" Or processor.Platform() = "raspberrypi")
  598. compilerOptions.Add("linuxx86", (processor.Platform() = "linux" Or processor.Platform() = "android") And processor.CPU()="x86")
  599. compilerOptions.Add("linuxppc", processor.Platform() = "linux" And processor.CPU()="ppc")
  600. compilerOptions.Add("linuxx64", (processor.Platform() = "linux" Or processor.Platform() = "android") And processor.CPU()="x64")
  601. compilerOptions.Add("linuxarm", (processor.Platform() = "linux" Or processor.Platform() = "android" Or processor.Platform() = "raspberrypi") And processor.CPU()="arm")
  602. compilerOptions.Add("linuxarm64", ((processor.Platform() = "linux" Or processor.Platform() = "raspberrypi") And processor.CPU()="arm64") Or (processor.Platform() = "android" And processor.CPU()="arm64v8a"))
  603. compilerOptions.Add("linuxriscv32", (processor.Platform() = "linux" And processor.CPU()="riscv32"))
  604. compilerOptions.Add("linuxriscv64", ((processor.Platform() = "linux" And processor.CPU()="riscv64")))
  605. compilerOptions.Add("macos", processor.Platform() = "macos" Or processor.Platform() = "osx" Or processor.Platform() = "ios")
  606. compilerOptions.Add("macosx86", (processor.Platform() = "macos"Or processor.Platform() = "osx" Or processor.Platform() = "ios") And processor.CPU()="x86")
  607. compilerOptions.Add("macosppc", (processor.Platform() = "macos" Or processor.Platform() = "osx") And processor.CPU()="ppc")
  608. compilerOptions.Add("macosx64", (processor.Platform() = "macos" Or processor.Platform() = "osx" Or processor.Platform() = "ios") And processor.CPU()="x64")
  609. compilerOptions.Add("macosarm64", (processor.Platform() = "macos" Or processor.Platform() = "osx" Or processor.Platform() = "ios") And processor.CPU()="arm64")
  610. compilerOptions.Add("osx", processor.Platform() = "macos" Or processor.Platform() = "osx")
  611. compilerOptions.Add("osxx86", (processor.Platform() = "macos"Or processor.Platform() = "osx") And processor.CPU()="x86")
  612. compilerOptions.Add("osxx64", (processor.Platform() = "macos" Or processor.Platform() = "osx") And processor.CPU()="x64")
  613. compilerOptions.Add("osxarm64", (processor.Platform() = "macos" Or processor.Platform() = "osx") And processor.CPU()="arm64")
  614. compilerOptions.Add("ios", processor.Platform() = "ios")
  615. compilerOptions.Add("iosx86", processor.Platform() = "ios" And processor.CPU()="x86")
  616. compilerOptions.Add("iosx64", processor.Platform() = "ios" And processor.CPU()="x64")
  617. compilerOptions.Add("iosarmv7", processor.Platform() = "ios" And processor.CPU()="armv7")
  618. compilerOptions.Add("iosarm64", processor.Platform() = "ios" And processor.CPU()="arm64")
  619. compilerOptions.Add("android", processor.Platform() = "android")
  620. compilerOptions.Add("androidarm", processor.Platform() = "android" And processor.CPU()="arm")
  621. compilerOptions.Add("androidarmeabi", processor.Platform() = "android" And processor.CPU()="armeabi")
  622. compilerOptions.Add("androidarmeabiv7a", processor.Platform() = "android" And processor.CPU()="armeabiv7a")
  623. compilerOptions.Add("androidarm64v8a", processor.Platform() = "android" And processor.CPU()="arm64v8a")
  624. compilerOptions.Add("raspberrypi", processor.Platform() = "raspberrypi")
  625. compilerOptions.Add("raspberrypiarm", processor.Platform() = "raspberrypi" And processor.CPU()="arm")
  626. compilerOptions.Add("raspberrypiarm64", processor.Platform() = "raspberrypi" And processor.CPU()="arm64")
  627. compilerOptions.Add("haiku", processor.Platform() = "haiku")
  628. compilerOptions.Add("haikux86", processor.Platform() = "haiku" And processor.CPU()="x86")
  629. compilerOptions.Add("haikux64", processor.Platform() = "haiku" And processor.CPU()="x64")
  630. compilerOptions.Add("emscripten", processor.Platform() = "emscripten")
  631. compilerOptions.Add("emscriptenjs", processor.Platform() = "emscripten" And processor.CPU()="js")
  632. compilerOptions.Add("opengles", processor.Platform() = "android" Or processor.Platform() ="raspberrypi" Or processor.Platform() = "emscripten" Or processor.Platform() = "ios")
  633. compilerOptions.Add("bmxng", processor.BCCVersion() <> "BlitzMax")
  634. compilerOptions.Add("coverage", opt_coverage)
  635. compilerOptions.Add("musl", processor.Platform() = "linux" Or processor.Platform() ="raspberrypi")
  636. compilerOptions.Add("nx", processor.Platform() = "nx")
  637. compilerOptions.Add("nxarm64", processor.Platform() = "nx" And processor.CPU()="arm64")
  638. Local userdefs:TUserDef[] = GetUserDefs()
  639. If userdefs Then
  640. For Local def:TUserDef = EachIn userdefs
  641. compilerOptions.Add(def.name, def.value)
  642. Next
  643. End If
  644. End Function
  645. Function GetUserDefs:TUserDef[]()
  646. Local defs:String = opt_userdefs
  647. If globals.Get("user_defs") Then
  648. If defs Then
  649. defs :+ ","
  650. End If
  651. defs :+ globals.Get("user_defs")
  652. End If
  653. Local parts:String[] = defs.ToLower().Split(",")
  654. Local userdefs:TUserDef[parts.length]
  655. Local count:Int
  656. For Local def:String = EachIn parts
  657. def = def.Trim()
  658. If Not def Then
  659. Continue
  660. End If
  661. Local name:String = def
  662. Local value:Int = 1
  663. Local dp:String[] = def.Split("=")
  664. If dp.length = 2 Then
  665. name = dp[0]
  666. value = Int(dp[1])
  667. End If
  668. Local ud:TUserDef = New TUserDef
  669. ud.name = name
  670. ud.value = value
  671. userdefs[count] = ud
  672. count :+ 1
  673. Next
  674. If count < parts.length Then
  675. userdefs = userdefs[..count]
  676. End If
  677. Return userdefs
  678. End Function
  679. Type TUserDef
  680. Field name:String
  681. Field value:Int = 1
  682. End Type