toolchain.lua 28 KB

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