toolchain.lua 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038
  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. }
  330. configuration { "x64", "vs*" }
  331. defines { "_WIN64" }
  332. targetdir (path.join(_buildDir, "win64_" .. _ACTION, "bin"))
  333. objdir (path.join(_buildDir, "win64_" .. _ACTION, "obj"))
  334. libdirs {
  335. path.join(_libDir, "lib/win64_" .. _ACTION),
  336. }
  337. configuration { "ARM", "vs*" }
  338. targetdir (path.join(_buildDir, "arm_" .. _ACTION, "bin"))
  339. objdir (path.join(_buildDir, "arm_" .. _ACTION, "obj"))
  340. configuration { "vs*-clang" }
  341. buildoptions {
  342. "-Qunused-arguments",
  343. }
  344. configuration { "x32", "vs*-clang" }
  345. targetdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/bin"))
  346. objdir (path.join(_buildDir, "win32_" .. _ACTION .. "-clang/obj"))
  347. configuration { "x64", "vs*-clang" }
  348. targetdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/bin"))
  349. objdir (path.join(_buildDir, "win64_" .. _ACTION .. "-clang/obj"))
  350. configuration { "winphone8* or winstore8*" }
  351. removeflags {
  352. "StaticRuntime",
  353. "NoExceptions",
  354. }
  355. configuration { "*-gcc* or osx" }
  356. buildoptions {
  357. "-Wshadow",
  358. }
  359. configuration { "mingw-*" }
  360. defines { "WIN32" }
  361. includedirs { path.join(bxDir, "include/compat/mingw") }
  362. buildoptions {
  363. "-Wunused-value",
  364. "-fdata-sections",
  365. "-ffunction-sections",
  366. "-msse2",
  367. "-Wunused-value",
  368. "-Wundef",
  369. }
  370. buildoptions_cpp {
  371. "-std=c++0x",
  372. }
  373. linkoptions {
  374. "-Wl,--gc-sections",
  375. "-static-libgcc",
  376. "-static-libstdc++",
  377. }
  378. configuration { "x32", "mingw-gcc" }
  379. targetdir (path.join(_buildDir, "win32_mingw-gcc/bin"))
  380. objdir (path.join(_buildDir, "win32_mingw-gcc/obj"))
  381. libdirs {
  382. path.join(_libDir, "lib/win32_mingw-gcc"),
  383. }
  384. buildoptions { "-m32" }
  385. configuration { "x64", "mingw-gcc" }
  386. targetdir (path.join(_buildDir, "win64_mingw-gcc/bin"))
  387. objdir (path.join(_buildDir, "win64_mingw-gcc/obj"))
  388. libdirs {
  389. path.join(_libDir, "lib/win64_mingw-gcc"),
  390. }
  391. buildoptions { "-m64" }
  392. configuration { "mingw-clang" }
  393. buildoptions {
  394. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++",
  395. "-isystem$(MINGW)/lib/gcc/x86_64-w64-mingw32/4.8.1/include/c++/x86_64-w64-mingw32",
  396. "-isystem$(MINGW)/x86_64-w64-mingw32/include",
  397. }
  398. linkoptions {
  399. "-Qunused-arguments",
  400. "-Wno-error=unused-command-line-argument-hard-error-in-future",
  401. }
  402. configuration { "x32", "mingw-clang" }
  403. targetdir (path.join(_buildDir, "win32_mingw-clang/bin"))
  404. objdir (path.join(_buildDir, "win32_mingw-clang/obj"))
  405. libdirs {
  406. path.join(_libDir, "lib/win32_mingw-clang"),
  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. }
  415. buildoptions { "-m64" }
  416. configuration { "linux-clang" }
  417. configuration { "linux-gcc-5" }
  418. buildoptions {
  419. -- "-fno-omit-frame-pointer",
  420. -- "-fsanitize=address",
  421. -- "-fsanitize=undefined",
  422. -- "-fsanitize=float-divide-by-zero",
  423. -- "-fsanitize=float-cast-overflow",
  424. }
  425. links {
  426. -- "asan",
  427. -- "ubsan",
  428. }
  429. configuration { "linux-gcc" }
  430. buildoptions {
  431. "-mfpmath=sse",
  432. }
  433. configuration { "linux-gcc or linux-clang" }
  434. buildoptions {
  435. "-msse2",
  436. "-Wunused-value",
  437. "-Wundef",
  438. }
  439. buildoptions_cpp {
  440. "-std=c++0x",
  441. }
  442. links {
  443. "rt",
  444. "dl",
  445. }
  446. linkoptions {
  447. "-Wl,--gc-sections",
  448. }
  449. configuration { "linux-gcc*", "x32" }
  450. targetdir (path.join(_buildDir, "linux32_gcc/bin"))
  451. objdir (path.join(_buildDir, "linux32_gcc/obj"))
  452. libdirs { path.join(_libDir, "lib/linux32_gcc") }
  453. buildoptions {
  454. "-m32",
  455. }
  456. configuration { "linux-gcc*", "x64" }
  457. targetdir (path.join(_buildDir, "linux64_gcc/bin"))
  458. objdir (path.join(_buildDir, "linux64_gcc/obj"))
  459. libdirs { path.join(_libDir, "lib/linux64_gcc") }
  460. buildoptions {
  461. "-m64",
  462. }
  463. configuration { "linux-clang", "x32" }
  464. targetdir (path.join(_buildDir, "linux32_clang/bin"))
  465. objdir (path.join(_buildDir, "linux32_clang/obj"))
  466. libdirs { path.join(_libDir, "lib/linux32_clang") }
  467. buildoptions {
  468. "-m32",
  469. }
  470. configuration { "linux-clang", "x64" }
  471. targetdir (path.join(_buildDir, "linux64_clang/bin"))
  472. objdir (path.join(_buildDir, "linux64_clang/obj"))
  473. libdirs { path.join(_libDir, "lib/linux64_clang") }
  474. buildoptions {
  475. "-m64",
  476. }
  477. configuration { "linux-mips-gcc" }
  478. targetdir (path.join(_buildDir, "linux32_mips_gcc/bin"))
  479. objdir (path.join(_buildDir, "linux32_mips_gcc/obj"))
  480. libdirs { path.join(_libDir, "lib/linux32_mips_gcc") }
  481. buildoptions {
  482. "-Wunused-value",
  483. "-Wundef",
  484. }
  485. buildoptions_cpp {
  486. "-std=c++0x",
  487. }
  488. links {
  489. "rt",
  490. "dl",
  491. }
  492. linkoptions {
  493. "-Wl,--gc-sections",
  494. }
  495. configuration { "linux-arm-gcc" }
  496. targetdir (path.join(_buildDir, "linux32_arm_gcc/bin"))
  497. objdir (path.join(_buildDir, "linux32_arm_gcc/obj"))
  498. libdirs { path.join(_libDir, "lib/linux32_arm_gcc") }
  499. buildoptions {
  500. "-Wunused-value",
  501. "-Wundef",
  502. }
  503. buildoptions_cpp {
  504. "-std=c++0x",
  505. }
  506. links {
  507. "rt",
  508. "dl",
  509. }
  510. linkoptions {
  511. "-Wl,--gc-sections",
  512. }
  513. configuration { "android-*" }
  514. flags {
  515. "NoImportLib",
  516. }
  517. includedirs {
  518. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  519. "$(ANDROID_NDK_ROOT)/sources/android/native_app_glue",
  520. }
  521. linkoptions {
  522. "-nostdlib",
  523. "-static-libgcc",
  524. }
  525. links {
  526. "c",
  527. "dl",
  528. "m",
  529. "android",
  530. "log",
  531. "gnustl_static",
  532. "gcc",
  533. }
  534. buildoptions {
  535. "-fPIC",
  536. "-no-canonical-prefixes",
  537. "-Wa,--noexecstack",
  538. "-fstack-protector",
  539. "-ffunction-sections",
  540. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  541. "-Wunused-value",
  542. "-Wundef",
  543. }
  544. buildoptions_cpp {
  545. "-std=c++0x",
  546. }
  547. linkoptions {
  548. "-no-canonical-prefixes",
  549. "-Wl,--no-undefined",
  550. "-Wl,-z,noexecstack",
  551. "-Wl,-z,relro",
  552. "-Wl,-z,now",
  553. }
  554. configuration { "android-arm" }
  555. targetdir (path.join(_buildDir, "android-arm/bin"))
  556. objdir (path.join(_buildDir, "android-arm/obj"))
  557. libdirs {
  558. path.join(_libDir, "lib/android-arm"),
  559. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  560. }
  561. includedirs {
  562. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  563. }
  564. buildoptions {
  565. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  566. "-mthumb",
  567. "-march=armv7-a",
  568. "-mfloat-abi=softfp",
  569. "-mfpu=neon",
  570. "-Wunused-value",
  571. "-Wundef",
  572. }
  573. linkoptions {
  574. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  575. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  576. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  577. "-march=armv7-a",
  578. "-Wl,--fix-cortex-a8",
  579. }
  580. configuration { "android-mips" }
  581. targetdir (path.join(_buildDir, "android-mips/bin"))
  582. objdir (path.join(_buildDir, "android-mips/obj"))
  583. libdirs {
  584. path.join(_libDir, "lib/android-mips"),
  585. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  586. }
  587. includedirs {
  588. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  589. }
  590. buildoptions {
  591. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  592. "-Wunused-value",
  593. "-Wundef",
  594. }
  595. linkoptions {
  596. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  597. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  598. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  599. }
  600. configuration { "android-x86" }
  601. targetdir (path.join(_buildDir, "android-x86/bin"))
  602. objdir (path.join(_buildDir, "android-x86/obj"))
  603. libdirs {
  604. path.join(_libDir, "lib/android-x86"),
  605. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  606. }
  607. includedirs {
  608. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  609. }
  610. buildoptions {
  611. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  612. "-march=i686",
  613. "-mtune=atom",
  614. "-mstackrealign",
  615. "-msse3",
  616. "-mfpmath=sse",
  617. "-Wunused-value",
  618. "-Wundef",
  619. }
  620. linkoptions {
  621. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  622. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  623. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "/arch-x86/usr/lib/crtend_so.o"),
  624. }
  625. configuration { "asmjs" }
  626. targetdir (path.join(_buildDir, "asmjs/bin"))
  627. objdir (path.join(_buildDir, "asmjs/obj"))
  628. libdirs { path.join(_libDir, "lib/asmjs") }
  629. buildoptions {
  630. "-isystem$(EMSCRIPTEN)/system/include",
  631. "-isystem$(EMSCRIPTEN)/system/include/libc",
  632. "-Wunused-value",
  633. "-Wundef",
  634. }
  635. configuration { "freebsd" }
  636. targetdir (path.join(_buildDir, "freebsd/bin"))
  637. objdir (path.join(_buildDir, "freebsd/obj"))
  638. libdirs { path.join(_libDir, "lib/freebsd") }
  639. includedirs {
  640. path.join(bxDir, "include/compat/freebsd"),
  641. }
  642. configuration { "nacl or nacl-arm or pnacl" }
  643. buildoptions {
  644. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  645. "-fno-stack-protector",
  646. "-fdiagnostics-show-option",
  647. "-fdata-sections",
  648. "-ffunction-sections",
  649. "-Wunused-value",
  650. "-Wundef",
  651. }
  652. buildoptions_cpp {
  653. "-std=c++0x",
  654. }
  655. includedirs {
  656. "$(NACL_SDK_ROOT)/include",
  657. path.join(bxDir, "include/compat/nacl"),
  658. }
  659. configuration { "nacl" }
  660. buildoptions {
  661. "-pthread",
  662. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  663. "-msse2",
  664. }
  665. linkoptions {
  666. "-Wl,--gc-sections",
  667. }
  668. configuration { "x32", "nacl" }
  669. targetdir (path.join(_buildDir, "nacl-x86/bin"))
  670. objdir (path.join(_buildDir, "nacl-x86/obj"))
  671. libdirs { path.join(_libDir, "lib/nacl-x86") }
  672. linkoptions { "-melf32_nacl" }
  673. configuration { "x32", "nacl", "Debug" }
  674. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  675. configuration { "x32", "nacl", "Release" }
  676. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  677. configuration { "x64", "nacl" }
  678. targetdir (path.join(_buildDir, "nacl-x64/bin"))
  679. objdir (path.join(_buildDir, "nacl-x64/obj"))
  680. libdirs { path.join(_libDir, "lib/nacl-x64") }
  681. linkoptions { "-melf64_nacl" }
  682. configuration { "x64", "nacl", "Debug" }
  683. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  684. configuration { "x64", "nacl", "Release" }
  685. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  686. configuration { "nacl-arm" }
  687. buildoptions {
  688. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  689. }
  690. targetdir (path.join(_buildDir, "nacl-arm/bin"))
  691. objdir (path.join(_buildDir, "nacl-arm/obj"))
  692. libdirs { path.join(_libDir, "lib/nacl-arm") }
  693. configuration { "nacl-arm", "Debug" }
  694. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  695. configuration { "nacl-arm", "Release" }
  696. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  697. configuration { "pnacl" }
  698. targetdir (path.join(_buildDir, "pnacl/bin"))
  699. objdir (path.join(_buildDir, "pnacl/obj"))
  700. libdirs { path.join(_libDir, "lib/pnacl") }
  701. configuration { "pnacl", "Debug" }
  702. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  703. configuration { "pnacl", "Release" }
  704. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  705. configuration { "Xbox360" }
  706. targetdir (path.join(_buildDir, "xbox360/bin"))
  707. objdir (path.join(_buildDir, "xbox360/obj"))
  708. includedirs { path.join(bxDir, "include/compat/msvc") }
  709. libdirs { path.join(_libDir, "lib/xbox360") }
  710. defines {
  711. "NOMINMAX",
  712. "_XBOX",
  713. }
  714. configuration { "osx", "x32" }
  715. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  716. objdir (path.join(_buildDir, "osx32_clang/obj"))
  717. --libdirs { path.join(_libDir, "lib/osx32_clang") }
  718. buildoptions {
  719. "-m32",
  720. }
  721. configuration { "osx", "x64" }
  722. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  723. objdir (path.join(_buildDir, "osx64_clang/obj"))
  724. --libdirs { path.join(_libDir, "lib/osx64_clang") }
  725. buildoptions {
  726. "-m64",
  727. }
  728. configuration { "osx", "Universal" }
  729. targetdir (path.join(_buildDir, "osx_universal/bin"))
  730. objdir (path.join(_buildDir, "osx_universal/bin"))
  731. configuration { "osx" }
  732. buildoptions {
  733. "-Wfatal-errors",
  734. "-msse2",
  735. "-Wunused-value",
  736. "-Wundef",
  737. }
  738. includedirs { path.join(bxDir, "include/compat/osx") }
  739. configuration { "ios*" }
  740. linkoptions {
  741. "-lc++",
  742. }
  743. buildoptions {
  744. "-Wfatal-errors",
  745. "-Wunused-value",
  746. "-Wundef",
  747. }
  748. includedirs { path.join(bxDir, "include/compat/ios") }
  749. configuration { "ios-arm" }
  750. targetdir (path.join(_buildDir, "ios-arm/bin"))
  751. objdir (path.join(_buildDir, "ios-arm/obj"))
  752. libdirs { path.join(_libDir, "lib/ios-arm") }
  753. linkoptions {
  754. "-miphoneos-version-min=7.0",
  755. "-arch armv7",
  756. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  757. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  758. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  759. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  760. }
  761. buildoptions {
  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. }
  766. configuration { "ios-simulator" }
  767. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  768. objdir (path.join(_buildDir, "ios-simulator/obj"))
  769. libdirs { path.join(_libDir, "lib/ios-simulator") }
  770. linkoptions {
  771. "-mios-simulator-version-min=7.0",
  772. "-arch i386",
  773. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  774. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  775. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  776. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  777. }
  778. buildoptions {
  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. }
  783. configuration { "ps4" }
  784. targetdir (path.join(_buildDir, "ps4/bin"))
  785. objdir (path.join(_buildDir, "ps4/obj"))
  786. libdirs { path.join(_libDir, "lib/ps4") }
  787. includedirs {
  788. path.join(bxDir, "include/compat/freebsd"),
  789. "$(PS4_SDK_ROOT)/target/include",
  790. "$(PS4_SDK_ROOT)/target/include_common",
  791. }
  792. buildoptions {
  793. }
  794. buildoptions_cpp {
  795. "-std=c++0x",
  796. }
  797. linkoptions {
  798. }
  799. configuration { "qnx-arm" }
  800. targetdir (path.join(_buildDir, "qnx-arm/bin"))
  801. objdir (path.join(_buildDir, "qnx-arm/obj"))
  802. libdirs { path.join(_libDir, "lib/qnx-arm") }
  803. -- includedirs { path.join(bxDir, "include/compat/qnx") }
  804. buildoptions {
  805. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  806. "-Wunused-value",
  807. "-Wundef",
  808. }
  809. buildoptions_cpp {
  810. "-std=c++0x",
  811. }
  812. configuration { "rpi" }
  813. targetdir (path.join(_buildDir, "rpi/bin"))
  814. objdir (path.join(_buildDir, "rpi/obj"))
  815. libdirs {
  816. path.join(_libDir, "lib/rpi"),
  817. "/opt/vc/lib",
  818. }
  819. defines {
  820. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  821. "__STDC_VERSION__=199901L",
  822. }
  823. buildoptions {
  824. "-Wunused-value",
  825. "-Wundef",
  826. }
  827. buildoptions_cpp {
  828. "-std=c++0x",
  829. }
  830. includedirs {
  831. "/opt/vc/include",
  832. "/opt/vc/include/interface/vcos/pthreads",
  833. "/opt/vc/include/interface/vmcs_host/linux",
  834. }
  835. links {
  836. "rt",
  837. }
  838. linkoptions {
  839. "-Wl,--gc-sections",
  840. }
  841. configuration {} -- reset configuration
  842. return true
  843. end
  844. function strip()
  845. configuration { "android-arm", "Release" }
  846. postbuildcommands {
  847. "$(SILENT) echo Stripping symbols.",
  848. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  849. }
  850. configuration { "android-mips", "Release" }
  851. postbuildcommands {
  852. "$(SILENT) echo Stripping symbols.",
  853. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  854. }
  855. configuration { "android-x86", "Release" }
  856. postbuildcommands {
  857. "$(SILENT) echo Stripping symbols.",
  858. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  859. }
  860. configuration { "linux-* or rpi", "Release" }
  861. postbuildcommands {
  862. "$(SILENT) echo Stripping symbols.",
  863. "$(SILENT) strip -s \"$(TARGET)\""
  864. }
  865. configuration { "mingw*", "Release" }
  866. postbuildcommands {
  867. "$(SILENT) echo Stripping symbols.",
  868. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  869. }
  870. configuration { "pnacl" }
  871. postbuildcommands {
  872. "$(SILENT) echo Running pnacl-finalize.",
  873. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  874. }
  875. configuration { "*nacl*", "Release" }
  876. postbuildcommands {
  877. "$(SILENT) echo Stripping symbols.",
  878. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  879. }
  880. configuration { "asmjs" }
  881. postbuildcommands {
  882. "$(SILENT) echo Running asmjs finalize.",
  883. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 "
  884. -- .. "-s EMTERPRETIFY=1 "
  885. -- .. "-s EMTERPRETIFY_ASYNC=1 "
  886. .. "-s TOTAL_MEMORY=268435456 "
  887. -- .. "-s ALLOW_MEMORY_GROWTH=1 "
  888. .. "--memory-init-file 1 "
  889. .. "\"$(TARGET)\" -o \"$(TARGET)\".html "
  890. -- .. "--preload-file ../../../examples/runtime@/"
  891. }
  892. configuration {} -- reset configuration
  893. end