toolchain.lua 27 KB

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