toolchain.lua 37 KB

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