toolchain.lua 43 KB

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