toolchain.lua 38 KB

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