toolchain.lua 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340
  1. --
  2. -- Copyright 2010-2018 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  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-mips", "Android - MIPS" },
  43. { "android-x86", "Android - x86" },
  44. { "asmjs", "Emscripten/asm.js" },
  45. { "freebsd", "FreeBSD" },
  46. { "linux-gcc", "Linux (GCC compiler)" },
  47. { "linux-gcc-afl", "Linux (GCC + AFL fuzzer)" },
  48. { "linux-gcc-6", "Linux (GCC-6 compiler)" },
  49. { "linux-clang", "Linux (Clang compiler)" },
  50. { "linux-clang-afl", "Linux (Clang + AFL fuzzer)" },
  51. { "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
  52. { "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
  53. { "ios-arm", "iOS - ARM" },
  54. { "ios-arm64", "iOS - ARM64" },
  55. { "ios-simulator", "iOS - Simulator" },
  56. { "ios-simulator64", "iOS - Simulator 64" },
  57. { "tvos-arm64", "tvOS - ARM64" },
  58. { "tvos-simulator", "tvOS - Simulator" },
  59. { "mingw-gcc", "MinGW" },
  60. { "mingw-clang", "MinGW (clang compiler)" },
  61. { "netbsd", "NetBSD" },
  62. { "osx", "OSX" },
  63. { "orbis", "Orbis" },
  64. { "riscv", "RISC-V" },
  65. { "rpi", "RaspberryPi" },
  66. },
  67. }
  68. newoption {
  69. trigger = "vs",
  70. value = "toolset",
  71. description = "Choose VS toolset",
  72. allowed = {
  73. { "vs2012-clang", "Clang 3.6" },
  74. { "vs2013-clang", "Clang 3.6" },
  75. { "vs2015-clang", "Clang 3.9" },
  76. { "vs2017-clang", "Clang with MS CodeGen" },
  77. { "vs2012-xp", "Visual Studio 2012 targeting XP" },
  78. { "vs2013-xp", "Visual Studio 2013 targeting XP" },
  79. { "vs2015-xp", "Visual Studio 2015 targeting XP" },
  80. { "vs2017-xp", "Visual Studio 2017 targeting XP" },
  81. { "winstore100", "Universal Windows App 10.0" },
  82. { "durango", "Durango" },
  83. { "orbis", "Orbis" },
  84. },
  85. }
  86. newoption {
  87. trigger = "xcode",
  88. value = "xcode_target",
  89. description = "Choose XCode target",
  90. allowed = {
  91. { "osx", "OSX" },
  92. { "ios", "iOS" },
  93. { "tvos", "tvOS" },
  94. }
  95. }
  96. newoption {
  97. trigger = "with-android",
  98. value = "#",
  99. description = "Set Android platform version (default: android-14).",
  100. }
  101. newoption {
  102. trigger = "with-ios",
  103. value = "#",
  104. description = "Set iOS target version (default: 8.0).",
  105. }
  106. newoption {
  107. trigger = "with-macos",
  108. value = "#",
  109. description = "Set macOS target version (default 10.11).",
  110. }
  111. newoption {
  112. trigger = "with-tvos",
  113. value = "#",
  114. description = "Set tvOS target version (default: 9.0).",
  115. }
  116. newoption {
  117. trigger = "with-windows",
  118. value = "#",
  119. description = "Set the Windows target platform version (default: $WindowsSDKVersion or 8.1).",
  120. }
  121. newoption {
  122. trigger = "with-dynamic-runtime",
  123. description = "Dynamically link with the runtime rather than statically",
  124. }
  125. newoption {
  126. trigger = "with-32bit-compiler",
  127. description = "Use 32-bit compiler instead 64-bit.",
  128. }
  129. newoption {
  130. trigger = "with-avx",
  131. description = "Use AVX extension.",
  132. }
  133. -- Avoid error when invoking genie --help.
  134. if (_ACTION == nil) then return false end
  135. location (path.join(_buildDir, "projects", _ACTION))
  136. if _ACTION == "clean" then
  137. os.rmdir(_buildDir)
  138. os.mkdir(_buildDir)
  139. os.exit(1)
  140. end
  141. local androidPlatform = "android-24"
  142. if _OPTIONS["with-android"] then
  143. androidPlatform = "android-" .. _OPTIONS["with-android"]
  144. end
  145. local iosPlatform = ""
  146. if _OPTIONS["with-ios"] then
  147. iosPlatform = _OPTIONS["with-ios"]
  148. end
  149. local macosPlatform = ""
  150. if _OPTIONS["with-macos"] then
  151. macosPlatform = _OPTIONS["with-macos"]
  152. end
  153. local tvosPlatform = ""
  154. if _OPTIONS["with-tvos"] then
  155. tvosPlatform = _OPTIONS["with-tvos"]
  156. end
  157. local windowsPlatform = string.gsub(os.getenv("WindowsSDKVersion") or "8.1", "\\", "")
  158. if _OPTIONS["with-windows"] then
  159. windowsPlatform = _OPTIONS["with-windows"]
  160. end
  161. local compiler32bit = false
  162. if _OPTIONS["with-32bit-compiler"] then
  163. compiler32bit = true
  164. end
  165. flags {
  166. "ExtraWarnings",
  167. }
  168. if _ACTION == "gmake" or _ACTION == "ninja" then
  169. if nil == _OPTIONS["gcc"] then
  170. print("GCC flavor must be specified!")
  171. os.exit(1)
  172. end
  173. if "android-arm" == _OPTIONS["gcc"] then
  174. if not os.getenv("ANDROID_NDK_ARM")
  175. or not os.getenv("ANDROID_NDK_CLANG")
  176. or not os.getenv("ANDROID_NDK_ROOT") then
  177. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT environment variables.")
  178. end
  179. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  180. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  181. premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
  182. premake.gcc.llvm = true
  183. location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
  184. elseif "android-mips" == _OPTIONS["gcc"] then
  185. if not os.getenv("ANDROID_NDK_MIPS")
  186. or not os.getenv("ANDROID_NDK_CLANG")
  187. or not os.getenv("ANDROID_NDK_ROOT") then
  188. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT environment variables.")
  189. end
  190. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  191. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  192. premake.gcc.llvm = true
  193. location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
  194. elseif "android-x86" == _OPTIONS["gcc"] then
  195. if not os.getenv("ANDROID_NDK_X86")
  196. or not os.getenv("ANDROID_NDK_CLANG")
  197. or not os.getenv("ANDROID_NDK_ROOT") then
  198. print("Set ANDROID_NDK_CLANG, ANDROID_NDK_ARM, and ANDROID_NDK_ROOT environment variables.")
  199. end
  200. premake.gcc.cc = "$(ANDROID_NDK_CLANG)/bin/clang"
  201. premake.gcc.cxx = "$(ANDROID_NDK_CLANG)/bin/clang++"
  202. premake.gcc.llvm = true
  203. location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
  204. elseif "asmjs" == _OPTIONS["gcc"] then
  205. if not os.getenv("EMSCRIPTEN") then
  206. print("Set EMSCRIPTEN environment variable.")
  207. end
  208. premake.gcc.cc = "\"$(EMSCRIPTEN)/emcc\""
  209. premake.gcc.cxx = "\"$(EMSCRIPTEN)/em++\""
  210. premake.gcc.ar = "\"$(EMSCRIPTEN)/emar\""
  211. premake.gcc.llvm = true
  212. location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
  213. elseif "freebsd" == _OPTIONS["gcc"] then
  214. location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
  215. elseif "ios-arm" == _OPTIONS["gcc"]
  216. or "ios-arm64" == _OPTIONS["gcc"] then
  217. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  218. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  219. premake.gcc.ar = "ar"
  220. location (path.join(_buildDir, "projects", _ACTION .. "-" .. _OPTIONS["gcc"]))
  221. elseif "ios-simulator" == _OPTIONS["gcc"] then
  222. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  223. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  224. premake.gcc.ar = "ar"
  225. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
  226. elseif "ios-simulator64" == _OPTIONS["gcc"] then
  227. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  228. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  229. premake.gcc.ar = "ar"
  230. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator64"))
  231. elseif "tvos-arm64" == _OPTIONS["gcc"] then
  232. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  233. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  234. premake.gcc.ar = "ar"
  235. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-arm64"))
  236. elseif "tvos-simulator" == _OPTIONS["gcc"] then
  237. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  238. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  239. premake.gcc.ar = "ar"
  240. location (path.join(_buildDir, "projects", _ACTION .. "-tvos-simulator"))
  241. elseif "linux-gcc" == _OPTIONS["gcc"] then
  242. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  243. elseif "linux-gcc-afl" == _OPTIONS["gcc"] then
  244. premake.gcc.cc = "afl-gcc"
  245. premake.gcc.cxx = "afl-g++"
  246. premake.gcc.ar = "ar"
  247. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  248. elseif "linux-gcc-6" == _OPTIONS["gcc"] then
  249. premake.gcc.cc = "gcc-6"
  250. premake.gcc.cxx = "g++-6"
  251. premake.gcc.ar = "ar"
  252. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  253. elseif "linux-clang" == _OPTIONS["gcc"] then
  254. premake.gcc.cc = "clang"
  255. premake.gcc.cxx = "clang++"
  256. premake.gcc.ar = "ar"
  257. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  258. elseif "linux-clang-afl" == _OPTIONS["gcc"] then
  259. premake.gcc.cc = "afl-clang"
  260. premake.gcc.cxx = "afl-clang++"
  261. premake.gcc.ar = "ar"
  262. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  263. elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
  264. location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
  265. elseif "linux-arm-gcc" == _OPTIONS["gcc"] then
  266. location (path.join(_buildDir, "projects", _ACTION .. "-linux-arm-gcc"))
  267. elseif "linux-steamlink" == _OPTIONS["gcc"] then
  268. if not os.getenv("MARVELL_SDK_PATH") then
  269. print("Set MARVELL_SDK_PATH environment variable.")
  270. end
  271. premake.gcc.cc = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-gcc"
  272. premake.gcc.cxx = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-g++"
  273. premake.gcc.ar = "$(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-ar"
  274. location (path.join(_buildDir, "projects", _ACTION .. "-linux-steamlink"))
  275. elseif "mingw-gcc" == _OPTIONS["gcc"] then
  276. if not os.getenv("MINGW") then
  277. print("Set MINGW environment variable.")
  278. end
  279. local mingwToolchain = "x86_64-w64-mingw32"
  280. if compiler32bit then
  281. if os.is("linux") then
  282. mingwToolchain = "i686-w64-mingw32"
  283. else
  284. mingwToolchain = "mingw32"
  285. end
  286. end
  287. premake.gcc.cc = "$(MINGW)/bin/" .. mingwToolchain .. "-gcc"
  288. premake.gcc.cxx = "$(MINGW)/bin/" .. mingwToolchain .. "-g++"
  289. premake.gcc.ar = "$(MINGW)/bin/ar"
  290. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
  291. elseif "mingw-clang" == _OPTIONS["gcc"] then
  292. premake.gcc.cc = "$(CLANG)/bin/clang"
  293. premake.gcc.cxx = "$(CLANG)/bin/clang++"
  294. premake.gcc.ar = "$(MINGW)/bin/ar"
  295. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  296. -- premake.gcc.llvm = true
  297. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
  298. elseif "netbsd" == _OPTIONS["gcc"] then
  299. location (path.join(_buildDir, "projects", _ACTION .. "-netbsd"))
  300. elseif "osx" == _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 .. "-osx"))
  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)/toolchain/bin/riscv32-unknown-elf-gcc"
  324. premake.gcc.cxx = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-g++"
  325. premake.gcc.ar = "$(FREEDOM_E_SDK)/toolchain/bin/riscv32-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. then
  333. local action = premake.action.current()
  334. action.vstudio.windowsTargetPlatformVersion = windowsPlatform
  335. action.vstudio.windowsTargetPlatformMinVersion = windowsPlatform
  336. if (_ACTION .. "-clang") == _OPTIONS["vs"] then
  337. if "vs2017-clang" == _OPTIONS["vs"] then
  338. premake.vstudio.toolset = "v141_clang_c2"
  339. elseif "vs2015-clang" == _OPTIONS["vs"] then
  340. premake.vstudio.toolset = "LLVM-vs2014"
  341. else
  342. premake.vstudio.toolset = ("LLVM-" .. _ACTION)
  343. end
  344. location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
  345. elseif "winstore100" == _OPTIONS["vs"] then
  346. premake.vstudio.toolset = "v141"
  347. premake.vstudio.storeapp = "10.0"
  348. platforms { "ARM" }
  349. location (path.join(_buildDir, "projects", _ACTION .. "-winstore100"))
  350. elseif "durango" == _OPTIONS["vs"] then
  351. if not os.getenv("DurangoXDK") then
  352. print("DurangoXDK not found.")
  353. end
  354. premake.vstudio.toolset = "v140"
  355. premake.vstudio.storeapp = "durango"
  356. platforms { "Durango" }
  357. location (path.join(_buildDir, "projects", _ACTION .. "-durango"))
  358. elseif "orbis" == _OPTIONS["vs"] then
  359. if not os.getenv("SCE_ORBIS_SDK_DIR") then
  360. print("Set SCE_ORBIS_SDK_DIR environment variable.")
  361. end
  362. platforms { "Orbis" }
  363. location (path.join(_buildDir, "projects", _ACTION .. "-orbis"))
  364. elseif ("vs2012-xp") == _OPTIONS["vs"] then
  365. premake.vstudio.toolset = ("v110_xp")
  366. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  367. elseif "vs2013-xp" == _OPTIONS["vs"] then
  368. premake.vstudio.toolset = ("v120_xp")
  369. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  370. elseif "vs2015-xp" == _OPTIONS["vs"] then
  371. premake.vstudio.toolset = ("v140_xp")
  372. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  373. elseif "vs2015-xp" == _OPTIONS["vs"] then
  374. premake.vstudio.toolset = ("v141_xp")
  375. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  376. end
  377. elseif _ACTION == "xcode4"
  378. or _ACTION == "xcode8"
  379. or _ACTION == "xcode9" 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. "_HAS_ITERATOR_DEBUGGING=0",
  450. "_ITERATOR_DEBUG_LEVEL=0",
  451. "_SCL_SECURE=0",
  452. "_SECURE_SCL=0",
  453. "_SCL_SECURE_NO_WARNINGS",
  454. "_CRT_SECURE_NO_WARNINGS",
  455. "_CRT_SECURE_NO_DEPRECATE",
  456. }
  457. buildoptions {
  458. "/wd4201", -- warning C4201: nonstandard extension used: nameless struct/union
  459. "/wd4324", -- warning C4324: '': structure was padded due to alignment specifier
  460. "/Ob2", -- The Inline Function Expansion
  461. }
  462. linkoptions {
  463. "/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
  464. }
  465. configuration { "vs2008" }
  466. includedirs { path.join(bxDir, "include/compat/msvc/pre1600") }
  467. configuration { "x32", "vs*" }
  468. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  469. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  470. libdirs {
  471. path.join(_libDir, "lib/win32_" .. _ACTION),
  472. }
  473. configuration { "x64", "vs*" }
  474. defines { "_WIN64" }
  475. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  476. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  477. libdirs {
  478. path.join(_libDir, "lib/win64_" .. _ACTION),
  479. }
  480. configuration { "x32", "vs2017" }
  481. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  482. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  483. libdirs {
  484. path.join(_libDir, "lib/win32_" .. _ACTION),
  485. }
  486. configuration { "x64", "vs2017" }
  487. defines { "_WIN64" }
  488. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  489. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  490. libdirs {
  491. path.join(_libDir, "lib/win64_" .. _ACTION),
  492. }
  493. configuration { "ARM", "vs*" }
  494. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  495. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  496. configuration { "vs*-clang" }
  497. buildoptions {
  498. "-Qunused-arguments",
  499. }
  500. configuration { "x32", "vs*-clang" }
  501. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  502. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  503. configuration { "x64", "vs*-clang" }
  504. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  505. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  506. configuration { "winstore*" }
  507. removeflags {
  508. "StaticRuntime",
  509. "NoBufferSecurityCheck",
  510. }
  511. buildoptions {
  512. "/wd4530", -- vccorlib.h(1345): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
  513. }
  514. linkoptions {
  515. "/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
  516. }
  517. configuration { "*-gcc* or osx" }
  518. buildoptions {
  519. "-Wshadow",
  520. }
  521. configuration { "mingw-*" }
  522. defines { "WIN32" }
  523. includedirs { path.join(bxDir, "include/compat/mingw") }
  524. defines {
  525. "MINGW_HAS_SECURE_API=1",
  526. }
  527. buildoptions {
  528. "-Wunused-value",
  529. "-fdata-sections",
  530. "-ffunction-sections",
  531. "-msse2",
  532. "-Wunused-value",
  533. "-Wundef",
  534. }
  535. buildoptions_cpp {
  536. "-std=c++11",
  537. }
  538. linkoptions {
  539. "-Wl,--gc-sections",
  540. "-static",
  541. "-static-libgcc",
  542. "-static-libstdc++",
  543. }
  544. configuration { "x32", "mingw-gcc" }
  545. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  546. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  547. libdirs {
  548. path.join(_libDir, "lib/win32_mingw-gcc"),
  549. }
  550. buildoptions {
  551. "-m32",
  552. "-mstackrealign",
  553. }
  554. configuration { "x64", "mingw-gcc" }
  555. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  556. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  557. libdirs {
  558. path.join(_libDir, "lib/win64_mingw-gcc"),
  559. }
  560. buildoptions { "-m64" }
  561. configuration { "mingw-clang" }
  562. buildoptions {
  563. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  564. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  565. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  566. }
  567. linkoptions {
  568. "-Qunused-arguments",
  569. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  570. }
  571. configuration { "x32", "mingw-clang" }
  572. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  573. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  574. libdirs {
  575. path.join(_libDir, "lib/win32_mingw-clang"),
  576. }
  577. buildoptions { "-m32" }
  578. configuration { "x64", "mingw-clang" }
  579. targetdir (path.join(_buildDir, "win64_mingw-clang/bin"))
  580. objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
  581. libdirs {
  582. path.join(_libDir, "lib/win64_mingw-clang"),
  583. }
  584. buildoptions { "-m64" }
  585. configuration { "linux-clang" }
  586. configuration { "linux-gcc-6" }
  587. buildoptions {
  588. -- "-fno-omit-frame-pointer",
  589. -- "-fsanitize=address",
  590. -- "-fsanitize=undefined",
  591. -- "-fsanitize=float-divide-by-zero",
  592. -- "-fsanitize=float-cast-overflow",
  593. }
  594. links {
  595. -- "asan",
  596. -- "ubsan",
  597. }
  598. configuration { "linux-gcc" }
  599. buildoptions {
  600. "-mfpmath=sse",
  601. }
  602. configuration { "linux-gcc* or linux-clang*" }
  603. buildoptions {
  604. "-msse2",
  605. -- "-Wdouble-promotion",
  606. -- "-Wduplicated-branches",
  607. -- "-Wduplicated-cond",
  608. -- "-Wjump-misses-init",
  609. "-Wshadow",
  610. -- "-Wnull-dereference",
  611. "-Wunused-value",
  612. "-Wundef",
  613. -- "-Wuseless-cast",
  614. }
  615. buildoptions_cpp {
  616. "-std=c++11",
  617. }
  618. links {
  619. "rt",
  620. "dl",
  621. }
  622. linkoptions {
  623. "-Wl,--gc-sections",
  624. "-Wl,--as-needed",
  625. }
  626. configuration { "linux-gcc*" }
  627. buildoptions {
  628. "-Wlogical-op",
  629. }
  630. configuration { "linux-gcc*", "x32" }
  631. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  632. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  633. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  634. buildoptions {
  635. "-m32",
  636. }
  637. configuration { "linux-gcc*", "x64" }
  638. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  639. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  640. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  641. buildoptions {
  642. "-m64",
  643. }
  644. configuration { "linux-clang*", "x32" }
  645. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  646. objdir (path.join(_buildDir, "linux32_clang/obj"))
  647. libdirs { path.join(_libDir, "lib/linux32_clang") }
  648. buildoptions {
  649. "-m32",
  650. }
  651. configuration { "linux-clang*", "x64" }
  652. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  653. objdir (path.join(_buildDir, "linux64_clang/obj"))
  654. libdirs { path.join(_libDir, "lib/linux64_clang") }
  655. buildoptions {
  656. "-m64",
  657. }
  658. configuration { "linux-mips-gcc" }
  659. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  660. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  661. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  662. buildoptions {
  663. "-Wunused-value",
  664. "-Wundef",
  665. }
  666. buildoptions_cpp {
  667. "-std=c++11",
  668. }
  669. links {
  670. "rt",
  671. "dl",
  672. }
  673. linkoptions {
  674. "-Wl,--gc-sections",
  675. }
  676. configuration { "linux-arm-gcc" }
  677. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  678. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  679. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  680. buildoptions {
  681. "-Wunused-value",
  682. "-Wundef",
  683. }
  684. buildoptions_cpp {
  685. "-std=c++11",
  686. }
  687. links {
  688. "rt",
  689. "dl",
  690. }
  691. linkoptions {
  692. "-Wl,--gc-sections",
  693. }
  694. configuration { "android-*" }
  695. targetprefix ("lib")
  696. flags {
  697. "NoImportLib",
  698. }
  699. includedirs {
  700. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  701. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  702. }
  703. linkoptions {
  704. "-nostdlib",
  705. }
  706. links {
  707. "c",
  708. "dl",
  709. "m",
  710. "android",
  711. "log",
  712. "c++",
  713. "gcc",
  714. }
  715. buildoptions {
  716. "-fPIC",
  717. "-no-canonical-prefixes",
  718. "-Wa,--noexecstack",
  719. "-fstack-protector-strong",
  720. "-ffunction-sections",
  721. "-Wunused-value",
  722. "-Wundef",
  723. }
  724. buildoptions_cpp {
  725. "-std=c++11",
  726. }
  727. linkoptions {
  728. "-no-canonical-prefixes",
  729. "-Wl,--no-undefined",
  730. "-Wl,-z,noexecstack",
  731. "-Wl,-z,relro",
  732. "-Wl,-z,now",
  733. }
  734. configuration { "linux-steamlink" }
  735. targetdir (path.join(_buildDir, "steamlink/bin"))
  736. objdir (path.join(_buildDir, "steamlink/obj"))
  737. libdirs { path.join(_libDir, "lib/steamlink") }
  738. includedirs { path.join(bxDir, "include/compat/linux") }
  739. defines {
  740. "__STEAMLINK__=1", -- There is no special prefedined compiler symbol to detect SteamLink, faking it.
  741. }
  742. buildoptions {
  743. "-std=c++11",
  744. "-Wfatal-errors",
  745. "-Wunused-value",
  746. "-Wundef",
  747. "-pthread",
  748. "-marm",
  749. "-mfloat-abi=hard",
  750. "--sysroot=$(MARVELL_SDK_PATH)/rootfs",
  751. }
  752. linkoptions {
  753. "-static-libgcc",
  754. "-static-libstdc++",
  755. "--sysroot=$(MARVELL_SDK_PATH)/rootfs",
  756. }
  757. configuration { "android-arm" }
  758. targetdir (path.join(_buildDir, "android-arm/bin"))
  759. objdir (path.join(_buildDir, "android-arm/obj"))
  760. libdirs {
  761. path.join(_libDir, "lib/android-arm"),
  762. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
  763. }
  764. includedirs {
  765. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/include",
  766. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  767. }
  768. buildoptions {
  769. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  770. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  771. "-target armv7-none-linux-androideabi",
  772. "-mthumb",
  773. "-march=armv7-a",
  774. "-mfloat-abi=softfp",
  775. "-mfpu=neon",
  776. "-Wunused-value",
  777. "-Wundef",
  778. }
  779. linkoptions {
  780. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  781. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  782. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  783. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  784. "-target armv7-none-linux-androideabi",
  785. "-march=armv7-a",
  786. "-Wl,--fix-cortex-a8",
  787. }
  788. configuration { "android-mips" }
  789. targetdir (path.join(_buildDir, "android-mips/bin"))
  790. objdir (path.join(_buildDir, "android-mips/obj"))
  791. libdirs {
  792. path.join(_libDir, "lib/android-mips"),
  793. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips",
  794. }
  795. includedirs {
  796. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/mips/include",
  797. }
  798. buildoptions {
  799. "-gcc-toolchain $(ANDROID_NDK_MIPS)",
  800. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  801. "-target mipsel-none-linux-android",
  802. "-mips32",
  803. "-Wunused-value",
  804. "-Wundef",
  805. }
  806. linkoptions {
  807. "-gcc-toolchain $(ANDROID_NDK_MIPS)",
  808. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  809. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  810. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  811. "-target mipsel-none-linux-android",
  812. "-mips32",
  813. }
  814. configuration { "android-x86" }
  815. targetdir (path.join(_buildDir, "android-x86/bin"))
  816. objdir (path.join(_buildDir, "android-x86/obj"))
  817. libdirs {
  818. path.join(_libDir, "lib/android-x86"),
  819. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
  820. }
  821. includedirs {
  822. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86/include",
  823. }
  824. buildoptions {
  825. "-gcc-toolchain $(ANDROID_NDK_X86)",
  826. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  827. "-target i686-none-linux-android",
  828. "-march=i686",
  829. "-mtune=atom",
  830. "-mstackrealign",
  831. "-msse3",
  832. "-mfpmath=sse",
  833. "-Wunused-value",
  834. "-Wundef",
  835. }
  836. linkoptions {
  837. "-gcc-toolchain $(ANDROID_NDK_X86)",
  838. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  839. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  840. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"),
  841. "-target i686-none-linux-android",
  842. }
  843. configuration { "asmjs" }
  844. targetdir (path.join(_buildDir, "asmjs/bin"))
  845. objdir (path.join(_buildDir, "asmjs/obj"))
  846. libdirs { path.join(_libDir, "lib/asmjs") }
  847. buildoptions {
  848. "-i\"system$(EMSCRIPTEN)/system/include\"",
  849. "-i\"system$(EMSCRIPTEN)/system/include/libcxx\"",
  850. "-i\"system$(EMSCRIPTEN)/system/include/libc\"",
  851. "-Wunused-value",
  852. "-Wundef",
  853. }
  854. buildoptions_cpp {
  855. "-std=c++11",
  856. }
  857. configuration { "freebsd" }
  858. targetdir (path.join(_buildDir, "freebsd/bin"))
  859. objdir (path.join(_buildDir, "freebsd/obj"))
  860. libdirs { path.join(_libDir, "lib/freebsd") }
  861. includedirs {
  862. path.join(bxDir, "include/compat/freebsd"),
  863. }
  864. configuration { "xbox360" }
  865. targetdir (path.join(_buildDir, "xbox360/bin"))
  866. objdir (path.join(_buildDir, "xbox360/obj"))
  867. includedirs { path.join(bxDir, "include/compat/msvc") }
  868. libdirs { path.join(_libDir, "lib/xbox360") }
  869. defines {
  870. "NOMINMAX",
  871. }
  872. configuration { "durango" }
  873. targetdir (path.join(_buildDir, "durango/bin"))
  874. objdir (path.join(_buildDir, "durango/obj"))
  875. includedirs { path.join(bxDir, "include/compat/msvc") }
  876. libdirs { path.join(_libDir, "lib/durango") }
  877. removeflags { "StaticRuntime" }
  878. defines {
  879. "NOMINMAX",
  880. }
  881. configuration { "netbsd" }
  882. targetdir (path.join(_buildDir, "netbsd/bin"))
  883. objdir (path.join(_buildDir, "netbsd/obj"))
  884. libdirs { path.join(_libDir, "lib/netbsd") }
  885. includedirs {
  886. path.join(bxDir, "include/compat/freebsd"),
  887. }
  888. configuration { "osx", "x32" }
  889. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  890. objdir (path.join(_buildDir, "osx32_clang/obj"))
  891. --libdirs { path.join(_libDir, "lib/osx32_clang") }
  892. buildoptions {
  893. "-m32",
  894. }
  895. configuration { "osx", "x64" }
  896. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  897. objdir (path.join(_buildDir, "osx64_clang/obj"))
  898. --libdirs { path.join(_libDir, "lib/osx64_clang") }
  899. buildoptions {
  900. "-m64",
  901. }
  902. configuration { "osx", "Universal" }
  903. targetdir (path.join(_buildDir, "osx_universal/bin"))
  904. objdir (path.join(_buildDir, "osx_universal/bin"))
  905. configuration { "osx" }
  906. buildoptions_cpp {
  907. "-std=c++11",
  908. }
  909. buildoptions_objcpp {
  910. "-std=c++11",
  911. }
  912. buildoptions {
  913. "-Wfatal-errors",
  914. "-msse2",
  915. "-Wunused-value",
  916. "-Wundef",
  917. }
  918. includedirs { path.join(bxDir, "include/compat/osx") }
  919. configuration { "ios*" }
  920. linkoptions {
  921. "-lc++",
  922. }
  923. buildoptions_cpp {
  924. "-std=c++11",
  925. }
  926. buildoptions_objcpp {
  927. "-std=c++11",
  928. }
  929. buildoptions {
  930. "-Wfatal-errors",
  931. "-Wunused-value",
  932. "-Wundef",
  933. }
  934. includedirs { path.join(bxDir, "include/compat/ios") }
  935. configuration { "xcode*", "ios*" }
  936. targetdir (path.join(_buildDir, "ios-arm/bin"))
  937. objdir (path.join(_buildDir, "ios-arm/obj"))
  938. configuration { "ios-arm" }
  939. targetdir (path.join(_buildDir, "ios-arm/bin"))
  940. objdir (path.join(_buildDir, "ios-arm/obj"))
  941. libdirs { path.join(_libDir, "lib/ios-arm") }
  942. linkoptions {
  943. "-arch armv7",
  944. }
  945. buildoptions {
  946. "-arch armv7",
  947. }
  948. configuration { "ios-arm64" }
  949. targetdir (path.join(_buildDir, "ios-arm64/bin"))
  950. objdir (path.join(_buildDir, "ios-arm64/obj"))
  951. libdirs { path.join(_libDir, "lib/ios-arm64") }
  952. linkoptions {
  953. "-arch arm64",
  954. }
  955. buildoptions {
  956. "-arch arm64",
  957. }
  958. configuration { "ios-arm*" }
  959. linkoptions {
  960. "-miphoneos-version-min=7.0",
  961. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  962. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  963. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  964. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  965. }
  966. buildoptions {
  967. "-miphoneos-version-min=7.0",
  968. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  969. }
  970. configuration { "ios-simulator" }
  971. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  972. objdir (path.join(_buildDir, "ios-simulator/obj"))
  973. libdirs { path.join(_libDir, "lib/ios-simulator") }
  974. linkoptions {
  975. "-mios-simulator-version-min=7.0",
  976. "-arch i386",
  977. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  978. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  979. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  980. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  981. }
  982. buildoptions {
  983. "-mios-simulator-version-min=7.0",
  984. "-arch i386",
  985. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  986. }
  987. configuration { "ios-simulator64" }
  988. targetdir (path.join(_buildDir, "ios-simulator64/bin"))
  989. objdir (path.join(_buildDir, "ios-simulator64/obj"))
  990. libdirs { path.join(_libDir, "lib/ios-simulator64") }
  991. linkoptions {
  992. "-mios-simulator-version-min=7.0",
  993. "-arch x86_64",
  994. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  995. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  996. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  997. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  998. }
  999. buildoptions {
  1000. "-mios-simulator-version-min=7.0",
  1001. "-arch x86_64",
  1002. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  1003. }
  1004. configuration { "tvos*" }
  1005. linkoptions {
  1006. "-lc++",
  1007. }
  1008. buildoptions {
  1009. "-Wfatal-errors",
  1010. "-Wunused-value",
  1011. "-Wundef",
  1012. }
  1013. includedirs { path.join(bxDir, "include/compat/ios") }
  1014. configuration { "xcode*", "tvos*" }
  1015. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  1016. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  1017. configuration { "tvos-arm64" }
  1018. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  1019. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  1020. libdirs { path.join(_libDir, "lib/tvos-arm64") }
  1021. linkoptions {
  1022. "-mtvos-version-min=9.0",
  1023. "-arch arm64",
  1024. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  1025. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
  1026. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  1027. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1028. }
  1029. buildoptions {
  1030. "-mtvos-version-min=9.0",
  1031. "-arch arm64",
  1032. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  1033. }
  1034. configuration { "tvos-simulator" }
  1035. targetdir (path.join(_buildDir, "tvos-simulator/bin"))
  1036. objdir (path.join(_buildDir, "tvos-simulator/obj"))
  1037. libdirs { path.join(_libDir, "lib/tvos-simulator") }
  1038. linkoptions {
  1039. "-mtvos-simulator-version-min=9.0",
  1040. "-arch i386",
  1041. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1042. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
  1043. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  1044. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  1045. }
  1046. buildoptions {
  1047. "-mtvos-simulator-version-min=9.0",
  1048. "-arch i386",
  1049. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1050. }
  1051. configuration { "orbis" }
  1052. targetdir (path.join(_buildDir, "orbis/bin"))
  1053. objdir (path.join(_buildDir, "orbis/obj"))
  1054. libdirs { path.join(_libDir, "lib/orbis") }
  1055. includedirs {
  1056. path.join(bxDir, "include/compat/freebsd"),
  1057. "$(SCE_ORBIS_SDK_DIR)/target/include",
  1058. "$(SCE_ORBIS_SDK_DIR)/target/include_common",
  1059. }
  1060. buildoptions_cpp {
  1061. "-std=c++11",
  1062. }
  1063. configuration { "rpi" }
  1064. targetdir (path.join(_buildDir, "rpi/bin"))
  1065. objdir (path.join(_buildDir, "rpi/obj"))
  1066. libdirs {
  1067. path.join(_libDir, "lib/rpi"),
  1068. "/opt/vc/lib",
  1069. }
  1070. defines {
  1071. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  1072. "__STDC_VERSION__=199901L",
  1073. }
  1074. buildoptions {
  1075. "-Wunused-value",
  1076. "-Wundef",
  1077. }
  1078. buildoptions_cpp {
  1079. "-std=c++11",
  1080. }
  1081. includedirs {
  1082. "/opt/vc/include",
  1083. "/opt/vc/include/interface/vcos/pthreads",
  1084. "/opt/vc/include/interface/vmcs_host/linux",
  1085. }
  1086. links {
  1087. "rt",
  1088. "dl",
  1089. }
  1090. linkoptions {
  1091. "-Wl,--gc-sections",
  1092. }
  1093. configuration { "riscv" }
  1094. targetdir (path.join(_buildDir, "riscv/bin"))
  1095. objdir (path.join(_buildDir, "riscv/obj"))
  1096. defines {
  1097. "__BSD_VISIBLE",
  1098. "__MISC_VISIBLE",
  1099. }
  1100. includedirs {
  1101. "$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf/include",
  1102. path.join(bxDir, "include/compat/riscv"),
  1103. }
  1104. buildoptions {
  1105. "-Wunused-value",
  1106. "-Wundef",
  1107. "--sysroot=$(FREEDOM_E_SDK)/toolchain/riscv32-unknown-elf",
  1108. }
  1109. buildoptions_cpp {
  1110. "-std=c++11",
  1111. }
  1112. configuration {} -- reset configuration
  1113. return true
  1114. end
  1115. function strip()
  1116. configuration { "android-arm", "Release" }
  1117. postbuildcommands {
  1118. "$(SILENT) echo Stripping symbols.",
  1119. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  1120. }
  1121. configuration { "android-mips", "Release" }
  1122. postbuildcommands {
  1123. "$(SILENT) echo Stripping symbols.",
  1124. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  1125. }
  1126. configuration { "android-x86", "Release" }
  1127. postbuildcommands {
  1128. "$(SILENT) echo Stripping symbols.",
  1129. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  1130. }
  1131. configuration { "linux-steamlink", "Release" }
  1132. postbuildcommands {
  1133. "$(SILENT) echo Stripping symbols.",
  1134. "$(SILENT) $(MARVELL_SDK_PATH)/toolchain/bin/armv7a-cros-linux-gnueabi-strip -s \"$(TARGET)\""
  1135. }
  1136. configuration { "linux-* or rpi", "not linux-steamlink", "Release" }
  1137. postbuildcommands {
  1138. "$(SILENT) echo Stripping symbols.",
  1139. "$(SILENT) strip -s \"$(TARGET)\""
  1140. }
  1141. configuration { "mingw*", "Release" }
  1142. postbuildcommands {
  1143. "$(SILENT) echo Stripping symbols.",
  1144. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  1145. }
  1146. configuration { "asmjs" }
  1147. postbuildcommands {
  1148. "$(SILENT) echo Running asmjs finalize.",
  1149. "$(SILENT) \"$(EMSCRIPTEN)/emcc\" -O2 "
  1150. -- .. "-s ALLOW_MEMORY_GROWTH=1 "
  1151. -- .. "-s ASSERTIONS=2 "
  1152. -- .. "-s EMTERPRETIFY=1 "
  1153. -- .. "-s EMTERPRETIFY_ASYNC=1 "
  1154. .. "-s PRECISE_F32=1 "
  1155. .. "-s TOTAL_MEMORY=268435456 "
  1156. -- .. "-s USE_WEBGL2=1 "
  1157. .. "--memory-init-file 1 "
  1158. .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
  1159. -- .. "--preload-file ../../../examples/runtime@/ "
  1160. }
  1161. configuration { "riscv" }
  1162. postbuildcommands {
  1163. "$(SILENT) echo Stripping symbols.",
  1164. "$(SILENT) $(FREEDOM_E_SDK)/toolchain/bin/riscv32-unknown-elf-strip -s \"$(TARGET)\""
  1165. }
  1166. configuration {} -- reset configuration
  1167. end