toolchain.lua 27 KB

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