toolchain.lua 28 KB

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