toolchain.lua 39 KB

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