toolchain.lua 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263
  1. --
  2. -- Copyright 2010-2021 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-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. }
  460. linkoptions {
  461. "/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
  462. }
  463. configuration { "vs2008" }
  464. includedirs { path.join(bxDir, "include/compat/msvc/pre1600") }
  465. configuration { "x32", "vs*" }
  466. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  467. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  468. libdirs {
  469. path.join(_libDir, "lib/win32_" .. _ACTION),
  470. }
  471. configuration { "x64", "vs*" }
  472. defines { "_WIN64" }
  473. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  474. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  475. libdirs {
  476. path.join(_libDir, "lib/win64_" .. _ACTION),
  477. }
  478. configuration { "x32", "vs2017" }
  479. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  480. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  481. libdirs {
  482. path.join(_libDir, "lib/win32_" .. _ACTION),
  483. }
  484. configuration { "x64", "vs2017" }
  485. defines { "_WIN64" }
  486. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  487. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  488. libdirs {
  489. path.join(_libDir, "lib/win64_" .. _ACTION),
  490. }
  491. configuration { "ARM", "vs*" }
  492. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  493. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  494. configuration { "vs*-clang" }
  495. buildoptions {
  496. "-Qunused-arguments",
  497. }
  498. configuration { "x32", "vs*-clang" }
  499. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  500. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  501. configuration { "x64", "vs*-clang" }
  502. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  503. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  504. configuration { "winstore*" }
  505. removeflags {
  506. "StaticRuntime",
  507. "NoBufferSecurityCheck",
  508. }
  509. buildoptions {
  510. "/wd4530", -- vccorlib.h(1345): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
  511. }
  512. linkoptions {
  513. "/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
  514. }
  515. configuration { "*-gcc* or osx" }
  516. buildoptions {
  517. "-Wshadow",
  518. }
  519. configuration { "mingw-*" }
  520. defines { "WIN32" }
  521. includedirs { path.join(bxDir, "include/compat/mingw") }
  522. defines {
  523. "MINGW_HAS_SECURE_API=1",
  524. }
  525. buildoptions {
  526. "-Wunused-value",
  527. "-fdata-sections",
  528. "-ffunction-sections",
  529. "-msse2",
  530. "-Wunused-value",
  531. "-Wundef",
  532. }
  533. linkoptions {
  534. "-Wl,--gc-sections",
  535. "-static",
  536. "-static-libgcc",
  537. "-static-libstdc++",
  538. }
  539. configuration { "x32", "mingw-gcc" }
  540. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  541. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  542. libdirs {
  543. path.join(_libDir, "lib/win32_mingw-gcc"),
  544. }
  545. buildoptions {
  546. "-m32",
  547. "-mstackrealign",
  548. }
  549. configuration { "x64", "mingw-gcc" }
  550. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  551. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  552. libdirs {
  553. path.join(_libDir, "lib/win64_mingw-gcc"),
  554. }
  555. buildoptions { "-m64" }
  556. configuration { "mingw-clang" }
  557. buildoptions {
  558. "-isystem $(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  559. "-isystem $(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  560. "-isystem $(MINGW)/x86_64-w64-mingw32/include",
  561. }
  562. linkoptions {
  563. "-Qunused-arguments",
  564. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  565. }
  566. configuration { "x32", "mingw-clang" }
  567. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  568. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  569. libdirs {
  570. path.join(_libDir, "lib/win32_mingw-clang"),
  571. }
  572. buildoptions { "-m32" }
  573. configuration { "x64", "mingw-clang" }
  574. targetdir (path.join(_buildDir, "win64_mingw-clang/bin"))
  575. objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
  576. libdirs {
  577. path.join(_libDir, "lib/win64_mingw-clang"),
  578. }
  579. buildoptions { "-m64" }
  580. configuration { "linux-clang" }
  581. configuration { "linux-gcc-6" }
  582. buildoptions {
  583. -- "-fno-omit-frame-pointer",
  584. -- "-fsanitize=address",
  585. -- "-fsanitize=undefined",
  586. -- "-fsanitize=float-divide-by-zero",
  587. -- "-fsanitize=float-cast-overflow",
  588. }
  589. links {
  590. -- "asan",
  591. -- "ubsan",
  592. }
  593. configuration { "linux-gcc" }
  594. buildoptions {
  595. "-mfpmath=sse",
  596. }
  597. configuration { "linux-gcc* or linux-clang*" }
  598. buildoptions {
  599. "-msse2",
  600. -- "-Wdouble-promotion",
  601. -- "-Wduplicated-branches",
  602. -- "-Wduplicated-cond",
  603. -- "-Wjump-misses-init",
  604. "-Wshadow",
  605. -- "-Wnull-dereference",
  606. "-Wunused-value",
  607. "-Wundef",
  608. -- "-Wuseless-cast",
  609. }
  610. links {
  611. "rt",
  612. "dl",
  613. }
  614. linkoptions {
  615. "-Wl,--gc-sections",
  616. "-Wl,--as-needed",
  617. }
  618. configuration { "linux-gcc*" }
  619. buildoptions {
  620. "-Wlogical-op",
  621. }
  622. configuration { "linux-gcc*", "x32" }
  623. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  624. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  625. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  626. buildoptions {
  627. "-m32",
  628. }
  629. configuration { "linux-gcc*", "x64" }
  630. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  631. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  632. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  633. buildoptions {
  634. "-m64",
  635. }
  636. configuration { "linux-clang*", "x32" }
  637. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  638. objdir (path.join(_buildDir, "linux32_clang/obj"))
  639. libdirs { path.join(_libDir, "lib/linux32_clang") }
  640. buildoptions {
  641. "-m32",
  642. }
  643. configuration { "linux-clang*", "x64" }
  644. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  645. objdir (path.join(_buildDir, "linux64_clang/obj"))
  646. libdirs { path.join(_libDir, "lib/linux64_clang") }
  647. buildoptions {
  648. "-m64",
  649. }
  650. configuration { "linux-mips-gcc" }
  651. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  652. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  653. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  654. buildoptions {
  655. "-Wunused-value",
  656. "-Wundef",
  657. }
  658. links {
  659. "rt",
  660. "dl",
  661. }
  662. linkoptions {
  663. "-Wl,--gc-sections",
  664. }
  665. configuration { "linux-arm-gcc" }
  666. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  667. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  668. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  669. buildoptions {
  670. "-Wunused-value",
  671. "-Wundef",
  672. }
  673. links {
  674. "rt",
  675. "dl",
  676. }
  677. linkoptions {
  678. "-Wl,--gc-sections",
  679. }
  680. configuration { "android-*" }
  681. targetprefix ("lib")
  682. flags {
  683. "NoImportLib",
  684. }
  685. includedirs {
  686. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/include",
  687. "${ANDROID_NDK_ROOT}/sysroot/usr/include",
  688. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  689. }
  690. linkoptions {
  691. "-nostdlib",
  692. }
  693. links {
  694. "c",
  695. "dl",
  696. "m",
  697. "android",
  698. "log",
  699. "c++_shared",
  700. "gcc",
  701. }
  702. buildoptions {
  703. "-fPIC",
  704. "-no-canonical-prefixes",
  705. "-Wa,--noexecstack",
  706. "-fstack-protector-strong",
  707. "-ffunction-sections",
  708. "-Wunused-value",
  709. "-Wundef",
  710. }
  711. linkoptions {
  712. "-no-canonical-prefixes",
  713. "-Wl,--no-undefined",
  714. "-Wl,-z,noexecstack",
  715. "-Wl,-z,relro",
  716. "-Wl,-z,now",
  717. }
  718. configuration { "android-arm" }
  719. targetdir (path.join(_buildDir, "android-arm/bin"))
  720. objdir (path.join(_buildDir, "android-arm/obj"))
  721. libdirs {
  722. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a",
  723. }
  724. includedirs {
  725. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/arm-linux-androideabi",
  726. }
  727. buildoptions {
  728. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  729. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  730. "-target armv7-none-linux-androideabi",
  731. "-mthumb",
  732. "-march=armv7-a",
  733. "-mfloat-abi=softfp",
  734. "-mfpu=neon",
  735. "-Wunused-value",
  736. "-Wundef",
  737. }
  738. linkoptions {
  739. "-gcc-toolchain $(ANDROID_NDK_ARM)",
  740. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  741. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  742. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  743. "-target armv7-none-linux-androideabi",
  744. "-march=armv7-a",
  745. }
  746. configuration { "android-arm64" }
  747. targetdir (path.join(_buildDir, "android-arm64/bin"))
  748. objdir (path.join(_buildDir, "android-arm64/obj"))
  749. libdirs {
  750. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/arm64-v8a",
  751. }
  752. includedirs {
  753. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/aarch64-linux-android",
  754. }
  755. buildoptions {
  756. "-gcc-toolchain $(ANDROID_NDK_ARM64)",
  757. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
  758. "-target aarch64-none-linux-androideabi",
  759. "-march=armv8-a",
  760. "-Wunused-value",
  761. "-Wundef",
  762. }
  763. linkoptions {
  764. "-gcc-toolchain $(ANDROID_NDK_ARM64)",
  765. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64"),
  766. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtbegin_so.o"),
  767. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm64/usr/lib/crtend_so.o"),
  768. "-target aarch64-none-linux-androideabi",
  769. "-march=armv8-a",
  770. }
  771. configuration { "android-x86" }
  772. targetdir (path.join(_buildDir, "android-x86/bin"))
  773. objdir (path.join(_buildDir, "android-x86/obj"))
  774. libdirs {
  775. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/x86",
  776. }
  777. includedirs {
  778. "$(ANDROID_NDK_ROOT)/sysroot/usr/include/x86_64-linux-android",
  779. }
  780. buildoptions {
  781. "-gcc-toolchain $(ANDROID_NDK_X86)",
  782. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  783. "-target i686-none-linux-android",
  784. "-march=i686",
  785. "-mtune=atom",
  786. "-mstackrealign",
  787. "-msse3",
  788. "-mfpmath=sse",
  789. "-Wunused-value",
  790. "-Wundef",
  791. }
  792. linkoptions {
  793. "-gcc-toolchain $(ANDROID_NDK_X86)",
  794. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  795. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  796. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtend_so.o"),
  797. "-target i686-none-linux-android",
  798. }
  799. configuration { "wasm*" }
  800. buildoptions {
  801. "-Wunused-value",
  802. "-Wundef",
  803. }
  804. linkoptions {
  805. "-s MAX_WEBGL_VERSION=2"
  806. }
  807. configuration { "wasm2js" }
  808. targetdir (path.join(_buildDir, "wasm2js/bin"))
  809. objdir (path.join(_buildDir, "wasm2js/obj"))
  810. libdirs { path.join(_libDir, "lib/wasm2js") }
  811. linkoptions {
  812. "-s WASM=0"
  813. }
  814. configuration { "wasm" }
  815. targetdir (path.join(_buildDir, "wasm/bin"))
  816. objdir (path.join(_buildDir, "wasm/obj"))
  817. libdirs { path.join(_libDir, "lib/wasm") }
  818. configuration { "freebsd" }
  819. targetdir (path.join(_buildDir, "freebsd/bin"))
  820. objdir (path.join(_buildDir, "freebsd/obj"))
  821. libdirs { path.join(_libDir, "lib/freebsd") }
  822. includedirs {
  823. path.join(bxDir, "include/compat/freebsd"),
  824. }
  825. configuration { "xbox360" }
  826. targetdir (path.join(_buildDir, "xbox360/bin"))
  827. objdir (path.join(_buildDir, "xbox360/obj"))
  828. includedirs { path.join(bxDir, "include/compat/msvc") }
  829. libdirs { path.join(_libDir, "lib/xbox360") }
  830. defines {
  831. "NOMINMAX",
  832. }
  833. configuration { "durango" }
  834. targetdir (path.join(_buildDir, "durango/bin"))
  835. objdir (path.join(_buildDir, "durango/obj"))
  836. includedirs { path.join(bxDir, "include/compat/msvc") }
  837. libdirs { path.join(_libDir, "lib/durango") }
  838. removeflags { "StaticRuntime" }
  839. defines {
  840. "NOMINMAX",
  841. }
  842. configuration { "netbsd" }
  843. targetdir (path.join(_buildDir, "netbsd/bin"))
  844. objdir (path.join(_buildDir, "netbsd/obj"))
  845. libdirs { path.join(_libDir, "lib/netbsd") }
  846. includedirs {
  847. path.join(bxDir, "include/compat/freebsd"),
  848. }
  849. configuration { "osx-x64" }
  850. targetdir (path.join(_buildDir, "osx-x64/bin"))
  851. objdir (path.join(_buildDir, "osx-x64/obj"))
  852. linkoptions {
  853. "-arch x86_64",
  854. }
  855. buildoptions {
  856. "-arch x86_64",
  857. "-msse2",
  858. "-target x86_64-apple-macos" .. (#macosPlatform > 0 and macosPlatform or "10.11"),
  859. }
  860. configuration { "osx-arm64" }
  861. targetdir (path.join(_buildDir, "osx-arm64/bin"))
  862. objdir (path.join(_buildDir, "osx-arm64/obj"))
  863. linkoptions {
  864. "-arch arm64",
  865. }
  866. buildoptions {
  867. "-arch arm64",
  868. "-Wno-error=unused-command-line-argument",
  869. "-Wno-unused-command-line-argument",
  870. }
  871. configuration { "osx*" }
  872. buildoptions {
  873. "-Wfatal-errors",
  874. "-Wunused-value",
  875. "-Wundef",
  876. }
  877. includedirs { path.join(bxDir, "include/compat/osx") }
  878. configuration { "ios*" }
  879. linkoptions {
  880. "-lc++",
  881. }
  882. buildoptions {
  883. "-Wfatal-errors",
  884. "-Wunused-value",
  885. "-Wundef",
  886. }
  887. includedirs { path.join(bxDir, "include/compat/ios") }
  888. configuration { "xcode*", "ios*" }
  889. targetdir (path.join(_buildDir, "ios-arm/bin"))
  890. objdir (path.join(_buildDir, "ios-arm/obj"))
  891. configuration { "ios-arm" }
  892. targetdir (path.join(_buildDir, "ios-arm/bin"))
  893. objdir (path.join(_buildDir, "ios-arm/obj"))
  894. libdirs { path.join(_libDir, "lib/ios-arm") }
  895. linkoptions {
  896. "-arch armv7",
  897. }
  898. buildoptions {
  899. "-arch armv7",
  900. }
  901. configuration { "ios-arm64" }
  902. targetdir (path.join(_buildDir, "ios-arm64/bin"))
  903. objdir (path.join(_buildDir, "ios-arm64/obj"))
  904. libdirs { path.join(_libDir, "lib/ios-arm64") }
  905. linkoptions {
  906. "-arch arm64",
  907. }
  908. buildoptions {
  909. "-arch arm64",
  910. }
  911. configuration { "ios-arm*" }
  912. linkoptions {
  913. "-miphoneos-version-min=9.0",
  914. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  915. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  916. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  917. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  918. }
  919. buildoptions {
  920. "-miphoneos-version-min=9.0",
  921. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  922. "-fembed-bitcode",
  923. }
  924. configuration { "ios-simulator" }
  925. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  926. objdir (path.join(_buildDir, "ios-simulator/obj"))
  927. libdirs { path.join(_libDir, "lib/ios-simulator") }
  928. linkoptions {
  929. "-mios-simulator-version-min=9.0",
  930. "-arch i386",
  931. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  932. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  933. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  934. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  935. }
  936. buildoptions {
  937. "-mios-simulator-version-min=9.0",
  938. "-arch i386",
  939. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  940. }
  941. configuration { "ios-simulator64" }
  942. targetdir (path.join(_buildDir, "ios-simulator64/bin"))
  943. objdir (path.join(_buildDir, "ios-simulator64/obj"))
  944. libdirs { path.join(_libDir, "lib/ios-simulator64") }
  945. linkoptions {
  946. "-mios-simulator-version-min=9.0",
  947. "-arch x86_64",
  948. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  949. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  950. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  951. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  952. }
  953. buildoptions {
  954. "-mios-simulator-version-min=9.0",
  955. "-arch x86_64",
  956. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  957. }
  958. configuration { "tvos*" }
  959. linkoptions {
  960. "-lc++",
  961. }
  962. buildoptions {
  963. "-Wfatal-errors",
  964. "-Wunused-value",
  965. "-Wundef",
  966. }
  967. includedirs { path.join(bxDir, "include/compat/ios") }
  968. configuration { "xcode*", "tvos*" }
  969. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  970. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  971. configuration { "tvos-arm64" }
  972. targetdir (path.join(_buildDir, "tvos-arm64/bin"))
  973. objdir (path.join(_buildDir, "tvos-arm64/obj"))
  974. libdirs { path.join(_libDir, "lib/tvos-arm64") }
  975. linkoptions {
  976. "-mtvos-version-min=9.0",
  977. "-arch arm64",
  978. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  979. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/usr/lib/system",
  980. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  981. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  982. }
  983. buildoptions {
  984. "-mtvos-version-min=9.0",
  985. "-arch arm64",
  986. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS" ..tvosPlatform .. ".sdk",
  987. }
  988. configuration { "tvos-simulator" }
  989. targetdir (path.join(_buildDir, "tvos-simulator/bin"))
  990. objdir (path.join(_buildDir, "tvos-simulator/obj"))
  991. libdirs { path.join(_libDir, "lib/tvos-simulator") }
  992. linkoptions {
  993. "-mtvos-simulator-version-min=9.0",
  994. "-arch i386",
  995. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  996. "-L/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/usr/lib/system",
  997. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/Frameworks",
  998. "-F/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  999. }
  1000. buildoptions {
  1001. "-mtvos-simulator-version-min=9.0",
  1002. "-arch i386",
  1003. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator" ..tvosPlatform .. ".sdk",
  1004. }
  1005. configuration { "orbis" }
  1006. targetdir (path.join(_buildDir, "orbis/bin"))
  1007. objdir (path.join(_buildDir, "orbis/obj"))
  1008. libdirs { path.join(_libDir, "lib/orbis") }
  1009. includedirs {
  1010. path.join(bxDir, "include/compat/freebsd"),
  1011. "$(SCE_ORBIS_SDK_DIR)/target/include",
  1012. "$(SCE_ORBIS_SDK_DIR)/target/include_common",
  1013. }
  1014. configuration { "rpi" }
  1015. targetdir (path.join(_buildDir, "rpi/bin"))
  1016. objdir (path.join(_buildDir, "rpi/obj"))
  1017. libdirs {
  1018. path.join(_libDir, "lib/rpi"),
  1019. "/opt/vc/lib",
  1020. }
  1021. defines {
  1022. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  1023. "__STDC_VERSION__=199901L",
  1024. }
  1025. buildoptions {
  1026. "-Wunused-value",
  1027. "-Wundef",
  1028. }
  1029. includedirs {
  1030. "/opt/vc/include",
  1031. "/opt/vc/include/interface/vcos/pthreads",
  1032. "/opt/vc/include/interface/vmcs_host/linux",
  1033. }
  1034. links {
  1035. "rt",
  1036. "dl",
  1037. }
  1038. linkoptions {
  1039. "-Wl,--gc-sections",
  1040. }
  1041. configuration { "riscv" }
  1042. targetdir (path.join(_buildDir, "riscv/bin"))
  1043. objdir (path.join(_buildDir, "riscv/obj"))
  1044. defines {
  1045. "__BSD_VISIBLE",
  1046. "__MISC_VISIBLE",
  1047. }
  1048. includedirs {
  1049. "$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf/include",
  1050. path.join(bxDir, "include/compat/riscv"),
  1051. }
  1052. buildoptions {
  1053. "-Wunused-value",
  1054. "-Wundef",
  1055. "--sysroot=$(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/riscv64-unknown-elf",
  1056. }
  1057. configuration {} -- reset configuration
  1058. return true
  1059. end
  1060. function strip()
  1061. configuration { "android-arm", "Release" }
  1062. postbuildcommands {
  1063. "$(SILENT) echo Stripping symbols.",
  1064. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  1065. }
  1066. configuration { "android-arm64", "Release" }
  1067. postbuildcommands {
  1068. "$(SILENT) echo Stripping symbols.",
  1069. "$(SILENT) $(ANDROID_NDK_ARM64)/bin/aarch64-linux-android-strip -s \"$(TARGET)\""
  1070. }
  1071. configuration { "android-x86", "Release" }
  1072. postbuildcommands {
  1073. "$(SILENT) echo Stripping symbols.",
  1074. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  1075. }
  1076. configuration { "linux-* or rpi", "Release" }
  1077. postbuildcommands {
  1078. "$(SILENT) echo Stripping symbols.",
  1079. "$(SILENT) strip -s \"$(TARGET)\""
  1080. }
  1081. configuration { "mingw*", "Release" }
  1082. postbuildcommands {
  1083. "$(SILENT) echo Stripping symbols.",
  1084. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  1085. }
  1086. configuration { "riscv" }
  1087. postbuildcommands {
  1088. "$(SILENT) echo Stripping symbols.",
  1089. "$(SILENT) $(FREEDOM_E_SDK)/work/build/riscv-gnu-toolchain/riscv64-unknown-elf/prefix/bin/riscv64-unknown-elf-strip -s \"$(TARGET)\""
  1090. }
  1091. configuration {} -- reset configuration
  1092. end