toolchain.lua 39 KB

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