toolchain.lua 29 KB

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