toolchain.lua 30 KB

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