toolchain.lua 44 KB

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