2
0

toolchain.lua 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  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. buildoptions {
  487. "-Wunused-value",
  488. "-Wundef",
  489. }
  490. buildoptions_cpp {
  491. "-std=c++0x",
  492. }
  493. links {
  494. "rt",
  495. "dl",
  496. }
  497. linkoptions {
  498. "-Wl,--gc-sections",
  499. }
  500. configuration { "android-*" }
  501. flags {
  502. "NoImportLib",
  503. }
  504. includedirs {
  505. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  506. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  507. }
  508. linkoptions {
  509. "-nostdlib",
  510. "-static-libgcc",
  511. }
  512. links {
  513. "c",
  514. "dl",
  515. "m",
  516. "android",
  517. "log",
  518. "gnustl_static",
  519. "gcc",
  520. }
  521. buildoptions {
  522. "-fPIC",
  523. "-no-canonical-prefixes",
  524. "-Wa,--noexecstack",
  525. "-fstack-protector",
  526. "-ffunction-sections",
  527. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  528. "-Wunused-value",
  529. "-Wundef",
  530. }
  531. buildoptions_cpp {
  532. "-std=c++0x",
  533. }
  534. linkoptions {
  535. "-no-canonical-prefixes",
  536. "-Wl,--no-undefined",
  537. "-Wl,-z,noexecstack",
  538. "-Wl,-z,relro",
  539. "-Wl,-z,now",
  540. }
  541. configuration { "android-arm" }
  542. targetdir (path.join(_buildDir, "android-arm/bin"))
  543. objdir (path.join(_buildDir, "android-arm/obj"))
  544. libdirs {
  545. path.join(_libDir, "lib/android-arm"),
  546. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  547. }
  548. includedirs {
  549. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  550. }
  551. buildoptions {
  552. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  553. "-mthumb",
  554. "-march=armv7-a",
  555. "-mfloat-abi=softfp",
  556. "-mfpu=neon",
  557. "-Wunused-value",
  558. "-Wundef",
  559. }
  560. linkoptions {
  561. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  562. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  563. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  564. "-march=armv7-a",
  565. "-Wl,--fix-cortex-a8",
  566. }
  567. configuration { "android-mips" }
  568. targetdir (path.join(_buildDir, "android-mips/bin"))
  569. objdir (path.join(_buildDir, "android-mips/obj"))
  570. libdirs {
  571. path.join(_libDir, "lib/android-mips"),
  572. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  573. }
  574. includedirs {
  575. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  576. }
  577. buildoptions {
  578. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  579. "-Wunused-value",
  580. "-Wundef",
  581. }
  582. linkoptions {
  583. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  584. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  585. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  586. }
  587. configuration { "android-x86" }
  588. targetdir (path.join(_buildDir, "android-x86/bin"))
  589. objdir (path.join(_buildDir, "android-x86/obj"))
  590. libdirs {
  591. path.join(_libDir, "lib/android-x86"),
  592. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  593. }
  594. includedirs {
  595. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  596. }
  597. buildoptions {
  598. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  599. "-march=i686",
  600. "-mtune=atom",
  601. "-mstackrealign",
  602. "-msse3",
  603. "-mfpmath=sse",
  604. "-Wunused-value",
  605. "-Wundef",
  606. }
  607. linkoptions {
  608. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  609. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  610. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "/arch-x86/usr/lib/crtend_so.o"),
  611. }
  612. configuration { "asmjs" }
  613. targetdir (path.join(_buildDir, "asmjs/bin"))
  614. objdir (path.join(_buildDir, "asmjs/obj"))
  615. libdirs { path.join(_libDir, "lib/asmjs") }
  616. buildoptions {
  617. "-isystem$(EMSCRIPTEN)/system/include",
  618. "-isystem$(EMSCRIPTEN)/system/include/libc",
  619. "-Wunused-value",
  620. "-Wundef",
  621. }
  622. configuration { "freebsd" }
  623. targetdir (path.join(_buildDir, "freebsd/bin"))
  624. objdir (path.join(_buildDir, "freebsd/obj"))
  625. libdirs { path.join(_libDir, "lib/freebsd") }
  626. includedirs {
  627. path.join(bxDir, "include/compat/freebsd"),
  628. }
  629. configuration { "nacl or nacl-arm or pnacl" }
  630. buildoptions {
  631. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  632. "-fno-stack-protector",
  633. "-fdiagnostics-show-option",
  634. "-fdata-sections",
  635. "-ffunction-sections",
  636. "-Wunused-value",
  637. "-Wundef",
  638. }
  639. buildoptions_cpp {
  640. "-std=c++0x",
  641. }
  642. includedirs {
  643. "$(NACL_SDK_ROOT)/include",
  644. path.join(bxDir, "include/compat/nacl"),
  645. }
  646. configuration { "nacl" }
  647. buildoptions {
  648. "-pthread",
  649. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  650. "-msse2",
  651. }
  652. linkoptions {
  653. "-Wl,--gc-sections",
  654. }
  655. configuration { "x32", "nacl" }
  656. targetdir (path.join(_buildDir, "nacl-x86/bin"))
  657. objdir (path.join(_buildDir, "nacl-x86/obj"))
  658. libdirs { path.join(_libDir, "lib/nacl-x86") }
  659. linkoptions { "-melf32_nacl" }
  660. configuration { "x32", "nacl", "Debug" }
  661. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  662. configuration { "x32", "nacl", "Release" }
  663. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  664. configuration { "x64", "nacl" }
  665. targetdir (path.join(_buildDir, "nacl-x64/bin"))
  666. objdir (path.join(_buildDir, "nacl-x64/obj"))
  667. libdirs { path.join(_libDir, "lib/nacl-x64") }
  668. linkoptions { "-melf64_nacl" }
  669. configuration { "x64", "nacl", "Debug" }
  670. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  671. configuration { "x64", "nacl", "Release" }
  672. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  673. configuration { "nacl-arm" }
  674. buildoptions {
  675. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  676. }
  677. targetdir (path.join(_buildDir, "nacl-arm/bin"))
  678. objdir (path.join(_buildDir, "nacl-arm/obj"))
  679. libdirs { path.join(_libDir, "lib/nacl-arm") }
  680. configuration { "nacl-arm", "Debug" }
  681. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  682. configuration { "nacl-arm", "Release" }
  683. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  684. configuration { "pnacl" }
  685. targetdir (path.join(_buildDir, "pnacl/bin"))
  686. objdir (path.join(_buildDir, "pnacl/obj"))
  687. libdirs { path.join(_libDir, "lib/pnacl") }
  688. configuration { "pnacl", "Debug" }
  689. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  690. configuration { "pnacl", "Release" }
  691. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  692. configuration { "Xbox360" }
  693. targetdir (path.join(_buildDir, "xbox360/bin"))
  694. objdir (path.join(_buildDir, "xbox360/obj"))
  695. includedirs { path.join(bxDir, "include/compat/msvc") }
  696. libdirs { path.join(_libDir, "lib/xbox360") }
  697. defines {
  698. "NOMINMAX",
  699. "_XBOX",
  700. }
  701. configuration { "osx", "x32" }
  702. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  703. objdir (path.join(_buildDir, "osx32_clang/obj"))
  704. --libdirs { path.join(_libDir, "lib/osx32_clang") }
  705. buildoptions {
  706. "-m32",
  707. }
  708. configuration { "osx", "x64" }
  709. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  710. objdir (path.join(_buildDir, "osx64_clang/obj"))
  711. --libdirs { path.join(_libDir, "lib/osx64_clang") }
  712. buildoptions {
  713. "-m64",
  714. }
  715. configuration { "osx", "Universal" }
  716. targetdir (path.join(_buildDir, "osx_universal/bin"))
  717. objdir (path.join(_buildDir, "osx_universal/bin"))
  718. configuration { "osx" }
  719. buildoptions {
  720. "-Wfatal-errors",
  721. "-msse2",
  722. "-Wunused-value",
  723. "-Wundef",
  724. }
  725. includedirs { path.join(bxDir, "include/compat/osx") }
  726. configuration { "ios*" }
  727. linkoptions {
  728. "-lc++",
  729. }
  730. buildoptions {
  731. "-Wfatal-errors",
  732. "-Wunused-value",
  733. "-Wundef",
  734. }
  735. includedirs { path.join(bxDir, "include/compat/ios") }
  736. configuration { "ios-arm" }
  737. targetdir (path.join(_buildDir, "ios-arm/bin"))
  738. objdir (path.join(_buildDir, "ios-arm/obj"))
  739. libdirs { path.join(_libDir, "lib/ios-arm") }
  740. linkoptions {
  741. "-miphoneos-version-min=7.0",
  742. "-arch armv7",
  743. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  744. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  745. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  746. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  747. }
  748. buildoptions {
  749. "-miphoneos-version-min=7.0",
  750. "-arch armv7",
  751. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  752. }
  753. configuration { "ios-simulator" }
  754. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  755. objdir (path.join(_buildDir, "ios-simulator/obj"))
  756. libdirs { path.join(_libDir, "lib/ios-simulator") }
  757. linkoptions {
  758. "-mios-simulator-version-min=7.0",
  759. "-arch i386",
  760. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  761. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  762. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  763. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  764. }
  765. buildoptions {
  766. "-mios-simulator-version-min=7.0",
  767. "-arch i386",
  768. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  769. }
  770. configuration { "ps4" }
  771. targetdir (path.join(_buildDir, "ps4/bin"))
  772. objdir (path.join(_buildDir, "ps4/obj"))
  773. libdirs { path.join(_libDir, "lib/ps4") }
  774. includedirs {
  775. path.join(bxDir, "include/compat/freebsd"),
  776. "$(PS4_SDK_ROOT)/target/include",
  777. "$(PS4_SDK_ROOT)/target/include_common",
  778. }
  779. buildoptions {
  780. }
  781. buildoptions_cpp {
  782. "-std=c++0x",
  783. }
  784. linkoptions {
  785. }
  786. configuration { "qnx-arm" }
  787. targetdir (path.join(_buildDir, "qnx-arm/bin"))
  788. objdir (path.join(_buildDir, "qnx-arm/obj"))
  789. libdirs { path.join(_libDir, "lib/qnx-arm") }
  790. -- includedirs { path.join(bxDir, "include/compat/qnx") }
  791. buildoptions {
  792. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  793. "-Wunused-value",
  794. "-Wundef",
  795. }
  796. buildoptions_cpp {
  797. "-std=c++0x",
  798. }
  799. configuration { "rpi" }
  800. targetdir (path.join(_buildDir, "rpi/bin"))
  801. objdir (path.join(_buildDir, "rpi/obj"))
  802. libdirs {
  803. path.join(_libDir, "lib/rpi"),
  804. "/opt/vc/lib",
  805. }
  806. defines {
  807. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  808. "__STDC_VERSION__=199901L",
  809. }
  810. buildoptions {
  811. "-Wunused-value",
  812. "-Wundef",
  813. }
  814. buildoptions_cpp {
  815. "-std=c++0x",
  816. }
  817. includedirs {
  818. "/opt/vc/include",
  819. "/opt/vc/include/interface/vcos/pthreads",
  820. "/opt/vc/include/interface/vmcs_host/linux",
  821. }
  822. links {
  823. "rt",
  824. }
  825. linkoptions {
  826. "-Wl,--gc-sections",
  827. }
  828. configuration {} -- reset configuration
  829. return true
  830. end
  831. function strip()
  832. configuration { "android-arm", "Release" }
  833. postbuildcommands {
  834. "$(SILENT) echo Stripping symbols.",
  835. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  836. }
  837. configuration { "android-mips", "Release" }
  838. postbuildcommands {
  839. "$(SILENT) echo Stripping symbols.",
  840. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  841. }
  842. configuration { "android-x86", "Release" }
  843. postbuildcommands {
  844. "$(SILENT) echo Stripping symbols.",
  845. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  846. }
  847. configuration { "linux-* or rpi", "Release" }
  848. postbuildcommands {
  849. "$(SILENT) echo Stripping symbols.",
  850. "$(SILENT) strip -s \"$(TARGET)\""
  851. }
  852. configuration { "mingw*", "Release" }
  853. postbuildcommands {
  854. "$(SILENT) echo Stripping symbols.",
  855. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  856. }
  857. configuration { "pnacl" }
  858. postbuildcommands {
  859. "$(SILENT) echo Running pnacl-finalize.",
  860. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  861. }
  862. configuration { "*nacl*", "Release" }
  863. postbuildcommands {
  864. "$(SILENT) echo Stripping symbols.",
  865. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  866. }
  867. configuration { "asmjs" }
  868. postbuildcommands {
  869. "$(SILENT) echo Running asmjs finalize.",
  870. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 "
  871. -- .. "-s EMTERPRETIFY=1 "
  872. -- .. "-s EMTERPRETIFY_ASYNC=1 "
  873. .. "-s TOTAL_MEMORY=268435456 "
  874. -- .. "-s ALLOW_MEMORY_GROWTH=1 "
  875. .. "--memory-init-file 1 "
  876. .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
  877. -- .. "--preload-file ../../../examples/runtime@/"
  878. }
  879. configuration {} -- reset configuration
  880. end