toolchain.lua 40 KB

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