toolchain.lua 28 KB

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