bmk_modutil.bmx 22 KB

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