toolchain.lua 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454
  1. --
  2. -- Copyright 2010-2017 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. --
  5. local bxDir = path.getabsolute("..")
  6. local naclToolchain = ""
  7. local function crtNone()
  8. defines {
  9. "BX_CRT_NONE=1",
  10. }
  11. buildoptions {
  12. "-nostdlib",
  13. "-nodefaultlibs",
  14. "-nostartfiles",
  15. "-Wa,--noexecstack",
  16. "-ffreestanding",
  17. }
  18. linkoptions {
  19. "-nostdlib",
  20. "-nodefaultlibs",
  21. "-nostartfiles",
  22. "-Wa,--noexecstack",
  23. "-ffreestanding",
  24. }
  25. configuration { "linux-*" }
  26. buildoptions {
  27. "-mpreferred-stack-boundary=4",
  28. "-mstackrealign",
  29. }
  30. linkoptions {
  31. "-mpreferred-stack-boundary=4",
  32. "-mstackrealign",
  33. }
  34. configuration {}
  35. end
  36. function toolchain(_buildDir, _libDir)
  37. newoption {
  38. trigger = "gcc",
  39. value = "GCC",
  40. description = "Choose GCC flavor",
  41. allowed = {
  42. { "android-arm", "Android - ARM" },
  43. { "android-mips", "Android - MIPS" },
  44. { "android-x86", "Android - x86" },
  45. { "asmjs", "Emscripten/asm.js" },
  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. { "tvos-arm64", "tvOS - ARM64" },
  58. { "tvos-simulator", "tvOS - Simulator" },
  59. { "mingw-gcc", "MinGW" },
  60. { "mingw-clang", "MinGW (clang compiler)" },
  61. { "nacl", "Native Client" },
  62. { "nacl-arm", "Native Client - ARM" },
  63. { "netbsd", "NetBSD" },
  64. { "osx", "OSX" },
  65. { "pnacl", "Native Client - PNaCl" },
  66. { "orbis", "Orbis" },
  67. { "qnx-arm", "QNX/Blackberry - ARM" },
  68. { "riscv", "RISC-V" },
  69. { "rpi", "RaspberryPi" },
  70. },
  71. }
  72. newoption {
  73. trigger = "vs",
  74. value = "toolset",
  75. description = "Choose VS toolset",
  76. allowed = {
  77. { "vs2012-clang", "Clang 3.6" },
  78. { "vs2013-clang", "Clang 3.6" },
  79. { "vs2015-clang", "Clang 3.9" },
  80. { "vs2017-clang", "Clang with MS CodeGen" },
  81. { "vs2012-xp", "Visual Studio 2012 targeting XP" },
  82. { "vs2013-xp", "Visual Studio 2013 targeting XP" },
  83. { "vs2015-xp", "Visual Studio 2015 targeting XP" },
  84. { "vs2017-xp", "Visual Studio 2017 targeting XP" },
  85. { "winphone8", "Windows Phone 8.0" },
  86. { "winphone81", "Windows Phone 8.1" },
  87. { "winstore81", "Windows Store 8.1" },
  88. { "winstore82", "Universal Windows App" },
  89. { "durango", "Durango" },
  90. { "orbis", "Orbis" },
  91. },
  92. }
  93. newoption {
  94. trigger = "xcode",
  95. value = "xcode_target",
  96. description = "Choose XCode target",
  97. allowed = {
  98. { "osx", "OSX" },
  99. { "ios", "iOS" },
  100. { "tvos", "tvOS" },
  101. }
  102. }
  103. newoption {
  104. trigger = "with-android",
  105. value = "#",
  106. description = "Set Android platform version (default: android-14).",
  107. }
  108. newoption {
  109. trigger = "with-ios",
  110. value = "#",
  111. description = "Set iOS target version (default: 8.0).",
  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: 10.0.10240.0).",
  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 tvosPlatform = ""
  152. if _OPTIONS["with-tvos"] then
  153. tvosPlatform = _OPTIONS["with-tvos"]
  154. end
  155. local windowsPlatform = "10.0.10240.0"
  156. if _OPTIONS["with-windows"] then
  157. windowsPlatform = _OPTIONS["with-windows"]
  158. end
  159. local compiler32bit = false
  160. if _OPTIONS["with-32bit-compiler"] then
  161. compiler32bit = true
  162. end
  163. flags {
  164. "ExtraWarnings",
  165. }
  166. if _ACTION == "gmake" or _ACTION == "ninja" then
  167. if nil == _OPTIONS["gcc"] then
  168. print("GCC flavor must be specified!")
  169. os.exit(1)
  170. end
  171. if "android-arm" == _OPTIONS["gcc"] then
  172. if not os.getenv("ANDROID_NDK_ARM")
  173. or not os.getenv("ANDROID_NDK_CLANG")
  174. or not os.getenv("ANDROID_NDK_ROOT") then
  175. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT envrionment variables.")
  176. end
  177. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  178. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  179. premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
  180. premake.gcc.llvm = true
  181. location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
  182. elseif "android-mips" == _OPTIONS["gcc"] then
  183. if not os.getenv("ANDROID_NDK_MIPS")
  184. or not os.getenv("ANDROID_NDK_CLANG")
  185. or not os.getenv("ANDROID_NDK_ROOT") then
  186. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT envrionment variables.")
  187. end
  188. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  189. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  190. premake.gcc.llvm = true
  191. location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
  192. elseif "android-x86" == _OPTIONS["gcc"] then
  193. if not os.getenv("ANDROID_NDK_X86")
  194. or not os.getenv("ANDROID_NDK_CLANG")
  195. or not os.getenv("ANDROID_NDK_ROOT") then
  196. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT envrionment variables.")
  197. end
  198. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  199. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  200. premake.gcc.llvm = true
  201. location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
  202. elseif "asmjs" == _OPTIONS["gcc"] then
  203. if not os.getenv("EMSCRIPTEN") then
  204. print("Set EMSCRIPTEN enviroment variable.")
  205. end
  206. premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\""
  207. premake.gcc.cxx = "\"$(EMSCRIPTEN)/em++\""
  208. premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\""
  209. premake.gcc.llvm = true
  210. location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
  211. elseif "freebsd" == _OPTIONS["gcc"] then
  212. location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
  213. elseif "ios-arm" == _OPTIONS["gcc"]
  214. or "ios-arm64" == _OPTIONS["gcc"] then
  215. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  216. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  217. premake.gcc.ar = "ar"
  218. location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
  219. elseif "ios-simulator" == _OPTIONS["gcc"] then
  220. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  221. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  222. premake.gcc.ar = "ar"
  223. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
  224. elseif "tvos-arm64" == _OPTIONS["gcc"] then
  225. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  226. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  227. premake.gcc.ar = "ar"
  228. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-arm64"))
  229. elseif "tvos-simulator" == _OPTIONS["gcc"] then
  230. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  231. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  232. premake.gcc.ar = "ar"
  233. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-simulator"))
  234. elseif "linux-gcc" == _OPTIONS["gcc"] then
  235. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  236. elseif "linux-gcc-afl" == _OPTIONS["gcc"] then
  237. premake.gcc.cc = "afl-gcc"
  238. premake.gcc.cxx = "afl-g++"
  239. premake.gcc.ar = "ar"
  240. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  241. elseif "linux-gcc-6" == _OPTIONS["gcc"] then
  242. premake.gcc.cc = "gcc-6"
  243. premake.gcc.cxx = "g++-6"
  244. premake.gcc.ar = "ar"
  245. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  246. elseif "linux-clang" == _OPTIONS["gcc"] then
  247. premake.gcc.cc = "clang"
  248. premake.gcc.cxx = "clang++"
  249. premake.gcc.ar = "ar"
  250. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  251. elseif "linux-clang-afl" == _OPTIONS["gcc"] then
  252. premake.gcc.cc = "afl-clang"
  253. premake.gcc.cxx = "afl-clang++"
  254. premake.gcc.ar = "ar"
  255. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  256. elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
  257. location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
  258. elseif "linux-arm-gcc" == _OPTIONS["gcc"] then
  259. location (path.join(_buildDir, "projects", _ACTION .. "-linux-arm-gcc"))
  260. elseif "linux-steamlink" == _OPTIONS["gcc"] then
  261. if not os.getenv("MARVELL_SDK_PATH") then
  262. print("Set MARVELL_SDK_PATH enviroment variable.")
  263. end
  264. premake.gcc.cc = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-gcc"
  265. premake.gcc.cxx = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-g++"
  266. premake.gcc.ar = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-ar"
  267. location (path.join(_buildDir, "projects", _ACTION .. "-linux-steamlink"))
  268. elseif "mingw-gcc" == _OPTIONS["gcc"] then
  269. local mingwToolchain = "x86_64-w64-mingw32"
  270. if compiler32bit then
  271. if os.is("linux") then
  272. mingwToolchain = "i686-w64-mingw32"
  273. else
  274. mingwToolchain = "mingw32"
  275. end
  276. end
  277. premake.gcc.cc = "$(MINGW)/bin/" .. mingwToolchain .. "-gcc"
  278. premake.gcc.cxx = "$(MINGW)/bin/" .. mingwToolchain .. "-g++"
  279. premake.gcc.ar = "$(MINGW)/bin/ar"
  280. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
  281. elseif "mingw-clang" == _OPTIONS["gcc"] then
  282. premake.gcc.cc = "$(CLANG)/bin/clang"
  283. premake.gcc.cxx = "$(CLANG)/bin/clang++"
  284. premake.gcc.ar = "$(MINGW)/bin/ar"
  285. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  286. -- premake.gcc.llvm = true
  287. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
  288. elseif "nacl" == _OPTIONS["gcc"] then
  289. if not os.getenv("NACL_SDK_ROOT") then
  290. print("Set NACL_SDK_ROOT enviroment variable.")
  291. end
  292. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_x86_glibc/bin/x86_64-nacl-"
  293. if os.is("macosx") then
  294. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_x86_glibc/bin/x86_64-nacl-"
  295. elseif os.is("linux") then
  296. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_x86_glibc/bin/x86_64-nacl-"
  297. end
  298. premake.gcc.cc = naclToolchain .. "gcc"
  299. premake.gcc.cxx = naclToolchain .. "g++"
  300. premake.gcc.ar = naclToolchain .. "ar"
  301. location (path.join(_buildDir, "projects", _ACTION .. "-nacl"))
  302. elseif "nacl-arm" == _OPTIONS["gcc"] then
  303. if not os.getenv("NACL_SDK_ROOT") then
  304. print("Set NACL_SDK_ROOT enviroment variable.")
  305. end
  306. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_arm_glibc/bin/arm-nacl-"
  307. if os.is("macosx") then
  308. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_arm_glibc/bin/arm-nacl-"
  309. elseif os.is("linux") then
  310. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_arm_glibc/bin/arm-nacl-"
  311. end
  312. premake.gcc.cc = naclToolchain .. "gcc"
  313. premake.gcc.cxx = naclToolchain .. "g++"
  314. premake.gcc.ar = naclToolchain .. "ar"
  315. location (path.join(_buildDir, "projects", _ACTION .. "-nacl-arm"))
  316. elseif "netbsd" == _OPTIONS["gcc"] then
  317. location (path.join(_buildDir, "projects", _ACTION .. "-netbsd"))
  318. elseif "osx" == _OPTIONS["gcc"] then
  319. if os.is("linux") then
  320. if not os.getenv("OSXCROSS") then
  321. print("Set OSXCROSS enviroment variable.")
  322. end
  323. local osxToolchain = "x86_64-apple-darwin15-"
  324. premake.gcc.cc = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "clang"
  325. premake.gcc.cxx = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "clang++"
  326. premake.gcc.ar = "$(OSXCROSS)/target/bin/" .. osxToolchain .. "ar"
  327. end
  328. location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
  329. elseif "pnacl" == _OPTIONS["gcc"] then
  330. if not os.getenv("NACL_SDK_ROOT") then
  331. print("Set NACL_SDK_ROOT enviroment variable.")
  332. end
  333. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_pnacl/bin/pnacl-"
  334. if os.is("macosx") then
  335. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_pnacl/bin/pnacl-"
  336. elseif os.is("linux") then
  337. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_pnacl/bin/pnacl-"
  338. end
  339. premake.gcc.cc = naclToolchain .. "clang"
  340. premake.gcc.cxx = naclToolchain .. "clang++"
  341. premake.gcc.ar = naclToolchain .. "ar"
  342. location (path.join(_buildDir, "projects", _ACTION .. "-pnacl"))
  343. elseif "orbis" == _OPTIONS["gcc"] then
  344. if not os.getenv("SCE_ORBIS_SDK_DIR") then
  345. print("Set SCE_ORBIS_SDK_DIR enviroment variable.")
  346. end
  347. orbisToolchain = "$(SCE_ORBIS_SDK_DIR)/host_tools/bin/orbis-"
  348. premake.gcc.cc = orbisToolchain .. "clang"
  349. premake.gcc.cxx = orbisToolchain .. "clang++"
  350. premake.gcc.ar = orbisToolchain .. "ar"
  351. location (path.join(_buildDir, "projects", _ACTION .. "-orbis"))
  352. elseif "qnx-arm" == _OPTIONS["gcc"] then
  353. if not os.getenv("QNX_HOST") then
  354. print("Set QNX_HOST enviroment variable.")
  355. end
  356. premake.gcc.cc = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-gcc"
  357. premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
  358. premake.gcc.ar = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
  359. location (path.join(_buildDir, "projects", _ACTION .. "-qnx-arm"))
  360. elseif "rpi" == _OPTIONS["gcc"] then
  361. location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
  362. elseif "riscv" == _OPTIONS["gcc"] then
  363. premake.gcc.cc = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-gcc"
  364. premake.gcc.cxx = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-g++"
  365. premake.gcc.ar = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-ar"
  366. location (path.join(_buildDir, "projects", _ACTION .. "-riscv"))
  367. end
  368. elseif _ACTION == "vs2012"
  369. or _ACTION == "vs2013"
  370. or _ACTION == "vs2015"
  371. or _ACTION == "vs2017"
  372. then
  373. if (_ACTION .. "-clang") == _OPTIONS["vs"] then
  374. if "vs2017-clang" == _OPTIONS["vs"] then
  375. premake.vstudio.toolset = "v141_clang_c2"
  376. elseif "vs2015-clang" == _OPTIONS["vs"] then
  377. premake.vstudio.toolset = "LLVM-vs2014"
  378. else
  379. premake.vstudio.toolset = ("LLVM-" .. _ACTION)
  380. end
  381. location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
  382. elseif "winphone8" == _OPTIONS["vs"] then
  383. premake.vstudio.toolset = "v110_wp80"
  384. location (path.join(_buildDir, "projects", _ACTION .. "-winphone8"))
  385. elseif "winphone81" == _OPTIONS["vs"] then
  386. premake.vstudio.toolset = "v120_wp81"
  387. premake.vstudio.storeapp = "8.1"
  388. platforms { "ARM" }
  389. location (path.join(_buildDir, "projects", _ACTION .. "-winphone81"))
  390. elseif "winstore81" == _OPTIONS["vs"] then
  391. premake.vstudio.toolset = "v120"
  392. premake.vstudio.storeapp = "8.1"
  393. platforms { "ARM" }
  394. location (path.join(_buildDir, "projects", _ACTION .. "-winstore81"))
  395. elseif "winstore82" == _OPTIONS["vs"] then
  396. premake.vstudio.toolset = "v140"
  397. premake.vstudio.storeapp = "8.2"
  398. local action = premake.action.current()
  399. action.vstudio.windowsTargetPlatformVersion = windowsPlatform
  400. action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform
  401. platforms { "ARM" }
  402. location (path.join(_buildDir, "projects", _ACTION .. "-winstore82"))
  403. elseif "durango" == _OPTIONS["vs"] then
  404. if not os.getenv("DurangoXDK") then
  405. print("DurangoXDK not found.")
  406. end
  407. premake.vstudio.toolset = "v140"
  408. premake.vstudio.storeapp = "durango"
  409. platforms { "Durango" }
  410. location (path.join(_buildDir, "projects", _ACTION .. "-durango"))
  411. elseif "orbis" == _OPTIONS["vs"] then
  412. if not os.getenv("SCE_ORBIS_SDK_DIR") then
  413. print("Set SCE_ORBIS_SDK_DIR enviroment variable.")
  414. end
  415. platforms { "Orbis" }
  416. location (path.join(_buildDir, "projects", _ACTION .. "-orbis"))
  417. end
  418. elseif ("vs2012-xp") == _OPTIONS["vs"] then
  419. premake.vstudio.toolset = ("v110_xp")
  420. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  421. elseif "vs2013-xp" == _OPTIONS["vs"] then
  422. premake.vstudio.toolset = ("v120_xp")
  423. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  424. elseif "vs2015-xp" == _OPTIONS["vs"] then
  425. premake.vstudio.toolset = ("v140_xp")
  426. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  427. elseif "vs2015-xp" == _OPTIONS["vs"] then
  428. premake.vstudio.toolset = ("v141_xp")
  429. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  430. elseif _ACTION == "xcode4" then
  431. if "osx" == _OPTIONS["xcode"] then
  432. premake.xcode.toolset = "macosx"
  433. location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
  434. elseif "ios" == _OPTIONS["xcode"] then
  435. premake.xcode.toolset = "iphoneos"
  436. location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
  437. elseif "tvos" == _OPTIONS["xcode"] then
  438. premake.xcode.toolset = "appletvos"
  439. location (path.join(_buildDir, "projects", _ACTION .. "-tvos"))
  440. end
  441. end
  442. if not _OPTIONS["with-dynamic-runtime"] then
  443. flags { "StaticRuntime" }
  444. end
  445. if _OPTIONS["with-avx"] then
  446. flags { "EnableAVX" }
  447. end
  448. if _OPTIONS["with-crtnone"] then
  449. crtNone()
  450. end
  451. flags {
  452. "NoPCH",
  453. "NativeWChar",
  454. "NoRTTI",
  455. "NoExceptions",
  456. "NoEditAndContinue",
  457. "NoFramePointer",
  458. "Symbols",
  459. }
  460. defines {
  461. "__STDC_LIMIT_MACROS",
  462. "__STDC_FORMAT_MACROS",
  463. "__STDC_CONSTANT_MACROS",
  464. }
  465. configuration { "Debug" }
  466. targetsuffix "Debug"
  467. defines {
  468. "_DEBUG",
  469. }
  470. configuration { "Release" }
  471. flags {
  472. "NoBufferSecurityCheck",
  473. "OptimizeSpeed",
  474. }
  475. defines {
  476. "NDEBUG",
  477. }
  478. targetsuffix "Release"
  479. configuration { "qbs" }
  480. flags {
  481. "ExtraWarnings",
  482. }
  483. configuration { "vs*", "x32" }
  484. flags {
  485. "EnableSSE2",
  486. }
  487. configuration { "vs*", "not orbis" }
  488. includedirs { path.join(bxDir, "include/compat/msvc") }
  489. defines {
  490. "WIN32",
  491. "_WIN32",
  492. "_HAS_EXCEPTIONS=0",
  493. "_HAS_ITERATOR_DEBUGGING=0",
  494. "_SCL_SECURE=0",
  495. "_SECURE_SCL=0",
  496. "_SCL_SECURE_NO_WARNINGS",
  497. "_CRT_SECURE_NO_WARNINGS",
  498. "_CRT_SECURE_NO_DEPRECATE",
  499. }
  500. buildoptions {
  501. "/wd4201", -- warning C4201: nonstandard extension used: nameless struct/union
  502. "/wd4324", -- warning C4324: '': structure was padded due to alignment specifier
  503. "/Ob2", -- The Inline Function Expansion
  504. }
  505. linkoptions {
  506. "/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
  507. }
  508. configuration { "vs2008" }
  509. includedirs { path.join(bxDir, "include/compat/msvc/pre1600") }
  510. configuration { "x32", "vs*" }
  511. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  512. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  513. libdirs {
  514. path.join(_libDir, "lib/win32_" .. _ACTION),
  515. }
  516. configuration { "x64", "vs*" }
  517. defines { "_WIN64" }
  518. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  519. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  520. libdirs {
  521. path.join(_libDir, "lib/win64_" .. _ACTION),
  522. }
  523. configuration { "x32", "vs2017" }
  524. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  525. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  526. libdirs {
  527. path.join(_libDir, "lib/win32_" .. _ACTION),
  528. }
  529. configuration { "x64", "vs2017" }
  530. defines { "_WIN64" }
  531. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  532. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  533. libdirs {
  534. path.join(_libDir, "lib/win64_" .. _ACTION),
  535. }
  536. configuration { "ARM", "vs*" }
  537. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  538. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  539. configuration { "vs*-clang" }
  540. buildoptions {
  541. "-Qunused-arguments",
  542. }
  543. configuration { "x32", "vs*-clang" }
  544. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  545. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  546. configuration { "x64", "vs*-clang" }
  547. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  548. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  549. configuration { "winphone8* or winstore8*" }
  550. removeflags {
  551. "StaticRuntime",
  552. "NoExceptions",
  553. }
  554. configuration { "*-gcc* or osx" }
  555. buildoptions {
  556. "-Wshadow",
  557. }
  558. configuration { "mingw-*" }
  559. defines { "WIN32" }
  560. includedirs { path.join(bxDir, "include/compat/mingw") }
  561. defines {
  562. "MINGW_HAS_SECURE_API=1",
  563. }
  564. buildoptions {
  565. "-Wunused-value",
  566. "-fdata-sections",
  567. "-ffunction-sections",
  568. "-msse2",
  569. "-Wunused-value",
  570. "-Wundef",
  571. }
  572. buildoptions_cpp {
  573. "-std=c++11",
  574. }
  575. linkoptions {
  576. "-Wl,--gc-sections",
  577. "-static",
  578. "-static-libgcc",
  579. "-static-libstdc++",
  580. }
  581. configuration { "x32", "mingw-gcc" }
  582. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  583. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  584. libdirs {
  585. path.join(_libDir, "lib/win32_mingw-gcc"),
  586. }
  587. buildoptions {
  588. "-m32",
  589. "-mstackrealign",
  590. }
  591. configuration { "x64", "mingw-gcc" }
  592. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  593. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  594. libdirs {
  595. path.join(_libDir, "lib/win64_mingw-gcc"),
  596. }
  597. buildoptions { "-m64" }
  598. configuration { "mingw-clang" }
  599. buildoptions {
  600. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  601. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  602. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  603. }
  604. linkoptions {
  605. "-Qunused-arguments",
  606. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  607. }
  608. configuration { "x32", "mingw-clang" }
  609. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  610. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  611. libdirs {
  612. path.join(_libDir, "lib/win32_mingw-clang"),
  613. }
  614. buildoptions { "-m32" }
  615. configuration { "x64", "mingw-clang" }
  616. targetdir (path.join(_buildDir, "win64_mingw-clang/bin"))
  617. objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
  618. libdirs {
  619. path.join(_libDir, "lib/win64_mingw-clang"),
  620. }
  621. buildoptions { "-m64" }
  622. configuration { "linux-clang" }
  623. configuration { "linux-gcc-6" }
  624. buildoptions {
  625. -- "-fno-omit-frame-pointer",
  626. -- "-fsanitize=address",
  627. -- "-fsanitize=undefined",
  628. -- "-fsanitize=float-divide-by-zero",
  629. -- "-fsanitize=float-cast-overflow",
  630. }
  631. links {
  632. -- "asan",
  633. -- "ubsan",
  634. }
  635. configuration { "linux-gcc" }
  636. buildoptions {
  637. "-mfpmath=sse",
  638. }
  639. configuration { "linux-gcc* or linux-clang*" }
  640. buildoptions {
  641. "-msse2",
  642. "-Wunused-value",
  643. "-Wundef",
  644. }
  645. buildoptions_cpp {
  646. "-std=c++11",
  647. }
  648. links {
  649. "rt",
  650. "dl",
  651. }
  652. linkoptions {
  653. "-Wl,--gc-sections",
  654. "-Wl,--as-needed",
  655. }
  656. configuration { "linux-gcc*", "x32" }
  657. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  658. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  659. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  660. buildoptions {
  661. "-m32",
  662. }
  663. configuration { "linux-gcc*", "x64" }
  664. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  665. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  666. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  667. buildoptions {
  668. "-m64",
  669. }
  670. configuration { "linux-clang*", "x32" }
  671. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  672. objdir (path.join(_buildDir, "linux32_clang/obj"))
  673. libdirs { path.join(_libDir, "lib/linux32_clang") }
  674. buildoptions {
  675. "-m32",
  676. }
  677. configuration { "linux-clang*", "x64" }
  678. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  679. objdir (path.join(_buildDir, "linux64_clang/obj"))
  680. libdirs { path.join(_libDir, "lib/linux64_clang") }
  681. buildoptions {
  682. "-m64",
  683. }
  684. configuration { "linux-mips-gcc" }
  685. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  686. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  687. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  688. buildoptions {
  689. "-Wunused-value",
  690. "-Wundef",
  691. }
  692. buildoptions_cpp {
  693. "-std=c++11",
  694. }
  695. links {
  696. "rt",
  697. "dl",
  698. }
  699. linkoptions {
  700. "-Wl,--gc-sections",
  701. }
  702. configuration { "linux-arm-gcc" }
  703. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  704. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  705. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  706. buildoptions {
  707. "-Wunused-value",
  708. "-Wundef",
  709. }
  710. buildoptions_cpp {
  711. "-std=c++11",
  712. }
  713. links {
  714. "rt",
  715. "dl",
  716. }
  717. linkoptions {
  718. "-Wl,--gc-sections",
  719. }
  720. configuration { "android-*" }
  721. targetprefix ("lib")
  722. flags {
  723. "NoImportLib",
  724. }
  725. includedirs {
  726. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  727. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  728. }
  729. linkoptions {
  730. "-nostdlib",
  731. }
  732. links {
  733. "c",
  734. "dl",
  735. "m",
  736. "android",
  737. "log",
  738. "c++",
  739. "gcc",
  740. }
  741. buildoptions {
  742. "-fPIC",
  743. "-no-canonical-prefixes",
  744. "-Wa,--noexecstack",
  745. "-fstack-protector-strong",
  746. "-ffunction-sections",
  747. "-Wunused-value",
  748. "-Wundef",
  749. }
  750. buildoptions_cpp {
  751. "-std=c++11",
  752. }
  753. linkoptions {
  754. "-no-canonical-prefixes",
  755. "-Wl,--no-undefined",
  756. "-Wl,-z,noexecstack",
  757. "-Wl,-z,relro",
  758. "-Wl,-z,now",
  759. }
  760. configuration { "linux-steamlink" }
  761. targetdir (path.join(_buildDir, "steamlink/bin"))
  762. objdir (path.join(_buildDir, "steamlink/obj"))
  763. libdirs { path.join(_libDir, "lib/steamlink") }
  764. includedirs { path.join(bxDir, "include/compat/linux") }
  765. defines {
  766. "__STEAMLINK__=1", -- There is no special prefedined compiler symbol to detect SteamLink, faking it.
  767. }
  768. buildoptions {
  769. "-std=c++11",
  770. "-Wfatal-errors",
  771. "-Wunused-value",
  772. "-Wundef",
  773. "-pthread",
  774. "-marm",
  775. "-mfloat-abi=hard",
  776. "--sysroot=$(MARVELL_SDK_PATH)/rootfs",
  777. }
  778. linkoptions {
  779. "-static-libgcc",
  780. "-static-libstdc++",
  781. "--sysroot=$(MARVELL_SDK_PATH)/rootfs",
  782. }
  783. configuration { "android-arm" }
  784. targetdir (path.join(_buildDir, "android-arm/bin"))
  785. objdir (path.join(_buildDir, "android-arm/obj"))
  786. libdirs {
  787. path.join(_libDir, "lib/android-arm"),
  788. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
  789. }
  790. includedirs {
  791. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/include",
  792. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  793. }
  794. buildoptions {
  795. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  796. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  797. "-target armv7-none-linux-androideabi",
  798. "-mthumb",
  799. "-march=armv7-a",
  800. "-mfloat-abi=softfp",
  801. "-mfpu=neon",
  802. "-Wunused-value",
  803. "-Wundef",
  804. }
  805. linkoptions {
  806. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  807. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  808. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  809. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  810. "-target armv7-none-linux-androideabi",
  811. "-march=armv7-a",
  812. "-Wl,--fix-cortex-a8",
  813. }
  814. configuration { "android-mips" }
  815. targetdir (path.join(_buildDir, "android-mips/bin"))
  816. objdir (path.join(_buildDir, "android-mips/obj"))
  817. libdirs {
  818. path.join(_libDir, "lib/android-mips"),
  819. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips",
  820. }
  821. includedirs {
  822. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips/include",
  823. }
  824. buildoptions {
  825. "-gcc-toolchain $(ANDROID_NDK_MIPS)",
  826. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  827. "-target mipsel-none-linux-android",
  828. "-mips32",
  829. "-Wunused-value",
  830. "-Wundef",
  831. }
  832. linkoptions {
  833. "-gcc-toolchain $(ANDROID_NDK_MIPS)",
  834. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  835. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  836. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  837. "-target mipsel-none-linux-android",
  838. "-mips32",
  839. }
  840. configuration { "android-x86" }
  841. targetdir (path.join(_buildDir, "android-x86/bin"))
  842. objdir (path.join(_buildDir, "android-x86/obj"))
  843. libdirs {
  844. path.join(_libDir, "lib/android-x86"),
  845. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
  846. }
  847. includedirs {
  848. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86/include",
  849. }
  850. buildoptions {
  851. "-gcc-toolchain $(ANDROID_NDK_X86)",
  852. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  853. "-target i686-none-linux-android",
  854. "-march=i686",
  855. "-mtune=atom",
  856. "-mstackrealign",
  857. "-msse3",
  858. "-mfpmath=sse",
  859. "-Wunused-value",
  860. "-Wundef",
  861. }
  862. linkoptions {
  863. "-gcc-toolchain $(ANDROID_NDK_X86)",
  864. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  865. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  866. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"),
  867. "-target i686-none-linux-android",
  868. }
  869. configuration { "asmjs" }
  870. targetdir (path.join(_buildDir, "asmjs/bin"))
  871. objdir (path.join(_buildDir, "asmjs/obj"))
  872. libdirs { path.join(_libDir, "lib/asmjs") }
  873. buildoptions {
  874. "-i\"system$(EMSCRIPTEN)/system/include\"",
  875. "-i\"system$(EMSCRIPTEN)/system/include/libc\"",
  876. "-Wunused-value",
  877. "-Wundef",
  878. }
  879. configuration { "freebsd" }
  880. targetdir (path.join(_buildDir, "freebsd/bin"))
  881. objdir (path.join(_buildDir, "freebsd/obj"))
  882. libdirs { path.join(_libDir, "lib/freebsd") }
  883. includedirs {
  884. path.join(bxDir, "include/compat/freebsd"),
  885. }
  886. configuration { "nacl or nacl-arm or pnacl" }
  887. buildoptions {
  888. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  889. "-fno-stack-protector",
  890. "-fdiagnostics-show-option",
  891. "-fdata-sections",
  892. "-ffunction-sections",
  893. "-Wunused-value",
  894. "-Wundef",
  895. }
  896. buildoptions_cpp {
  897. "-std=c++11",
  898. }
  899. includedirs {
  900. "$(NACL_SDK_ROOT)/include",
  901. path.join(bxDir, "include/compat/nacl"),
  902. }
  903. configuration { "nacl" }
  904. buildoptions {
  905. "-pthread",
  906. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  907. "-msse2",
  908. }
  909. linkoptions {
  910. "-Wl,--gc-sections",
  911. }
  912. configuration { "x32", "nacl" }
  913. targetdir (path.join(_buildDir, "nacl-x86/bin"))
  914. objdir (path.join(_buildDir, "nacl-x86/obj"))
  915. libdirs { path.join(_libDir, "lib/nacl-x86") }
  916. linkoptions { "-melf32_nacl" }
  917. configuration { "x32", "nacl", "Debug" }
  918. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_x86_32/Debug" }
  919. configuration { "x32", "nacl", "Release" }
  920. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_x86_32/Release" }
  921. configuration { "x64", "nacl" }
  922. targetdir (path.join(_buildDir, "nacl-x64/bin"))
  923. objdir (path.join(_buildDir, "nacl-x64/obj"))
  924. libdirs { path.join(_libDir, "lib/nacl-x64") }
  925. linkoptions { "-melf64_nacl" }
  926. configuration { "x64", "nacl", "Debug" }
  927. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_x86_64/Debug" }
  928. configuration { "x64", "nacl", "Release" }
  929. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_x86_64/Release" }
  930. configuration { "nacl-arm" }
  931. buildoptions {
  932. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  933. }
  934. targetdir (path.join(_buildDir, "nacl-arm/bin"))
  935. objdir (path.join(_buildDir, "nacl-arm/obj"))
  936. libdirs { path.join(_libDir, "lib/nacl-arm") }
  937. configuration { "nacl-arm", "Debug" }
  938. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_arm/Debug" }
  939. configuration { "nacl-arm", "Release" }
  940. libdirs { "$(NACL_SDK_ROOT)/lib/glibc_arm/Release" }
  941. configuration { "pnacl" }
  942. targetdir (path.join(_buildDir, "pnacl/bin"))
  943. objdir (path.join(_buildDir, "pnacl/obj"))
  944. libdirs { path.join(_libDir, "lib/pnacl") }
  945. configuration { "pnacl", "Debug" }
  946. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  947. configuration { "pnacl", "Release" }
  948. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  949. configuration { "xbox360" }
  950. targetdir (path.join(_buildDir, "xbox360/bin"))
  951. objdir (path.join(_buildDir, "xbox360/obj"))
  952. includedirs { path.join(bxDir, "include/compat/msvc") }
  953. libdirs { path.join(_libDir, "lib/xbox360") }
  954. defines {
  955. "NOMINMAX",
  956. }
  957. configuration { "durango" }
  958. targetdir (path.join(_buildDir, "durango/bin"))
  959. objdir (path.join(_buildDir, "durango/obj"))
  960. includedirs { path.join(bxDir, "include/compat/msvc") }
  961. libdirs { path.join(_libDir, "lib/durango") }
  962. removeflags { "StaticRuntime" }
  963. defines {
  964. "NOMINMAX",
  965. }
  966. configuration { "netbsd" }
  967. targetdir (path.join(_buildDir, "netbsd/bin"))
  968. objdir (path.join(_buildDir, "netbsd/obj"))
  969. libdirs { path.join(_libDir, "lib/netbsd") }
  970. includedirs {
  971. path.join(bxDir, "include/compat/freebsd"),
  972. }
  973. configuration { "osx", "x32" }
  974. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  975. objdir (path.join(_buildDir, "osx32_clang/obj"))
  976. --libdirs { path.join(_libDir, "lib/osx32_clang") }
  977. buildoptions {
  978. "-m32",
  979. }
  980. configuration { "osx", "x64" }
  981. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  982. objdir (path.join(_buildDir, "osx64_clang/obj"))
  983. --libdirs { path.join(_libDir, "lib/osx64_clang") }
  984. buildoptions {
  985. "-m64",
  986. }
  987. configuration { "osx", "Universal" }
  988. targetdir (path.join(_buildDir, "osx_universal/bin"))
  989. objdir (path.join(_buildDir, "osx_universal/bin"))
  990. configuration { "osx" }
  991. buildoptions_cpp {
  992. "-std=c++11",
  993. }
  994. buildoptions {
  995. "-Wfatal-errors",
  996. "-msse2",
  997. "-Wunused-value",
  998. "-Wundef",
  999. }
  1000. includedirs { path.join(bxDir, "include/compat/osx") }
  1001. configuration { "ios*" }
  1002. linkoptions {
  1003. "-lc++",
  1004. }
  1005. buildoptions_cpp {
  1006. "-std=c++11",
  1007. }
  1008. buildoptions {
  1009. "-Wfatal-errors",
  1010. "-Wunused-value",
  1011. "-Wundef",
  1012. }
  1013. includedirs { path.join(bxDir, "include/compat/ios") }
  1014. configuration { "xcode4", "ios*" }
  1015. targetdir (path.join(_buildDir, "ios-arm/bin"))
  1016. objdir (path.join(_buildDir, "ios-arm/obj"))
  1017. configuration { "ios-arm" }
  1018. targetdir (path.join(_buildDir, "ios-arm/bin"))
  1019. objdir (path.join(_buildDir, "ios-arm/obj"))
  1020. libdirs { path.join(_libDir, "lib/ios-arm") }
  1021. linkoptions {
  1022. "-arch armv7",
  1023. }
  1024. buildoptions {
  1025. "-arch armv7",
  1026. }
  1027. configuration { "ios-arm64" }
  1028. targetdir (path.join(_buildDir, "ios-arm64/bin"))
  1029. objdir (path.join(_buildDir, "ios-arm64/obj"))
  1030. libdirs { path.join(_libDir, "lib/ios-arm64") }
  1031. linkoptions {
  1032. "-arch arm64",
  1033. }
  1034. buildoptions {
  1035. "-arch arm64",
  1036. }
  1037. configuration { "ios-arm*" }
  1038. linkoptions {
  1039. "-miphoneos-version-min=7.0",
  1040. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  1041. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  1042. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  1043. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1044. }
  1045. buildoptions {
  1046. "-miphoneos-version-min=7.0",
  1047. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  1048. }
  1049. configuration { "ios-simulator" }
  1050. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  1051. objdir (path.join(_buildDir, "ios-simulator/obj"))
  1052. libdirs { path.join(_libDir, "lib/ios-simulator") }
  1053. linkoptions {
  1054. "-mios-simulator-version-min=7.0",
  1055. "-arch i386",
  1056. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  1057. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  1058. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  1059. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1060. }
  1061. buildoptions {
  1062. "-mios-simulator-version-min=7.0",
  1063. "-arch i386",
  1064. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  1065. }
  1066. configuration { "tvos*" }
  1067. linkoptions {
  1068. "-lc++",
  1069. }
  1070. buildoptions {
  1071. "-Wfatal-errors",
  1072. "-Wunused-value",
  1073. "-Wundef",
  1074. }
  1075. includedirs { path.join(bxDir, "include/compat/ios") }
  1076. configuration { "xcode4", "tvos*" }
  1077. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  1078. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  1079. configuration { "tvos-arm64" }
  1080. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  1081. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  1082. libdirs { path.join(_libDir, "lib/tvos-arm64") }
  1083. linkoptions {
  1084. "-mtvos-version-min=9.0",
  1085. "-arch arm64",
  1086. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  1087. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
  1088. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  1089. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1090. }
  1091. buildoptions {
  1092. "-mtvos-version-min=9.0",
  1093. "-arch arm64",
  1094. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  1095. }
  1096. configuration { "tvos-simulator" }
  1097. targetdir (path.join(_buildDir, "tvos-simulator/bin"))
  1098. objdir (path.join(_buildDir, "tvos-simulator/obj"))
  1099. libdirs { path.join(_libDir, "lib/tvos-simulator") }
  1100. linkoptions {
  1101. "-mtvos-simulator-version-min=9.0",
  1102. "-arch i386",
  1103. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1104. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
  1105. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  1106. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1107. }
  1108. buildoptions {
  1109. "-mtvos-simulator-version-min=9.0",
  1110. "-arch i386",
  1111. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1112. }
  1113. configuration { "orbis" }
  1114. targetdir (path.join(_buildDir, "orbis/bin"))
  1115. objdir (path.join(_buildDir, "orbis/obj"))
  1116. libdirs { path.join(_libDir, "lib/orbis") }
  1117. includedirs {
  1118. path.join(bxDir, "include/compat/freebsd"),
  1119. "$(SCE_ORBIS_SDK_DIR)/target/include",
  1120. "$(SCE_ORBIS_SDK_DIR)/target/include_common",
  1121. }
  1122. buildoptions {
  1123. }
  1124. buildoptions_cpp {
  1125. "-std=c++11",
  1126. }
  1127. linkoptions {
  1128. }
  1129. configuration { "qnx-arm" }
  1130. targetdir (path.join(_buildDir, "qnx-arm/bin"))
  1131. objdir (path.join(_buildDir, "qnx-arm/obj"))
  1132. libdirs { path.join(_libDir, "lib/qnx-arm") }
  1133. -- includedirs { path.join(bxDir, "include/compat/qnx") }
  1134. buildoptions {
  1135. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  1136. "-Wunused-value",
  1137. "-Wundef",
  1138. }
  1139. buildoptions_cpp {
  1140. "-std=c++11",
  1141. }
  1142. configuration { "rpi" }
  1143. targetdir (path.join(_buildDir, "rpi/bin"))
  1144. objdir (path.join(_buildDir, "rpi/obj"))
  1145. libdirs {
  1146. path.join(_libDir, "lib/rpi"),
  1147. "/opt/vc/lib",
  1148. }
  1149. defines {
  1150. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  1151. "__STDC_VERSION__=199901L",
  1152. }
  1153. buildoptions {
  1154. "-Wunused-value",
  1155. "-Wundef",
  1156. }
  1157. buildoptions_cpp {
  1158. "-std=c++11",
  1159. }
  1160. includedirs {
  1161. "/opt/vc/include",
  1162. "/opt/vc/include/interface/vcos/pthreads",
  1163. "/opt/vc/include/interface/vmcs_host/linux",
  1164. }
  1165. links {
  1166. "rt",
  1167. "dl",
  1168. }
  1169. linkoptions {
  1170. "-Wl,--gc-sections",
  1171. }
  1172. configuration { "riscv" }
  1173. targetdir (path.join(_buildDir, "riscv/bin"))
  1174. objdir (path.join(_buildDir, "riscv/obj"))
  1175. defines {
  1176. "__BSD_VISIBLE",
  1177. "__MISC_VISIBLE",
  1178. }
  1179. includedirs {
  1180. "$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf/include",
  1181. path.join(bxDir, "include/compat/riscv"),
  1182. }
  1183. buildoptions {
  1184. "-Wunused-value",
  1185. "-Wundef",
  1186. "--sysroot=$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf",
  1187. }
  1188. buildoptions_cpp {
  1189. "-std=c++11",
  1190. }
  1191. configuration {} -- reset configuration
  1192. return true
  1193. end
  1194. function strip()
  1195. configuration { "android-arm", "Release" }
  1196. postbuildcommands {
  1197. "$(SILENT) echo Stripping symbols.",
  1198. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  1199. }
  1200. configuration { "android-mips", "Release" }
  1201. postbuildcommands {
  1202. "$(SILENT) echo Stripping symbols.",
  1203. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  1204. }
  1205. configuration { "android-x86", "Release" }
  1206. postbuildcommands {
  1207. "$(SILENT) echo Stripping symbols.",
  1208. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  1209. }
  1210. configuration { "linux-steamlink", "Release" }
  1211. postbuildcommands {
  1212. "$(SILENT) echo Stripping symbols.",
  1213. "$(SILENT) $(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-strip -s \"$(TARGET)\""
  1214. }
  1215. configuration { "linux-* or rpi", "not linux-steamlink", "Release" }
  1216. postbuildcommands {
  1217. "$(SILENT) echo Stripping symbols.",
  1218. "$(SILENT) strip -s \"$(TARGET)\""
  1219. }
  1220. configuration { "mingw*", "Release" }
  1221. postbuildcommands {
  1222. "$(SILENT) echo Stripping symbols.",
  1223. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  1224. }
  1225. configuration { "pnacl" }
  1226. postbuildcommands {
  1227. "$(SILENT) echo Running pnacl-finalize.",
  1228. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  1229. }
  1230. configuration { "*nacl*", "Release" }
  1231. postbuildcommands {
  1232. "$(SILENT) echo Stripping symbols.",
  1233. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  1234. }
  1235. configuration { "asmjs" }
  1236. postbuildcommands {
  1237. "$(SILENT) echo Running asmjs finalize.",
  1238. "$(SILENT) \"$(EMSCRIPTEN)/emcc\" -O2 "
  1239. -- .. "-s EMTERPRETIFY=1 "
  1240. -- .. "-s EMTERPRETIFY_ASYNC=1 "
  1241. .. "-s TOTAL_MEMORY=268435456 "
  1242. -- .. "-s ALLOW_MEMORY_GROWTH=1 "
  1243. -- .. "-s USE_WEBGL2=1 "
  1244. .. "--memory-init-file 1 "
  1245. .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
  1246. -- .. "--preload-file ../../../examples/runtime@/"
  1247. }
  1248. configuration { "riscv" }
  1249. postbuildcommands {
  1250. "$(SILENT) echo Stripping symbols.",
  1251. "$(SILENT) $(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-strip -s \"$(TARGET)\""
  1252. }
  1253. configuration {} -- reset configuration
  1254. end