toolchain.lua 40 KB

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