toolchain.lua 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046
  1. --
  2. -- Copyright 2010-2015 Branimir Karadzic. All rights reserved.
  3. -- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
  4. --
  5. local bxDir = path.getabsolute("..")
  6. local naclToolchain = ""
  7. function toolchain(_buildDir, _libDir)
  8. newoption {
  9. trigger = "gcc",
  10. value = "GCC",
  11. description = "Choose GCC flavor",
  12. allowed = {
  13. { "android-arm", "Android - ARM" },
  14. { "android-mips", "Android - MIPS" },
  15. { "android-x86", "Android - x86" },
  16. { "asmjs", "Emscripten/asm.js" },
  17. { "freebsd", "FreeBSD" },
  18. { "linux-gcc", "Linux (GCC compiler)" },
  19. { "linux-gcc-5", "Linux (GCC-5 compiler)" },
  20. { "linux-clang", "Linux (Clang compiler)" },
  21. { "linux-mips-gcc", "Linux (MIPS, GCC compiler)" },
  22. { "linux-arm-gcc", "Linux (ARM, GCC compiler)" },
  23. { "ios-arm", "iOS - ARM" },
  24. { "ios-simulator", "iOS - Simulator" },
  25. { "mingw-gcc", "MinGW" },
  26. { "mingw-clang", "MinGW (clang compiler)" },
  27. { "nacl", "Native Client" },
  28. { "nacl-arm", "Native Client - ARM" },
  29. { "osx", "OSX" },
  30. { "pnacl", "Native Client - PNaCl" },
  31. { "ps4", "PS4" },
  32. { "qnx-arm", "QNX/Blackberry - ARM" },
  33. { "rpi", "RaspberryPi" },
  34. },
  35. }
  36. newoption {
  37. trigger = "vs",
  38. value = "toolset",
  39. description = "Choose VS toolset",
  40. allowed = {
  41. { "vs2012-clang", "Clang 3.6" },
  42. { "vs2013-clang", "Clang 3.6" },
  43. { "vs2012-xp", "Visual Studio 2012 targeting XP" },
  44. { "vs2013-xp", "Visual Studio 2013 targeting XP" },
  45. { "vs2015-xp", "Visual Studio 2015 targeting XP" },
  46. { "winphone8", "Windows Phone 8.0" },
  47. { "winphone81", "Windows Phone 8.1" },
  48. { "winstore81", "Windows Store 8.1" },
  49. { "winstore82", "Universal Windows App" },
  50. },
  51. }
  52. newoption {
  53. trigger = "xcode",
  54. value = "xcode_target",
  55. description = "Choose XCode target",
  56. allowed = {
  57. { "osx", "OSX" },
  58. { "ios", "iOS" },
  59. }
  60. }
  61. newoption {
  62. trigger = "with-android",
  63. value = "#",
  64. description = "Set Android platform version (default: android-14).",
  65. }
  66. newoption {
  67. trigger = "with-ios",
  68. value = "#",
  69. description = "Set iOS target version (default: 8.0).",
  70. }
  71. -- Avoid error when invoking genie --help.
  72. if (_ACTION == nil) then return false end
  73. location (path.join(_buildDir, "projects", _ACTION))
  74. if _ACTION == "clean" then
  75. os.rmdir(BUILD_DIR)
  76. end
  77. local androidPlatform = "android-14"
  78. if _OPTIONS["with-android"] then
  79. androidPlatform = "android-" .. _OPTIONS["with-android"]
  80. end
  81. local iosPlatform = ""
  82. if _OPTIONS["with-ios"] then
  83. iosPlatform = _OPTIONS["with-ios"]
  84. end
  85. if _ACTION == "gmake" then
  86. if nil == _OPTIONS["gcc"] then
  87. print("GCC flavor must be specified!")
  88. os.exit(1)
  89. end
  90. flags {
  91. "ExtraWarnings",
  92. }
  93. if "android-arm" == _OPTIONS["gcc"] then
  94. if not os.getenv("ANDROID_NDK_ARM") or not os.getenv("ANDROID_NDK_ROOT") then
  95. print("Set ANDROID_NDK_ARM and ANDROID_NDK_ROOT envrionment variables.")
  96. end
  97. premake.gcc.cc = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-gcc"
  98. premake.gcc.cxx = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-g++"
  99. premake.gcc.ar = "$(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-ar"
  100. location (path.join(_buildDir, "projects", _ACTION .. "-android-arm"))
  101. elseif "android-mips" == _OPTIONS["gcc"] then
  102. if not os.getenv("ANDROID_NDK_MIPS") or not os.getenv("ANDROID_NDK_ROOT") then
  103. print("Set ANDROID_NDK_MIPS and ANDROID_NDK_ROOT envrionment variables.")
  104. end
  105. premake.gcc.cc = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-gcc"
  106. premake.gcc.cxx = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-g++"
  107. premake.gcc.ar = "$(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-ar"
  108. location (path.join(_buildDir, "projects", _ACTION .. "-android-mips"))
  109. elseif "android-x86" == _OPTIONS["gcc"] then
  110. if not os.getenv("ANDROID_NDK_X86") or not os.getenv("ANDROID_NDK_ROOT") then
  111. print("Set ANDROID_NDK_X86 and ANDROID_NDK_ROOT envrionment variables.")
  112. end
  113. premake.gcc.cc = "$(ANDROID_NDK_X86)/bin/i686-linux-android-gcc"
  114. premake.gcc.cxx = "$(ANDROID_NDK_X86)/bin/i686-linux-android-g++"
  115. premake.gcc.ar = "$(ANDROID_NDK_X86)/bin/i686-linux-android-ar"
  116. location (path.join(_buildDir, "projects", _ACTION .. "-android-x86"))
  117. elseif "asmjs" == _OPTIONS["gcc"] then
  118. if not os.getenv("EMSCRIPTEN") then
  119. print("Set EMSCRIPTEN enviroment variables.")
  120. end
  121. premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
  122. premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
  123. premake.gcc.ar = "$(EMSCRIPTEN)/emar"
  124. premake.gcc.llvm = true
  125. location (path.join(_buildDir, "projects", _ACTION .. "-asmjs"))
  126. elseif "freebsd" == _OPTIONS["gcc"] then
  127. location (path.join(_buildDir, "projects", _ACTION .. "-freebsd"))
  128. elseif "ios-arm" == _OPTIONS["gcc"] then
  129. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  130. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  131. premake.gcc.ar = "ar"
  132. location (path.join(_buildDir, "projects", _ACTION .. "-ios-arm"))
  133. elseif "ios-simulator" == _OPTIONS["gcc"] then
  134. premake.gcc.cc = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
  135. premake.gcc.cxx = "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"
  136. premake.gcc.ar = "ar"
  137. location (path.join(_buildDir, "projects", _ACTION .. "-ios-simulator"))
  138. elseif "linux-gcc" == _OPTIONS["gcc"] then
  139. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  140. elseif "linux-gcc-5" == _OPTIONS["gcc"] then
  141. premake.gcc.cc = "gcc-5"
  142. premake.gcc.cxx = "g++-5"
  143. premake.gcc.ar = "ar"
  144. location (path.join(_buildDir, "projects", _ACTION .. "-linux"))
  145. elseif "linux-clang" == _OPTIONS["gcc"] then
  146. premake.gcc.cc = "clang"
  147. premake.gcc.cxx = "clang++"
  148. premake.gcc.ar = "ar"
  149. location (path.join(_buildDir, "projects", _ACTION .. "-linux-clang"))
  150. elseif "linux-mips-gcc" == _OPTIONS["gcc"] then
  151. location (path.join(_buildDir, "projects", _ACTION .. "-linux-mips-gcc"))
  152. elseif "linux-arm-gcc" == _OPTIONS["gcc"] then
  153. location (path.join(_buildDir, "projects", _ACTION .. "-linux-arm-gcc"))
  154. elseif "mingw-gcc" == _OPTIONS["gcc"] then
  155. premake.gcc.cc = "$(MINGW)/bin/x86_64-w64-mingw32-gcc"
  156. premake.gcc.cxx = "$(MINGW)/bin/x86_64-w64-mingw32-g++"
  157. premake.gcc.ar = "$(MINGW)/bin/ar"
  158. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-gcc"))
  159. elseif "mingw-clang" == _OPTIONS["gcc"] then
  160. premake.gcc.cc = "$(CLANG)/bin/clang"
  161. premake.gcc.cxx = "$(CLANG)/bin/clang++"
  162. premake.gcc.ar = "$(MINGW)/bin/ar"
  163. -- premake.gcc.ar = "$(CLANG)/bin/llvm-ar"
  164. -- premake.gcc.llvm = true
  165. location (path.join(_buildDir, "projects", _ACTION .. "-mingw-clang"))
  166. elseif "nacl" == _OPTIONS["gcc"] then
  167. if not os.getenv("NACL_SDK_ROOT") then
  168. print("Set NACL_SDK_ROOT enviroment variables.")
  169. end
  170. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_x86_newlib/bin/x86_64-nacl-"
  171. if os.is("macosx") then
  172. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_x86_newlib/bin/x86_64-nacl-"
  173. elseif os.is("linux") then
  174. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_x86_newlib/bin/x86_64-nacl-"
  175. end
  176. premake.gcc.cc = naclToolchain .. "gcc"
  177. premake.gcc.cxx = naclToolchain .. "g++"
  178. premake.gcc.ar = naclToolchain .. "ar"
  179. location (path.join(_buildDir, "projects", _ACTION .. "-nacl"))
  180. elseif "nacl-arm" == _OPTIONS["gcc"] then
  181. if not os.getenv("NACL_SDK_ROOT") then
  182. print("Set NACL_SDK_ROOT enviroment variables.")
  183. end
  184. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_arm_newlib/bin/arm-nacl-"
  185. if os.is("macosx") then
  186. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_arm_newlib/bin/arm-nacl-"
  187. elseif os.is("linux") then
  188. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_arm_newlib/bin/arm-nacl-"
  189. end
  190. premake.gcc.cc = naclToolchain .. "gcc"
  191. premake.gcc.cxx = naclToolchain .. "g++"
  192. premake.gcc.ar = naclToolchain .. "ar"
  193. location (path.join(_buildDir, "projects", _ACTION .. "-nacl-arm"))
  194. elseif "osx" == _OPTIONS["gcc"] then
  195. if os.is("linux") then
  196. local osxToolchain = "x86_64-apple-darwin13-"
  197. premake.gcc.cc = osxToolchain .. "clang"
  198. premake.gcc.cxx = osxToolchain .. "clang++"
  199. premake.gcc.ar = osxToolchain .. "ar"
  200. end
  201. location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
  202. elseif "pnacl" == _OPTIONS["gcc"] then
  203. if not os.getenv("NACL_SDK_ROOT") then
  204. print("Set NACL_SDK_ROOT enviroment variables.")
  205. end
  206. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/win_pnacl/bin/pnacl-"
  207. if os.is("macosx") then
  208. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/mac_pnacl/bin/pnacl-"
  209. elseif os.is("linux") then
  210. naclToolchain = "$(NACL_SDK_ROOT)/toolchain/linux_pnacl/bin/pnacl-"
  211. end
  212. premake.gcc.cc = naclToolchain .. "clang"
  213. premake.gcc.cxx = naclToolchain .. "clang++"
  214. premake.gcc.ar = naclToolchain .. "ar"
  215. location (path.join(_buildDir, "projects", _ACTION .. "-pnacl"))
  216. elseif "ps4" == _OPTIONS["gcc"] then
  217. if not os.getenv("PS4_SDK_ROOT") then
  218. print("Set PS4_SDK_ROOT enviroment variables.")
  219. end
  220. ps4Toolchain = "$(PS4_SDK_ROOT)/host_tools/bin/orbis-"
  221. premake.gcc.cc = ps4Toolchain .. "clang"
  222. premake.gcc.cxx = ps4Toolchain .. "clang++"
  223. premake.gcc.ar = ps4Toolchain .. "ar"
  224. location (path.join(_buildDir, "projects", _ACTION .. "-ps4"))
  225. elseif "qnx-arm" == _OPTIONS["gcc"] then
  226. if not os.getenv("QNX_HOST") then
  227. print("Set QNX_HOST enviroment variables.")
  228. end
  229. premake.gcc.cc = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-gcc"
  230. premake.gcc.cxx = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-g++"
  231. premake.gcc.ar = "$(QNX_HOST)/usr/bin/arm-unknown-nto-qnx8.0.0eabi-ar"
  232. location (path.join(_buildDir, "projects", _ACTION .. "-qnx-arm"))
  233. elseif "rpi" == _OPTIONS["gcc"] then
  234. location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
  235. end
  236. elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
  237. if (_ACTION .. "-clang") == _OPTIONS["vs"] then
  238. premake.vstudio.toolset = ("LLVM-" .. _ACTION)
  239. location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
  240. elseif "winphone8" == _OPTIONS["vs"] then
  241. premake.vstudio.toolset = "v110_wp80"
  242. location (path.join(_buildDir, "projects", _ACTION .. "-winphone8"))
  243. elseif "winphone81" == _OPTIONS["vs"] then
  244. premake.vstudio.toolset = "v120_wp81"
  245. premake.vstudio.storeapp = "8.1"
  246. platforms { "ARM" }
  247. location (path.join(_buildDir, "projects", _ACTION .. "-winphone81"))
  248. elseif "winstore81" == _OPTIONS["vs"] then
  249. premake.vstudio.toolset = "v120"
  250. premake.vstudio.storeapp = "8.1"
  251. platforms { "ARM" }
  252. location (path.join(_buildDir, "projects", _ACTION .. "-winstore81"))
  253. elseif "winstore82" == _OPTIONS["vs"] then
  254. premake.vstudio.toolset = "v140"
  255. premake.vstudio.storeapp = "8.2"
  256. platforms { "ARM" }
  257. location (path.join(_buildDir, "projects", _ACTION .. "-winstore82"))
  258. elseif ("vs2012-xp") == _OPTIONS["vs"] then
  259. premake.vstudio.toolset = ("v110_xp")
  260. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  261. elseif ("vs2013-xp") == _OPTIONS["vs"] then
  262. premake.vstudio.toolset = ("v120_xp")
  263. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  264. elseif ("vs2015-xp") == _OPTIONS["vs"] then
  265. premake.vstudio.toolset = ("v140_xp")
  266. location (path.join(_buildDir, "projects", _ACTION .. "-xp"))
  267. end
  268. elseif _ACTION == "xcode4" then
  269. if "osx" == _OPTIONS["xcode"] then
  270. premake.xcode.toolset = "macosx"
  271. location (path.join(_buildDir, "projects", _ACTION .. "-osx"))
  272. elseif "ios" == _OPTIONS["xcode"] then
  273. premake.xcode.toolset = "iphoneos"
  274. location (path.join(_buildDir, "projects", _ACTION .. "-ios"))
  275. end
  276. end
  277. flags {
  278. "StaticRuntime",
  279. "NoPCH",
  280. "NativeWChar",
  281. "NoRTTI",
  282. "NoExceptions",
  283. "NoEditAndContinue",
  284. "Symbols",
  285. }
  286. defines {
  287. "__STDC_LIMIT_MACROS",
  288. "__STDC_FORMAT_MACROS",
  289. "__STDC_CONSTANT_MACROS",
  290. }
  291. configuration { "Debug" }
  292. targetsuffix "Debug"
  293. configuration { "Release" }
  294. flags {
  295. "OptimizeSpeed",
  296. }
  297. targetsuffix "Release"
  298. configuration { "vs*", "x32" }
  299. flags {
  300. "EnableSSE2",
  301. }
  302. configuration { "vs*" }
  303. includedirs { path.join(bxDir, "include/compat/msvc") }
  304. defines {
  305. "WIN32",
  306. "_WIN32",
  307. "_HAS_EXCEPTIONS=0",
  308. "_HAS_ITERATOR_DEBUGGING=0",
  309. "_SCL_SECURE=0",
  310. "_SECURE_SCL=0",
  311. "_SCL_SECURE_NO_WARNINGS",
  312. "_CRT_SECURE_NO_WARNINGS",
  313. "_CRT_SECURE_NO_DEPRECATE",
  314. }
  315. buildoptions {
  316. "/Oy-", -- Suppresses creation of frame pointers on the call stack.
  317. "/Ob2", -- The Inline Function Expansion
  318. }
  319. linkoptions {
  320. "/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
  321. }
  322. configuration { "vs2008" }
  323. includedirs { path.join(bxDir, "include/compat/msvc/pre1600") }
  324. configuration { "x32", "vs*" }
  325. targetdir (path.join(_buildDir, "win32_" .. _ACTION, "bin"))
  326. objdir (path.join(_buildDir, "win32_" .. _ACTION, "obj"))
  327. libdirs {
  328. path.join(_libDir, "lib/win32_" .. _ACTION),
  329. "$(DXSDK_DIR)/lib/x86",
  330. }
  331. configuration { "x64", "vs*" }
  332. defines { "_WIN64" }
  333. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  334. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  335. libdirs {
  336. path.join(_libDir, "lib/win64_" .. _ACTION),
  337. "$(DXSDK_DIR)/lib/x64",
  338. }
  339. configuration { "ARM", "vs*" }
  340. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  341. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  342. configuration { "vs*-clang" }
  343. buildoptions {
  344. "-Qunused-arguments",
  345. }
  346. configuration { "x32", "vs*-clang" }
  347. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  348. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  349. configuration { "x64", "vs*-clang" }
  350. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  351. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  352. configuration { "winphone8* or winstore8*" }
  353. removeflags {
  354. "StaticRuntime",
  355. "NoExceptions",
  356. }
  357. configuration { "*-gcc* or osx" }
  358. buildoptions {
  359. "-Wshadow",
  360. }
  361. configuration { "mingw-*" }
  362. defines { "WIN32" }
  363. includedirs { path.join(bxDir, "include/compat/mingw") }
  364. buildoptions {
  365. "-Wunused-value",
  366. "-fdata-sections",
  367. "-ffunction-sections",
  368. "-msse2",
  369. "-Wunused-value",
  370. "-Wundef",
  371. }
  372. buildoptions_cpp {
  373. "-std=c++0x",
  374. }
  375. linkoptions {
  376. "-Wl,--gc-sections",
  377. "-static-libgcc",
  378. "-static-libstdc++",
  379. }
  380. configuration { "x32", "mingw-gcc" }
  381. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  382. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  383. libdirs {
  384. path.join(_libDir, "lib/win32_mingw-gcc"),
  385. "$(DXSDK_DIR)/lib/x86",
  386. }
  387. buildoptions { "-m32" }
  388. configuration { "x64", "mingw-gcc" }
  389. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  390. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  391. libdirs {
  392. path.join(_libDir, "lib/win64_mingw-gcc"),
  393. "$(DXSDK_DIR)/lib/x64",
  394. "$(GLES_X64_DIR)",
  395. }
  396. buildoptions { "-m64" }
  397. configuration { "mingw-clang" }
  398. buildoptions {
  399. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  400. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  401. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  402. }
  403. linkoptions {
  404. "-Qunused-arguments",
  405. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  406. }
  407. configuration { "x32", "mingw-clang" }
  408. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  409. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  410. libdirs {
  411. path.join(_libDir, "lib/win32_mingw-clang"),
  412. "$(DXSDK_DIR)/lib/x86",
  413. }
  414. buildoptions { "-m32" }
  415. configuration { "x64", "mingw-clang" }
  416. targetdir (path.join(_buildDir, "win64_mingw-clang/bin"))
  417. objdir (path.join(_buildDir, "win64_mingw-clang/obj"))
  418. libdirs {
  419. path.join(_libDir, "lib/win64_mingw-clang"),
  420. "$(DXSDK_DIR)/lib/x64",
  421. "$(GLES_X64_DIR)",
  422. }
  423. buildoptions { "-m64" }
  424. configuration { "linux-clang" }
  425. configuration { "linux-gcc-5" }
  426. buildoptions {
  427. -- "-fno-omit-frame-pointer",
  428. -- "-fsanitize=address",
  429. -- "-fsanitize=undefined",
  430. -- "-fsanitize=float-divide-by-zero",
  431. -- "-fsanitize=float-cast-overflow",
  432. }
  433. links {
  434. -- "asan",
  435. -- "ubsan",
  436. }
  437. configuration { "linux-gcc" }
  438. buildoptions {
  439. "-mfpmath=sse",
  440. }
  441. configuration { "linux-gcc or linux-clang" }
  442. buildoptions {
  443. "-msse2",
  444. "-Wunused-value",
  445. "-Wundef",
  446. }
  447. buildoptions_cpp {
  448. "-std=c++0x",
  449. }
  450. links {
  451. "rt",
  452. "dl",
  453. }
  454. linkoptions {
  455. "-Wl,--gc-sections",
  456. }
  457. configuration { "linux-gcc*", "x32" }
  458. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  459. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  460. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  461. buildoptions {
  462. "-m32",
  463. }
  464. configuration { "linux-gcc*", "x64" }
  465. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  466. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  467. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  468. buildoptions {
  469. "-m64",
  470. }
  471. configuration { "linux-clang", "x32" }
  472. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  473. objdir (path.join(_buildDir, "linux32_clang/obj"))
  474. libdirs { path.join(_libDir, "lib/linux32_clang") }
  475. buildoptions {
  476. "-m32",
  477. }
  478. configuration { "linux-clang", "x64" }
  479. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  480. objdir (path.join(_buildDir, "linux64_clang/obj"))
  481. libdirs { path.join(_libDir, "lib/linux64_clang") }
  482. buildoptions {
  483. "-m64",
  484. }
  485. configuration { "linux-mips-gcc" }
  486. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  487. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  488. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  489. buildoptions {
  490. "-Wunused-value",
  491. "-Wundef",
  492. }
  493. buildoptions_cpp {
  494. "-std=c++0x",
  495. }
  496. links {
  497. "rt",
  498. "dl",
  499. }
  500. linkoptions {
  501. "-Wl,--gc-sections",
  502. }
  503. configuration { "linux-arm-gcc" }
  504. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  505. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  506. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  507. buildoptions {
  508. "-Wunused-value",
  509. "-Wundef",
  510. }
  511. buildoptions_cpp {
  512. "-std=c++0x",
  513. }
  514. links {
  515. "rt",
  516. "dl",
  517. }
  518. linkoptions {
  519. "-Wl,--gc-sections",
  520. }
  521. configuration { "android-*" }
  522. flags {
  523. "NoImportLib",
  524. }
  525. includedirs {
  526. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  527. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  528. }
  529. linkoptions {
  530. "-nostdlib",
  531. "-static-libgcc",
  532. }
  533. links {
  534. "c",
  535. "dl",
  536. "m",
  537. "android",
  538. "log",
  539. "gnustl_static",
  540. "gcc",
  541. }
  542. buildoptions {
  543. "-fPIC",
  544. "-no-canonical-prefixes",
  545. "-Wa,--noexecstack",
  546. "-fstack-protector",
  547. "-ffunction-sections",
  548. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  549. "-Wunused-value",
  550. "-Wundef",
  551. }
  552. buildoptions_cpp {
  553. "-std=c++0x",
  554. }
  555. linkoptions {
  556. "-no-canonical-prefixes",
  557. "-Wl,--no-undefined",
  558. "-Wl,-z,noexecstack",
  559. "-Wl,-z,relro",
  560. "-Wl,-z,now",
  561. }
  562. configuration { "android-arm" }
  563. targetdir (path.join(_buildDir, "android-arm/bin"))
  564. objdir (path.join(_buildDir, "android-arm/obj"))
  565. libdirs {
  566. path.join(_libDir, "lib/android-arm"),
  567. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  568. }
  569. includedirs {
  570. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  571. }
  572. buildoptions {
  573. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  574. "-mthumb",
  575. "-march=armv7-a",
  576. "-mfloat-abi=softfp",
  577. "-mfpu=neon",
  578. "-Wunused-value",
  579. "-Wundef",
  580. }
  581. linkoptions {
  582. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  583. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  584. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  585. "-march=armv7-a",
  586. "-Wl,--fix-cortex-a8",
  587. }
  588. configuration { "android-mips" }
  589. targetdir (path.join(_buildDir, "android-mips/bin"))
  590. objdir (path.join(_buildDir, "android-mips/obj"))
  591. libdirs {
  592. path.join(_libDir, "lib/android-mips"),
  593. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  594. }
  595. includedirs {
  596. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  597. }
  598. buildoptions {
  599. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  600. "-Wunused-value",
  601. "-Wundef",
  602. }
  603. linkoptions {
  604. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  605. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  606. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  607. }
  608. configuration { "android-x86" }
  609. targetdir (path.join(_buildDir, "android-x86/bin"))
  610. objdir (path.join(_buildDir, "android-x86/obj"))
  611. libdirs {
  612. path.join(_libDir, "lib/android-x86"),
  613. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  614. }
  615. includedirs {
  616. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  617. }
  618. buildoptions {
  619. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  620. "-march=i686",
  621. "-mtune=atom",
  622. "-mstackrealign",
  623. "-msse3",
  624. "-mfpmath=sse",
  625. "-Wunused-value",
  626. "-Wundef",
  627. }
  628. linkoptions {
  629. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  630. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  631. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "/arch-x86/usr/lib/crtend_so.o"),
  632. }
  633. configuration { "asmjs" }
  634. targetdir (path.join(_buildDir, "asmjs/bin"))
  635. objdir (path.join(_buildDir, "asmjs/obj"))
  636. libdirs { path.join(_libDir, "lib/asmjs") }
  637. buildoptions {
  638. "-isystem$(EMSCRIPTEN)/system/include",
  639. "-isystem$(EMSCRIPTEN)/system/include/libc",
  640. "-Wunused-value",
  641. "-Wundef",
  642. }
  643. configuration { "freebsd" }
  644. targetdir (path.join(_buildDir, "freebsd/bin"))
  645. objdir (path.join(_buildDir, "freebsd/obj"))
  646. libdirs { path.join(_libDir, "lib/freebsd") }
  647. includedirs {
  648. path.join(bxDir, "include/compat/freebsd"),
  649. }
  650. configuration { "nacl or nacl-arm or pnacl" }
  651. buildoptions {
  652. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  653. "-fno-stack-protector",
  654. "-fdiagnostics-show-option",
  655. "-fdata-sections",
  656. "-ffunction-sections",
  657. "-Wunused-value",
  658. "-Wundef",
  659. }
  660. buildoptions_cpp {
  661. "-std=c++0x",
  662. }
  663. includedirs {
  664. "$(NACL_SDK_ROOT)/include",
  665. path.join(bxDir, "include/compat/nacl"),
  666. }
  667. configuration { "nacl" }
  668. buildoptions {
  669. "-pthread",
  670. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  671. "-msse2",
  672. }
  673. linkoptions {
  674. "-Wl,--gc-sections",
  675. }
  676. configuration { "x32", "nacl" }
  677. targetdir (path.join(_buildDir, "nacl-x86/bin"))
  678. objdir (path.join(_buildDir, "nacl-x86/obj"))
  679. libdirs { path.join(_libDir, "lib/nacl-x86") }
  680. linkoptions { "-melf32_nacl" }
  681. configuration { "x32", "nacl", "Debug" }
  682. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  683. configuration { "x32", "nacl", "Release" }
  684. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  685. configuration { "x64", "nacl" }
  686. targetdir (path.join(_buildDir, "nacl-x64/bin"))
  687. objdir (path.join(_buildDir, "nacl-x64/obj"))
  688. libdirs { path.join(_libDir, "lib/nacl-x64") }
  689. linkoptions { "-melf64_nacl" }
  690. configuration { "x64", "nacl", "Debug" }
  691. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  692. configuration { "x64", "nacl", "Release" }
  693. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  694. configuration { "nacl-arm" }
  695. buildoptions {
  696. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  697. }
  698. targetdir (path.join(_buildDir, "nacl-arm/bin"))
  699. objdir (path.join(_buildDir, "nacl-arm/obj"))
  700. libdirs { path.join(_libDir, "lib/nacl-arm") }
  701. configuration { "nacl-arm", "Debug" }
  702. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  703. configuration { "nacl-arm", "Release" }
  704. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  705. configuration { "pnacl" }
  706. targetdir (path.join(_buildDir, "pnacl/bin"))
  707. objdir (path.join(_buildDir, "pnacl/obj"))
  708. libdirs { path.join(_libDir, "lib/pnacl") }
  709. configuration { "pnacl", "Debug" }
  710. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  711. configuration { "pnacl", "Release" }
  712. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  713. configuration { "Xbox360" }
  714. targetdir (path.join(_buildDir, "xbox360/bin"))
  715. objdir (path.join(_buildDir, "xbox360/obj"))
  716. includedirs { path.join(bxDir, "include/compat/msvc") }
  717. libdirs { path.join(_libDir, "lib/xbox360") }
  718. defines {
  719. "NOMINMAX",
  720. "_XBOX",
  721. }
  722. configuration { "osx", "x32" }
  723. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  724. objdir (path.join(_buildDir, "osx32_clang/obj"))
  725. --libdirs { path.join(_libDir, "lib/osx32_clang") }
  726. buildoptions {
  727. "-m32",
  728. }
  729. configuration { "osx", "x64" }
  730. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  731. objdir (path.join(_buildDir, "osx64_clang/obj"))
  732. --libdirs { path.join(_libDir, "lib/osx64_clang") }
  733. buildoptions {
  734. "-m64",
  735. }
  736. configuration { "osx", "Universal" }
  737. targetdir (path.join(_buildDir, "osx_universal/bin"))
  738. objdir (path.join(_buildDir, "osx_universal/bin"))
  739. configuration { "osx" }
  740. buildoptions {
  741. "-Wfatal-errors",
  742. "-msse2",
  743. "-Wunused-value",
  744. "-Wundef",
  745. }
  746. includedirs { path.join(bxDir, "include/compat/osx") }
  747. configuration { "ios*" }
  748. linkoptions {
  749. "-lc++",
  750. }
  751. buildoptions {
  752. "-Wfatal-errors",
  753. "-Wunused-value",
  754. "-Wundef",
  755. }
  756. includedirs { path.join(bxDir, "include/compat/ios") }
  757. configuration { "ios-arm" }
  758. targetdir (path.join(_buildDir, "ios-arm/bin"))
  759. objdir (path.join(_buildDir, "ios-arm/obj"))
  760. libdirs { path.join(_libDir, "lib/ios-arm") }
  761. linkoptions {
  762. "-miphoneos-version-min=7.0",
  763. "-arch armv7",
  764. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  765. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  766. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  767. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  768. }
  769. buildoptions {
  770. "-miphoneos-version-min=7.0",
  771. "-arch armv7",
  772. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  773. }
  774. configuration { "ios-simulator" }
  775. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  776. objdir (path.join(_buildDir, "ios-simulator/obj"))
  777. libdirs { path.join(_libDir, "lib/ios-simulator") }
  778. linkoptions {
  779. "-mios-simulator-version-min=7.0",
  780. "-arch i386",
  781. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  782. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  783. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  784. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  785. }
  786. buildoptions {
  787. "-mios-simulator-version-min=7.0",
  788. "-arch i386",
  789. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  790. }
  791. configuration { "ps4" }
  792. targetdir (path.join(_buildDir, "ps4/bin"))
  793. objdir (path.join(_buildDir, "ps4/obj"))
  794. libdirs { path.join(_libDir, "lib/ps4") }
  795. includedirs {
  796. path.join(bxDir, "include/compat/freebsd"),
  797. "$(PS4_SDK_ROOT)/target/include",
  798. "$(PS4_SDK_ROOT)/target/include_common",
  799. }
  800. buildoptions {
  801. }
  802. buildoptions_cpp {
  803. "-std=c++0x",
  804. }
  805. linkoptions {
  806. }
  807. configuration { "qnx-arm" }
  808. targetdir (path.join(_buildDir, "qnx-arm/bin"))
  809. objdir (path.join(_buildDir, "qnx-arm/obj"))
  810. libdirs { path.join(_libDir, "lib/qnx-arm") }
  811. -- includedirs { path.join(bxDir, "include/compat/qnx") }
  812. buildoptions {
  813. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  814. "-Wunused-value",
  815. "-Wundef",
  816. }
  817. buildoptions_cpp {
  818. "-std=c++0x",
  819. }
  820. configuration { "rpi" }
  821. targetdir (path.join(_buildDir, "rpi/bin"))
  822. objdir (path.join(_buildDir, "rpi/obj"))
  823. libdirs {
  824. path.join(_libDir, "lib/rpi"),
  825. "/opt/vc/lib",
  826. }
  827. defines {
  828. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  829. "__STDC_VERSION__=199901L",
  830. }
  831. buildoptions {
  832. "-Wunused-value",
  833. "-Wundef",
  834. }
  835. buildoptions_cpp {
  836. "-std=c++0x",
  837. }
  838. includedirs {
  839. "/opt/vc/include",
  840. "/opt/vc/include/interface/vcos/pthreads",
  841. "/opt/vc/include/interface/vmcs_host/linux",
  842. }
  843. links {
  844. "rt",
  845. }
  846. linkoptions {
  847. "-Wl,--gc-sections",
  848. }
  849. configuration {} -- reset configuration
  850. return true
  851. end
  852. function strip()
  853. configuration { "android-arm", "Release" }
  854. postbuildcommands {
  855. "$(SILENT) echo Stripping symbols.",
  856. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  857. }
  858. configuration { "android-mips", "Release" }
  859. postbuildcommands {
  860. "$(SILENT) echo Stripping symbols.",
  861. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  862. }
  863. configuration { "android-x86", "Release" }
  864. postbuildcommands {
  865. "$(SILENT) echo Stripping symbols.",
  866. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  867. }
  868. configuration { "linux-* or rpi", "Release" }
  869. postbuildcommands {
  870. "$(SILENT) echo Stripping symbols.",
  871. "$(SILENT) strip -s \"$(TARGET)\""
  872. }
  873. configuration { "mingw*", "Release" }
  874. postbuildcommands {
  875. "$(SILENT) echo Stripping symbols.",
  876. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  877. }
  878. configuration { "pnacl" }
  879. postbuildcommands {
  880. "$(SILENT) echo Running pnacl-finalize.",
  881. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  882. }
  883. configuration { "*nacl*", "Release" }
  884. postbuildcommands {
  885. "$(SILENT) echo Stripping symbols.",
  886. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  887. }
  888. configuration { "asmjs" }
  889. postbuildcommands {
  890. "$(SILENT) echo Running asmjs finalize.",
  891. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 "
  892. -- .. "-s EMTERPRETIFY=1 "
  893. -- .. "-s EMTERPRETIFY_ASYNC=1 "
  894. .. "-s TOTAL_MEMORY=268435456 "
  895. -- .. "-s ALLOW_MEMORY_GROWTH=1 "
  896. .. "--memory-init-file 1 "
  897. .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
  898. -- .. "--preload-file ../../../examples/runtime@/"
  899. }
  900. configuration {} -- reset configuration
  901. end