toolchain.lua 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265
  1. --
  2. -- Copyright 2010-2022 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bx/blob/master/LICENSE
  4. --
  5. local bxDir = path.getabsolute("..")
  6. local function crtNone()
  7. defines {
  8. "BX_CRT_NONE=1",
  9. }
  10. buildoptions {
  11. "-nostdlib",
  12. "-nodefaultlibs",
  13. "-nostartfiles",
  14. "-Wa,--noexecstack",
  15. "-ffreestanding",
  16. }
  17. linkoptions {
  18. "-nostdlib",
  19. "-nodefaultlibs",
  20. "-nostartfiles",
  21. "-Wa,--noexecstack",
  22. "-ffreestanding",
  23. }
  24. configuration { "linux-*" }
  25. buildoptions {
  26. "-mpreferred-stack-boundary=4",
  27. "-mstackrealign",
  28. }
  29. linkoptions {
  30. "-mpreferred-stack-boundary=4",
  31. "-mstackrealign",
  32. }
  33. configuration {}
  34. end
  35. function toolchain(_buildDir, _libDir)
  36. newoption {
  37. trigger = "gcc",
  38. value = "GCC",
  39. description = "Choose GCC flavor",
  40. allowed = {
  41. { "android-arm", "Android - ARM" },
  42. { "android-arm64", "Android - ARM64" },
  43. { "android-x86", "Android - x86" },
  44. { "wasm2js", "Emscripten/Wasm2JS" },
  45. { "wasm", "Emscripten/Wasm" },
  46. { "freebsd", "FreeBSD" },
  47. { "linux-gcc", "Linux (GCC compiler)" },
  48. { "linux-gcc-afl", "Linux (GCC + AFL fuzzer)" },
  49. { "linux-gcc-6", "Linux (GCC-6 compiler)" },
  50. { "linux-clang", "Linux (Clang compiler)" },
  51. { "linux-clang-afl", "Linux (Clang + AFL fuzzer)" },
  52. { "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
  53. { "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
  54. { "ios-arm", "iOS - ARM" },
  55. { "ios-arm64", "iOS - ARM64" },
  56. { "ios-simulator", "iOS - Simulator" },
  57. { "ios-simulator64", "iOS - Simulator 64" },
  58. { "tvos-arm64", "tvOS - ARM64" },
  59. { "tvos-simulator", "tvOS - Simulator" },
  60. { "mingw-gcc", "MinGW" },
  61. { "mingw-clang", "MinGW (clang compiler)" },
  62. { "netbsd", "NetBSD" },
  63. { "osx-x64", "OSX - x64" },
  64. { "osx-arm64", "OSX - ARM64" },
  65. { "orbis", "Orbis" },
  66. { "riscv", "RISC-V" },
  67. { "rpi", "RaspberryPi" },
  68. },
  69. }
  70. newoption {
  71. trigger = "vs",
  72. value = "toolset",
  73. description = "Choose VS toolset",
  74. allowed = {
  75. { "vs2012-clang", "Clang 3.6" },
  76. { "vs2013-clang", "Clang 3.6" },
  77. { "vs2015-clang", "Clang 3.9" },
  78. { "vs2017-clang", "Clang with MS CodeGen" },
  79. { "vs2012-xp", "Visual Studio 2012 targeting XP" },
  80. { "vs2013-xp", "Visual Studio 2013 targeting XP" },
  81. { "vs2015-xp", "Visual Studio 2015 targeting XP" },
  82. { "vs2017-xp", "Visual Studio 2017 targeting XP" },
  83. { "winstore100", "Universal Windows App 10.0" },
  84. { "durango", "Durango" },
  85. { "orbis", "Orbis" },
  86. },
  87. }
  88. newoption {
  89. trigger = "xcode",
  90. value = "xcode_target",
  91. description = "Choose XCode target",
  92. allowed = {
  93. { "osx", "OSX" },
  94. { "ios", "iOS" },
  95. { "tvos", "tvOS" },
  96. }
  97. }
  98. newoption {
  99. trigger = "with-android",
  100. value = "#",
  101. description = "Set Android platform version (default: android-14).",
  102. }
  103. newoption {
  104. trigger = "with-ios",
  105. value = "#",
  106. description = "Set iOS target version (default: 8.0).",
  107. }
  108. newoption {
  109. trigger = "with-macos",
  110. value = "#",
  111. description = "Set macOS target version (default 10.11).",
  112. }
  113. newoption {
  114. trigger = "with-tvos",
  115. value = "#",
  116. description = "Set tvOS target version (default: 9.0).",
  117. }
  118. newoption {
  119. trigger = "with-windows",
  120. value = "#",
  121. description = "Set the Windows target platform version (default: $WindowsSDKVersion or 8.1).",
  122. }
  123. newoption {
  124. trigger = "with-dynamic-runtime",
  125. description = "Dynamically link with the runtime rather than statically",
  126. }
  127. newoption {
  128. trigger = "with-32bit-compiler",
  129. description = "Use 32-bit compiler instead 64-bit.",
  130. }
  131. newoption {
  132. trigger = "with-avx",
  133. description = "Use AVX extension.",
  134. }
  135. -- Avoid error when invoking genie --help.
  136. if (_ACTION == nil) then return false end
  137. location (path.join(_buildDir, "projects", _ACTION))
  138. if _ACTION == "clean" then
  139. os.rmdir(_buildDir)
  140. os.mkdir(_buildDir)
  141. os.exit(1)
  142. end
  143. local androidPlatform = "android-24"
  144. if _OPTIONS["with-android"] then
  145. androidPlatform = "android-" .. _OPTIONS["with-android"]
  146. end
  147. local iosPlatform = ""
  148. if _OPTIONS["with-ios"] then
  149. iosPlatform = _OPTIONS["with-ios"]
  150. end
  151. local macosPlatform = ""
  152. if _OPTIONS["with-macos"] then
  153. macosPlatform = _OPTIONS["with-macos"]
  154. end
  155. local tvosPlatform = ""
  156. if _OPTIONS["with-tvos"] then
  157. tvosPlatform = _OPTIONS["with-tvos"]
  158. end
  159. local windowsPlatform = string.gsub(os.getenv("WindowsSDKVersion") or "8.1", "\\", "")
  160. if _OPTIONS["with-windows"] then
  161. windowsPlatform = _OPTIONS["with-windows"]
  162. end
  163. local compiler32bit = false
  164. if _OPTIONS["with-32bit-compiler"] then
  165. compiler32bit = true
  166. end
  167. flags {
  168. "Cpp14",
  169. "ExtraWarnings",
  170. "FloatFast",
  171. }
  172. if _ACTION == "gmake" or _ACTION == "ninja" then
  173. if nil == _OPTIONS["gcc"] then
  174. print("GCC flavor must be specified!")
  175. os.exit(1)
  176. end
  177. if "android-arm" == _OPTIONS["gcc"] then
  178. if not os.getenv("ANDROID_NDK_ARM")
  179. or not os.getenv("ANDROID_NDK_CLANG")
  180. or not os.getenv("ANDROID_NDK_ROOT") then
  181. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT environment variables.")
  182. end
  183. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  184. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  185. premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
  186. premake.gcc.llvm = true
  187. location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
  188. elseif "android-arm64" == _OPTIONS["gcc"] then
  189. if not os.getenv("ANDROID_NDK_ARM64")
  190. or not os.getenv("ANDROID_NDK_CLANG")
  191. or not os.getenv("ANDROID_NDK_ROOT") then
  192. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM64, and ANDROID_NDK_ROOT environment variables.")
  193. end
  194. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  195. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  196. premake.gcc.ar = "$(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-ar"
  197. premake.gcc.llvm = true
  198. location (path.join(_buildDir, "projects", _ACTION .. "-android-arm64"))
  199. elseif "android-x86" == _OPTIONS["gcc"] then
  200. if not os.getenv("ANDROID_NDK_X86")
  201. or not os.getenv("ANDROID_NDK_CLANG")
  202. or not os.getenv("ANDROID_NDK_ROOT") then
  203. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_X86, and ANDROID_NDK_ROOT environment variables.")
  204. end
  205. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  206. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  207. premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
  208. premake.gcc.llvm = true
  209. location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
  210. elseif "wasm2js" == _OPTIONS["gcc"] or "wasm" == _OPTIONS["gcc"] then
  211. if not os.getenv("EMSCRIPTEN") then
  212. print("Set EMSCRIPTEN environment variable to root directory of your Emscripten installation. (e.g. by entering the EMSDK command prompt)")
  213. end
  214. premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\""
  215. premake.gcc.cxx = "\"$(EMSCRIPTEN)/em++\""
  216. premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\""
  217. premake.gcc.llvm = true
  218. premake.gcc.namestyle = "Emscripten"
  219. location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
  220. elseif "freebsd" == _OPTIONS["gcc"] then
  221. location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
  222. elseif "ios-arm" == _OPTIONS["gcc"]
  223. or "ios-arm64" == _OPTIONS["gcc"] then
  224. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  225. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  226. premake.gcc.ar = "ar"
  227. location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
  228. elseif "ios-simulator" == _OPTIONS["gcc"] then
  229. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  230. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  231. premake.gcc.ar = "ar"
  232. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
  233. elseif "ios-simulator64" == _OPTIONS["gcc"] then
  234. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  235. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  236. premake.gcc.ar = "ar"
  237. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator64"))
  238. elseif "tvos-arm64" == _OPTIONS["gcc"] then
  239. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  240. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  241. premake.gcc.ar = "ar"
  242. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-arm64"))
  243. elseif "tvos-simulator" == _OPTIONS["gcc"] then
  244. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  245. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  246. premake.gcc.ar = "ar"
  247. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-simulator"))
  248. elseif "linux-gcc" == _OPTIONS["gcc"] then
  249. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  250. elseif "linux-gcc-afl" == _OPTIONS["gcc"] then
  251. premake.gcc.cc = "afl-gcc"
  252. premake.gcc.cxx = "afl-g++"
  253. premake.gcc.ar = "ar"
  254. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  255. elseif "linux-gcc-6" == _OPTIONS["gcc"] then
  256. premake.gcc.cc = "gcc-6"
  257. premake.gcc.cxx = "g++-6"
  258. premake.gcc.ar = "ar"
  259. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  260. elseif "linux-clang" == _OPTIONS["gcc"] then
  261. premake.gcc.cc = "clang"
  262. premake.gcc.cxx = "clang++"
  263. premake.gcc.ar = "ar"
  264. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  265. elseif "linux-clang-afl" == _OPTIONS["gcc"] then
  266. premake.gcc.cc = "afl-clang"
  267. premake.gcc.cxx = "afl-clang++"
  268. premake.gcc.ar = "ar"
  269. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  270. elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
  271. location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
  272. elseif "linux-arm-gcc" == _OPTIONS["gcc"] then
  273. location (path.join(_buildDir, "projects", _ACTION .. "-linux-arm-gcc"))
  274. elseif "mingw-gcc" == _OPTIONS["gcc"] then
  275. if not os.getenv("MINGW") then
  276. print("Set MINGW environment variable.")
  277. end
  278. local mingwToolchain = "x86_64-w64-mingw32"
  279. if compiler32bit then
  280. if os.is("linux") then
  281. mingwToolchain = "i686-w64-mingw32"
  282. else
  283. mingwToolchain = "mingw32"
  284. end
  285. end
  286. premake.gcc.cc = "$(MINGW)/bin/" .. mingwToolchain .. "-gcc"
  287. premake.gcc.cxx = "$(MINGW)/bin/" .. mingwToolchain .. "-g++"
  288. premake.gcc.ar = "$(MINGW)/bin/ar"
  289. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
  290. elseif "mingw-clang" == _OPTIONS["gcc"] then
  291. premake.gcc.cc = "$(CLANG)/bin/clang"
  292. premake.gcc.cxx = "$(CLANG)/bin/clang++"
  293. premake.gcc.ar = "$(MINGW)/bin/ar"
  294. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  295. -- premake.gcc.llvm = true
  296. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
  297. elseif "netbsd" == _OPTIONS["gcc"] then
  298. location (path.join(_buildDir, "projects", _ACTION .. "-netbsd"))
  299. elseif "osx-x64" == _OPTIONS["gcc"]
  300. or "osx-arm64" == _OPTIONS["gcc"] then
  301. if os.is("linux") then
  302. if not os.getenv("OSXCROSS") then
  303. print("Set OSXCROSS environment variable.")
  304. end
  305. local osxToolchain = "x86_64-apple-darwin15-"
  306. premake.gcc.cc = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "clang"
  307. premake.gcc.cxx = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "clang++"
  308. premake.gcc.ar = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "ar"
  309. end
  310. location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
  311. elseif "orbis" == _OPTIONS["gcc"] then
  312. if not os.getenv("SCE_ORBIS_SDK_DIR") then
  313. print("Set SCE_ORBIS_SDK_DIR environment variable.")
  314. end
  315. orbisToolchain = "$(SCE_ORBIS_SDK_DIR)/host_tools/bin/orbis-"
  316. premake.gcc.cc = orbisToolchain .. "clang"
  317. premake.gcc.cxx = orbisToolchain .. "clang++"
  318. premake.gcc.ar = orbisToolchain .. "ar"
  319. location (path.join(_buildDir, "projects", _ACTION .. "-orbis"))
  320. elseif "rpi" == _OPTIONS["gcc"] then
  321. location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
  322. elseif "riscv" == _OPTIONS["gcc"] then
  323. premake.gcc.cc = "$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/bin/riscv64-unknown-elf-gcc"
  324. premake.gcc.cxx = "$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/bin/riscv64-unknown-elf-g++"
  325. premake.gcc.ar = "$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/bin/riscv64-unknown-elf-ar"
  326. location (path.join(_buildDir, "projects", _ACTION .. "-riscv"))
  327. end
  328. elseif _ACTION == "vs2012"
  329. or _ACTION == "vs2013"
  330. or _ACTION == "vs2015"
  331. or _ACTION == "vs2017"
  332. or _ACTION == "vs2019"
  333. or _ACTION == "vs2022"
  334. then
  335. local action = premake.action.current()
  336. action.vstudio.windowsTargetPlatformVersion = windowsPlatform
  337. action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform
  338. if (_ACTION .. "-clang") == _OPTIONS["vs"] then
  339. if "vs2017-clang" == _OPTIONS["vs"] then
  340. premake.vstudio.toolset = "v141_clang_c2"
  341. elseif "vs2015-clang" == _OPTIONS["vs"] then
  342. premake.vstudio.toolset = "LLVM-vs2014"
  343. else
  344. premake.vstudio.toolset = ("LLVM-" .. _ACTION)
  345. end
  346. location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
  347. elseif "winstore100" == _OPTIONS["vs"] then
  348. premake.vstudio.toolset = "v141"
  349. premake.vstudio.storeapp = "10.0"
  350. platforms { "ARM" }
  351. location (path.join(_buildDir, "projects", _ACTION .. "-winstore100"))
  352. elseif "durango" == _OPTIONS["vs"] then
  353. if not os.getenv("DurangoXDK") then
  354. print("DurangoXDK not found.")
  355. end
  356. premake.vstudio.toolset = "v140"
  357. premake.vstudio.storeapp = "durango"
  358. platforms { "Durango" }
  359. location (path.join(_buildDir, "projects", _ACTION .. "-durango"))
  360. elseif "orbis" == _OPTIONS["vs"] then
  361. if not os.getenv("SCE_ORBIS_SDK_DIR") then
  362. print("Set SCE_ORBIS_SDK_DIR environment variable.")
  363. end
  364. platforms { "Orbis" }
  365. location (path.join(_buildDir, "projects", _ACTION .. "-orbis"))
  366. elseif ("vs2012-xp") == _OPTIONS["vs"] then
  367. premake.vstudio.toolset = ("v110_xp")
  368. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  369. elseif "vs2013-xp" == _OPTIONS["vs"] then
  370. premake.vstudio.toolset = ("v120_xp")
  371. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  372. elseif "vs2015-xp" == _OPTIONS["vs"] then
  373. premake.vstudio.toolset = ("v140_xp")
  374. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  375. elseif "vs2015-xp" == _OPTIONS["vs"] then
  376. premake.vstudio.toolset = ("v141_xp")
  377. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  378. end
  379. elseif _ACTION and _ACTION:match("^xcode.+$") then
  380. local action = premake.action.current()
  381. local str_or = function(str, def)
  382. return #str > 0 and str or def
  383. end
  384. if "osx" == _OPTIONS["xcode"] then
  385. action.xcode.macOSTargetPlatformVersion = str_or(macosPlatform, "10.11")
  386. premake.xcode.toolset = "macosx"
  387. location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
  388. elseif "ios" == _OPTIONS["xcode"] then
  389. action.xcode.iOSTargetPlatformVersion = str_or(iosPlatform, "8.0")
  390. premake.xcode.toolset = "iphoneos"
  391. location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
  392. elseif "tvos" == _OPTIONS["xcode"] then
  393. action.xcode.tvOSTargetPlatformVersion = str_or(tvosPlatform, "9.0")
  394. premake.xcode.toolset = "appletvos"
  395. location (path.join(_buildDir, "projects", _ACTION .. "-tvos"))
  396. end
  397. end
  398. if not _OPTIONS["with-dynamic-runtime"] then
  399. flags { "StaticRuntime" }
  400. end
  401. if _OPTIONS["with-avx"] then
  402. flags { "EnableAVX" }
  403. end
  404. if _OPTIONS["with-crtnone"] then
  405. crtNone()
  406. end
  407. flags {
  408. "NoPCH",
  409. "NativeWChar",
  410. "NoRTTI",
  411. "NoExceptions",
  412. "NoEditAndContinue",
  413. "NoFramePointer",
  414. "Symbols",
  415. }
  416. defines {
  417. "__STDC_LIMIT_MACROS",
  418. "__STDC_FORMAT_MACROS",
  419. "__STDC_CONSTANT_MACROS",
  420. }
  421. configuration { "Debug" }
  422. targetsuffix "Debug"
  423. defines {
  424. "_DEBUG",
  425. }
  426. configuration { "Release" }
  427. flags {
  428. "NoBufferSecurityCheck",
  429. "OptimizeSpeed",
  430. }
  431. defines {
  432. "NDEBUG",
  433. }
  434. targetsuffix "Release"
  435. configuration { "qbs" }
  436. flags {
  437. "ExtraWarnings",
  438. }
  439. configuration { "vs*", "x32" }
  440. flags {
  441. "EnableSSE2",
  442. }
  443. configuration { "vs*", "not orbis", "not NX32", "not NX64" }
  444. includedirs { path.join(bxDir, "include/compat/msvc") }
  445. defines {
  446. "WIN32",
  447. "_WIN32",
  448. "_HAS_EXCEPTIONS=0",
  449. "_SCL_SECURE=0",
  450. "_SECURE_SCL=0",
  451. "_SCL_SECURE_NO_WARNINGS",
  452. "_CRT_SECURE_NO_WARNINGS",
  453. "_CRT_SECURE_NO_DEPRECATE",
  454. }
  455. buildoptions {
  456. "/wd4201", -- warning C4201: nonstandard extension used: nameless struct/union
  457. "/wd4324", -- warning C4324: '': structure was padded due to alignment specifier
  458. "/Ob2", -- The Inline Function Expansion
  459. "/Zc:__cplusplus", -- Enable updated __cplusplus macro
  460. }
  461. linkoptions {
  462. "/ignore:4221", -- LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
  463. }
  464. configuration { "vs2008" }
  465. includedirs { path.join(bxDir, "include/compat/msvc/pre1600") }
  466. configuration { "x32", "vs*" }
  467. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  468. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  469. libdirs {
  470. path.join(_libDir, "lib/win32_" .. _ACTION),
  471. }
  472. configuration { "x64", "vs*" }
  473. defines { "_WIN64" }
  474. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  475. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  476. libdirs {
  477. path.join(_libDir, "lib/win64_" .. _ACTION),
  478. }
  479. configuration { "x32", "vs2017" }
  480. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  481. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  482. libdirs {
  483. path.join(_libDir, "lib/win32_" .. _ACTION),
  484. }
  485. configuration { "x64", "vs2017" }
  486. defines { "_WIN64" }
  487. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  488. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  489. libdirs {
  490. path.join(_libDir, "lib/win64_" .. _ACTION),
  491. }
  492. configuration { "ARM", "vs*" }
  493. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  494. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  495. configuration { "vs*-clang" }
  496. buildoptions {
  497. "-Qunused-arguments",
  498. }
  499. configuration { "x32", "vs*-clang" }
  500. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  501. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  502. configuration { "x64", "vs*-clang" }
  503. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  504. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  505. configuration { "winstore*" }
  506. removeflags {
  507. "StaticRuntime",
  508. "NoBufferSecurityCheck",
  509. }
  510. buildoptions {
  511. "/wd4530", -- vccorlib.h(1345): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
  512. }
  513. linkoptions {
  514. "/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
  515. }
  516. configuration { "*-gcc* or osx" }
  517. buildoptions {
  518. "-Wshadow",
  519. }
  520. configuration { "mingw-*" }
  521. defines { "WIN32" }
  522. includedirs { path.join(bxDir, "include/compat/mingw") }
  523. defines {
  524. "MINGW_HAS_SECURE_API=1",
  525. }
  526. buildoptions {
  527. "-Wunused-value",
  528. "-fdata-sections",
  529. "-ffunction-sections",
  530. "-msse2",
  531. "-Wunused-value",
  532. "-Wundef",
  533. }
  534. linkoptions {
  535. "-Wl,--gc-sections",
  536. "-static",
  537. "-static-libgcc",
  538. "-static-libstdc++",
  539. }
  540. configuration { "x32", "mingw-gcc" }
  541. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  542. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  543. libdirs {
  544. path.join(_libDir, "lib/win32_mingw-gcc"),
  545. }
  546. buildoptions {
  547. "-m32",
  548. "-mstackrealign",
  549. }
  550. configuration { "x64", "mingw-gcc" }
  551. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  552. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  553. libdirs {
  554. path.join(_libDir, "lib/win64_mingw-gcc"),
  555. }
  556. buildoptions { "-m64" }
  557. configuration { "mingw-clang" }
  558. buildoptions {
  559. "-isystem $(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  560. "-isystem $(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  561. "-isystem $(MINGW)/x86_64-w64-mingw32/include",
  562. }
  563. linkoptions {
  564. "-Qunused-arguments",
  565. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  566. }
  567. configuration { "x32", "mingw-clang" }
  568. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  569. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  570. libdirs {
  571. path.join(_libDir, "lib/win32_mingw-clang"),
  572. }
  573. buildoptions { "-m32" }
  574. configuration { "x64", "mingw-clang" }
  575. targetdir (path.join(_buildDir, "win64_mingw-clang/bin"))
  576. objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
  577. libdirs {
  578. path.join(_libDir, "lib/win64_mingw-clang"),
  579. }
  580. buildoptions { "-m64" }
  581. configuration { "linux-*" }
  582. includedirs { path.join(bxDir, "include/compat/linux") }
  583. configuration { "linux-gcc-6" }
  584. buildoptions {
  585. -- "-fno-omit-frame-pointer",
  586. -- "-fsanitize=address",
  587. -- "-fsanitize=undefined",
  588. -- "-fsanitize=float-divide-by-zero",
  589. -- "-fsanitize=float-cast-overflow",
  590. }
  591. links {
  592. -- "asan",
  593. -- "ubsan",
  594. }
  595. configuration { "linux-gcc" }
  596. buildoptions {
  597. "-mfpmath=sse",
  598. }
  599. configuration { "linux-gcc* or linux-clang*" }
  600. buildoptions {
  601. "-msse2",
  602. -- "-Wdouble-promotion",
  603. -- "-Wduplicated-branches",
  604. -- "-Wduplicated-cond",
  605. -- "-Wjump-misses-init",
  606. "-Wshadow",
  607. -- "-Wnull-dereference",
  608. "-Wunused-value",
  609. "-Wundef",
  610. -- "-Wuseless-cast",
  611. }
  612. links {
  613. "rt",
  614. "dl",
  615. }
  616. linkoptions {
  617. "-Wl,--gc-sections",
  618. "-Wl,--as-needed",
  619. }
  620. configuration { "linux-gcc*" }
  621. buildoptions {
  622. "-Wlogical-op",
  623. }
  624. configuration { "linux-gcc*", "x32" }
  625. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  626. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  627. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  628. buildoptions {
  629. "-m32",
  630. }
  631. configuration { "linux-gcc*", "x64" }
  632. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  633. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  634. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  635. buildoptions {
  636. "-m64",
  637. }
  638. configuration { "linux-clang*", "x32" }
  639. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  640. objdir (path.join(_buildDir, "linux32_clang/obj"))
  641. libdirs { path.join(_libDir, "lib/linux32_clang") }
  642. buildoptions {
  643. "-m32",
  644. }
  645. configuration { "linux-clang*", "x64" }
  646. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  647. objdir (path.join(_buildDir, "linux64_clang/obj"))
  648. libdirs { path.join(_libDir, "lib/linux64_clang") }
  649. buildoptions {
  650. "-m64",
  651. }
  652. configuration { "linux-mips-gcc" }
  653. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  654. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  655. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  656. buildoptions {
  657. "-Wunused-value",
  658. "-Wundef",
  659. }
  660. links {
  661. "rt",
  662. "dl",
  663. }
  664. linkoptions {
  665. "-Wl,--gc-sections",
  666. }
  667. configuration { "linux-arm-gcc" }
  668. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  669. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  670. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  671. buildoptions {
  672. "-Wunused-value",
  673. "-Wundef",
  674. }
  675. links {
  676. "rt",
  677. "dl",
  678. }
  679. linkoptions {
  680. "-Wl,--gc-sections",
  681. }
  682. configuration { "android-*" }
  683. targetprefix ("lib")
  684. flags {
  685. "NoImportLib",
  686. }
  687. includedirs {
  688. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  689. "${ANDROID_NDK_ROOT}/sysroot/usr/include",
  690. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  691. }
  692. linkoptions {
  693. "-nostdlib",
  694. }
  695. links {
  696. "c",
  697. "dl",
  698. "m",
  699. "android",
  700. "log",
  701. "c++_shared",
  702. "gcc",
  703. }
  704. buildoptions {
  705. "-fPIC",
  706. "-no-canonical-prefixes",
  707. "-Wa,--noexecstack",
  708. "-fstack-protector-strong",
  709. "-ffunction-sections",
  710. "-Wunused-value",
  711. "-Wundef",
  712. }
  713. linkoptions {
  714. "-no-canonical-prefixes",
  715. "-Wl,--no-undefined",
  716. "-Wl,-z,noexecstack",
  717. "-Wl,-z,relro",
  718. "-Wl,-z,now",
  719. }
  720. configuration { "android-arm" }
  721. targetdir (path.join(_buildDir, "android-arm/bin"))
  722. objdir (path.join(_buildDir, "android-arm/obj"))
  723. libdirs {
  724. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
  725. }
  726. includedirs {
  727. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/arm-linux-androideabi",
  728. }
  729. buildoptions {
  730. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  731. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  732. "-target armv7-none-linux-androideabi",
  733. "-mthumb",
  734. "-march=armv7-a",
  735. "-mfloat-abi=softfp",
  736. "-mfpu=neon",
  737. "-Wunused-value",
  738. "-Wundef",
  739. }
  740. linkoptions {
  741. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  742. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  743. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  744. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  745. "-target armv7-none-linux-androideabi",
  746. "-march=armv7-a",
  747. }
  748. configuration { "android-arm64" }
  749. targetdir (path.join(_buildDir, "android-arm64/bin"))
  750. objdir (path.join(_buildDir, "android-arm64/obj"))
  751. libdirs {
  752. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/arm64-v8a",
  753. }
  754. includedirs {
  755. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/aarch64-linux-android",
  756. }
  757. buildoptions {
  758. "-gcc-toolchain $(ANDROID_NDK_ARM64)",
  759. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
  760. "-target aarch64-none-linux-androideabi",
  761. "-march=armv8-a",
  762. "-Wunused-value",
  763. "-Wundef",
  764. }
  765. linkoptions {
  766. "-gcc-toolchain $(ANDROID_NDK_ARM64)",
  767. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
  768. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtbegin_so.o"),
  769. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtend_so.o"),
  770. "-target aarch64-none-linux-androideabi",
  771. "-march=armv8-a",
  772. }
  773. configuration { "android-x86" }
  774. targetdir (path.join(_buildDir, "android-x86/bin"))
  775. objdir (path.join(_buildDir, "android-x86/obj"))
  776. libdirs {
  777. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
  778. }
  779. includedirs {
  780. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/x86_64-linux-android",
  781. }
  782. buildoptions {
  783. "-gcc-toolchain $(ANDROID_NDK_X86)",
  784. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  785. "-target i686-none-linux-android",
  786. "-march=i686",
  787. "-mtune=atom",
  788. "-mstackrealign",
  789. "-msse3",
  790. "-mfpmath=sse",
  791. "-Wunused-value",
  792. "-Wundef",
  793. }
  794. linkoptions {
  795. "-gcc-toolchain $(ANDROID_NDK_X86)",
  796. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  797. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  798. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"),
  799. "-target i686-none-linux-android",
  800. }
  801. configuration { "wasm*" }
  802. buildoptions {
  803. "-Wunused-value",
  804. "-Wundef",
  805. }
  806. linkoptions {
  807. "-s MAX_WEBGL_VERSION=2",
  808. }
  809. configuration { "wasm2js" }
  810. targetdir (path.join(_buildDir, "wasm2js/bin"))
  811. objdir (path.join(_buildDir, "wasm2js/obj"))
  812. libdirs { path.join(_libDir, "lib/wasm2js") }
  813. linkoptions {
  814. "-s WASM=0",
  815. }
  816. configuration { "wasm" }
  817. targetdir (path.join(_buildDir, "wasm/bin"))
  818. objdir (path.join(_buildDir, "wasm/obj"))
  819. libdirs { path.join(_libDir, "lib/wasm") }
  820. configuration { "freebsd" }
  821. targetdir (path.join(_buildDir, "freebsd/bin"))
  822. objdir (path.join(_buildDir, "freebsd/obj"))
  823. libdirs { path.join(_libDir, "lib/freebsd") }
  824. includedirs {
  825. path.join(bxDir, "include/compat/freebsd"),
  826. }
  827. configuration { "xbox360" }
  828. targetdir (path.join(_buildDir, "xbox360/bin"))
  829. objdir (path.join(_buildDir, "xbox360/obj"))
  830. includedirs { path.join(bxDir, "include/compat/msvc") }
  831. libdirs { path.join(_libDir, "lib/xbox360") }
  832. defines {
  833. "NOMINMAX",
  834. }
  835. configuration { "durango" }
  836. targetdir (path.join(_buildDir, "durango/bin"))
  837. objdir (path.join(_buildDir, "durango/obj"))
  838. includedirs { path.join(bxDir, "include/compat/msvc") }
  839. libdirs { path.join(_libDir, "lib/durango") }
  840. removeflags { "StaticRuntime" }
  841. defines {
  842. "NOMINMAX",
  843. }
  844. configuration { "netbsd" }
  845. targetdir (path.join(_buildDir, "netbsd/bin"))
  846. objdir (path.join(_buildDir, "netbsd/obj"))
  847. libdirs { path.join(_libDir, "lib/netbsd") }
  848. includedirs {
  849. path.join(bxDir, "include/compat/freebsd"),
  850. }
  851. configuration { "osx-x64" }
  852. targetdir (path.join(_buildDir, "osx-x64/bin"))
  853. objdir (path.join(_buildDir, "osx-x64/obj"))
  854. linkoptions {
  855. "-arch x86_64",
  856. }
  857. buildoptions {
  858. "-arch x86_64",
  859. "-msse2",
  860. "-target x86_64-apple-macos" .. (#macosPlatform > 0 and macosPlatform or "10.11"),
  861. }
  862. configuration { "osx-arm64" }
  863. targetdir (path.join(_buildDir, "osx-arm64/bin"))
  864. objdir (path.join(_buildDir, "osx-arm64/obj"))
  865. linkoptions {
  866. "-arch arm64",
  867. }
  868. buildoptions {
  869. "-arch arm64",
  870. "-Wno-error=unused-command-line-argument",
  871. "-Wno-unused-command-line-argument",
  872. }
  873. configuration { "osx*" }
  874. buildoptions {
  875. "-Wfatal-errors",
  876. "-Wunused-value",
  877. "-Wundef",
  878. }
  879. includedirs { path.join(bxDir, "include/compat/osx") }
  880. configuration { "ios*" }
  881. linkoptions {
  882. "-lc++",
  883. }
  884. buildoptions {
  885. "-Wfatal-errors",
  886. "-Wunused-value",
  887. "-Wundef",
  888. }
  889. includedirs { path.join(bxDir, "include/compat/ios") }
  890. configuration { "xcode*", "ios*" }
  891. targetdir (path.join(_buildDir, "ios-arm/bin"))
  892. objdir (path.join(_buildDir, "ios-arm/obj"))
  893. configuration { "ios-arm" }
  894. targetdir (path.join(_buildDir, "ios-arm/bin"))
  895. objdir (path.join(_buildDir, "ios-arm/obj"))
  896. libdirs { path.join(_libDir, "lib/ios-arm") }
  897. linkoptions {
  898. "-arch armv7",
  899. }
  900. buildoptions {
  901. "-arch armv7",
  902. }
  903. configuration { "ios-arm64" }
  904. targetdir (path.join(_buildDir, "ios-arm64/bin"))
  905. objdir (path.join(_buildDir, "ios-arm64/obj"))
  906. libdirs { path.join(_libDir, "lib/ios-arm64") }
  907. linkoptions {
  908. "-arch arm64",
  909. }
  910. buildoptions {
  911. "-arch arm64",
  912. }
  913. configuration { "ios-arm*" }
  914. linkoptions {
  915. "-miphoneos-version-min=9.0",
  916. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  917. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  918. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  919. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  920. }
  921. buildoptions {
  922. "-miphoneos-version-min=9.0",
  923. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  924. "-fembed-bitcode",
  925. }
  926. configuration { "ios-simulator" }
  927. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  928. objdir (path.join(_buildDir, "ios-simulator/obj"))
  929. libdirs { path.join(_libDir, "lib/ios-simulator") }
  930. linkoptions {
  931. "-mios-simulator-version-min=9.0",
  932. "-arch i386",
  933. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  934. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  935. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  936. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  937. }
  938. buildoptions {
  939. "-mios-simulator-version-min=9.0",
  940. "-arch i386",
  941. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  942. }
  943. configuration { "ios-simulator64" }
  944. targetdir (path.join(_buildDir, "ios-simulator64/bin"))
  945. objdir (path.join(_buildDir, "ios-simulator64/obj"))
  946. libdirs { path.join(_libDir, "lib/ios-simulator64") }
  947. linkoptions {
  948. "-mios-simulator-version-min=9.0",
  949. "-arch x86_64",
  950. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  951. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  952. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  953. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  954. }
  955. buildoptions {
  956. "-mios-simulator-version-min=9.0",
  957. "-arch x86_64",
  958. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  959. }
  960. configuration { "tvos*" }
  961. linkoptions {
  962. "-lc++",
  963. }
  964. buildoptions {
  965. "-Wfatal-errors",
  966. "-Wunused-value",
  967. "-Wundef",
  968. }
  969. includedirs { path.join(bxDir, "include/compat/ios") }
  970. configuration { "xcode*", "tvos*" }
  971. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  972. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  973. configuration { "tvos-arm64" }
  974. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  975. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  976. libdirs { path.join(_libDir, "lib/tvos-arm64") }
  977. linkoptions {
  978. "-mtvos-version-min=9.0",
  979. "-arch arm64",
  980. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  981. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
  982. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  983. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  984. }
  985. buildoptions {
  986. "-mtvos-version-min=9.0",
  987. "-arch arm64",
  988. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  989. }
  990. configuration { "tvos-simulator" }
  991. targetdir (path.join(_buildDir, "tvos-simulator/bin"))
  992. objdir (path.join(_buildDir, "tvos-simulator/obj"))
  993. libdirs { path.join(_libDir, "lib/tvos-simulator") }
  994. linkoptions {
  995. "-mtvos-simulator-version-min=9.0",
  996. "-arch i386",
  997. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  998. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
  999. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  1000. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1001. }
  1002. buildoptions {
  1003. "-mtvos-simulator-version-min=9.0",
  1004. "-arch i386",
  1005. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1006. }
  1007. configuration { "orbis" }
  1008. targetdir (path.join(_buildDir, "orbis/bin"))
  1009. objdir (path.join(_buildDir, "orbis/obj"))
  1010. libdirs { path.join(_libDir, "lib/orbis") }
  1011. includedirs {
  1012. path.join(bxDir, "include/compat/freebsd"),
  1013. "$(SCE_ORBIS_SDK_DIR)/target/include",
  1014. "$(SCE_ORBIS_SDK_DIR)/target/include_common",
  1015. }
  1016. configuration { "rpi" }
  1017. targetdir (path.join(_buildDir, "rpi/bin"))
  1018. objdir (path.join(_buildDir, "rpi/obj"))
  1019. libdirs {
  1020. path.join(_libDir, "lib/rpi"),
  1021. "/opt/vc/lib",
  1022. }
  1023. defines {
  1024. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  1025. "__STDC_VERSION__=199901L",
  1026. }
  1027. buildoptions {
  1028. "-Wunused-value",
  1029. "-Wundef",
  1030. }
  1031. includedirs {
  1032. "/opt/vc/include",
  1033. "/opt/vc/include/interface/vcos/pthreads",
  1034. "/opt/vc/include/interface/vmcs_host/linux",
  1035. }
  1036. links {
  1037. "rt",
  1038. "dl",
  1039. }
  1040. linkoptions {
  1041. "-Wl,--gc-sections",
  1042. }
  1043. configuration { "riscv" }
  1044. targetdir (path.join(_buildDir, "riscv/bin"))
  1045. objdir (path.join(_buildDir, "riscv/obj"))
  1046. defines {
  1047. "__BSD_VISIBLE",
  1048. "__MISC_VISIBLE",
  1049. }
  1050. includedirs {
  1051. "$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf/include",
  1052. path.join(bxDir, "include/compat/riscv"),
  1053. }
  1054. buildoptions {
  1055. "-Wunused-value",
  1056. "-Wundef",
  1057. "--sysroot=$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf",
  1058. }
  1059. configuration {} -- reset configuration
  1060. return true
  1061. end
  1062. function strip()
  1063. configuration { "android-arm", "Release" }
  1064. postbuildcommands {
  1065. "$(SILENT) echo Stripping symbols.",
  1066. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  1067. }
  1068. configuration { "android-arm64", "Release" }
  1069. postbuildcommands {
  1070. "$(SILENT) echo Stripping symbols.",
  1071. "$(SILENT) $(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-strip -s \"$(TARGET)\""
  1072. }
  1073. configuration { "android-x86", "Release" }
  1074. postbuildcommands {
  1075. "$(SILENT) echo Stripping symbols.",
  1076. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  1077. }
  1078. configuration { "linux-* or rpi", "Release" }
  1079. postbuildcommands {
  1080. "$(SILENT) echo Stripping symbols.",
  1081. "$(SILENT) strip -s \"$(TARGET)\""
  1082. }
  1083. configuration { "mingw*", "Release" }
  1084. postbuildcommands {
  1085. "$(SILENT) echo Stripping symbols.",
  1086. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  1087. }
  1088. configuration { "riscv" }
  1089. postbuildcommands {
  1090. "$(SILENT) echo Stripping symbols.",
  1091. "$(SILENT) $(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/bin/riscv64-unknown-elf-strip -s \"$(TARGET)\""
  1092. }
  1093. configuration {} -- reset configuration
  1094. end