toolchain.lua 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933
  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. "-no-canonical-prefixes",
  475. "-Wa,--noexecstack",
  476. "-fstack-protector",
  477. "-ffunction-sections",
  478. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  479. "-Wunused-value",
  480. "-Wundef",
  481. }
  482. buildoptions_cpp {
  483. "-std=c++0x",
  484. }
  485. linkoptions {
  486. "-no-canonical-prefixes",
  487. "-Wl,--no-undefined",
  488. "-Wl,-z,noexecstack",
  489. "-Wl,-z,relro",
  490. "-Wl,-z,now",
  491. }
  492. configuration { "android-arm" }
  493. targetdir (path.join(_buildDir, "android-arm/bin"))
  494. objdir (path.join(_buildDir, "android-arm/obj"))
  495. libdirs {
  496. path.join(_libDir, "lib/android-arm"),
  497. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  498. }
  499. includedirs {
  500. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include",
  501. }
  502. buildoptions {
  503. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  504. "-mthumb",
  505. "-march=armv7-a",
  506. "-mfloat-abi=softfp",
  507. "-mfpu=neon",
  508. "-Wunused-value",
  509. "-Wundef",
  510. }
  511. linkoptions {
  512. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm"),
  513. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtbegin_so.o"),
  514. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-arm/usr/lib/crtend_so.o"),
  515. "-march=armv7-a",
  516. "-Wl,--fix-cortex-a8",
  517. }
  518. configuration { "android-mips" }
  519. targetdir (path.join(_buildDir, "android-mips/bin"))
  520. objdir (path.join(_buildDir, "android-mips/obj"))
  521. libdirs {
  522. path.join(_libDir, "lib/android-mips"),
  523. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips",
  524. }
  525. includedirs {
  526. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/mips/include",
  527. }
  528. buildoptions {
  529. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  530. "-Wunused-value",
  531. "-Wundef",
  532. }
  533. linkoptions {
  534. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips"),
  535. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtbegin_so.o"),
  536. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-mips/usr/lib/crtend_so.o"),
  537. }
  538. configuration { "android-x86" }
  539. targetdir (path.join(_buildDir, "android-x86/bin"))
  540. objdir (path.join(_buildDir, "android-x86/obj"))
  541. libdirs {
  542. path.join(_libDir, "lib/android-x86"),
  543. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86",
  544. }
  545. includedirs {
  546. "$(ANDROID_NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/include",
  547. }
  548. buildoptions {
  549. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  550. "-march=i686",
  551. "-mtune=atom",
  552. "-mstackrealign",
  553. "-msse3",
  554. "-mfpmath=sse",
  555. "-Wunused-value",
  556. "-Wundef",
  557. }
  558. linkoptions {
  559. "--sysroot=" .. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86"),
  560. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "arch-x86/usr/lib/crtbegin_so.o"),
  561. path.join("$(ANDROID_NDK_ROOT)/platforms", androidPlatform, "/arch-x86/usr/lib/crtend_so.o"),
  562. }
  563. configuration { "asmjs" }
  564. targetdir (path.join(_buildDir, "asmjs/bin"))
  565. objdir (path.join(_buildDir, "asmjs/obj"))
  566. libdirs { path.join(_libDir, "lib/asmjs") }
  567. buildoptions {
  568. "-isystem$(EMSCRIPTEN)/system/include",
  569. "-isystem$(EMSCRIPTEN)/system/include/libc",
  570. "-Wunused-value",
  571. "-Wundef",
  572. }
  573. configuration { "freebsd" }
  574. targetdir (path.join(_buildDir, "freebsd/bin"))
  575. objdir (path.join(_buildDir, "freebsd/obj"))
  576. libdirs { path.join(_libDir, "lib/freebsd") }
  577. includedirs {
  578. path.join(bxDir, "include/compat/freebsd"),
  579. }
  580. configuration { "nacl or nacl-arm or pnacl" }
  581. buildoptions {
  582. "-U__STRICT_ANSI__", -- strcasecmp, setenv, unsetenv,...
  583. "-fno-stack-protector",
  584. "-fdiagnostics-show-option",
  585. "-fdata-sections",
  586. "-ffunction-sections",
  587. "-Wunused-value",
  588. "-Wundef",
  589. }
  590. buildoptions_cpp {
  591. "-std=c++0x",
  592. }
  593. includedirs {
  594. "$(NACL_SDK_ROOT)/include",
  595. path.join(bxDir, "include/compat/nacl"),
  596. }
  597. configuration { "nacl" }
  598. buildoptions {
  599. "-pthread",
  600. "-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
  601. "-msse2",
  602. }
  603. linkoptions {
  604. "-Wl,--gc-sections",
  605. }
  606. configuration { "x32", "nacl" }
  607. targetdir (path.join(_buildDir, "nacl-x86/bin"))
  608. objdir (path.join(_buildDir, "nacl-x86/obj"))
  609. libdirs { path.join(_libDir, "lib/nacl-x86") }
  610. linkoptions { "-melf32_nacl" }
  611. configuration { "x32", "nacl", "Debug" }
  612. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Debug" }
  613. configuration { "x32", "nacl", "Release" }
  614. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_32/Release" }
  615. configuration { "x64", "nacl" }
  616. targetdir (path.join(_buildDir, "nacl-x64/bin"))
  617. objdir (path.join(_buildDir, "nacl-x64/obj"))
  618. libdirs { path.join(_libDir, "lib/nacl-x64") }
  619. linkoptions { "-melf64_nacl" }
  620. configuration { "x64", "nacl", "Debug" }
  621. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Debug" }
  622. configuration { "x64", "nacl", "Release" }
  623. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_x86_64/Release" }
  624. configuration { "nacl-arm" }
  625. buildoptions {
  626. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  627. }
  628. targetdir (path.join(_buildDir, "nacl-arm/bin"))
  629. objdir (path.join(_buildDir, "nacl-arm/obj"))
  630. libdirs { path.join(_libDir, "lib/nacl-arm") }
  631. configuration { "nacl-arm", "Debug" }
  632. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Debug" }
  633. configuration { "nacl-arm", "Release" }
  634. libdirs { "$(NACL_SDK_ROOT)/lib/newlib_arm/Release" }
  635. configuration { "pnacl" }
  636. targetdir (path.join(_buildDir, "pnacl/bin"))
  637. objdir (path.join(_buildDir, "pnacl/obj"))
  638. libdirs { path.join(_libDir, "lib/pnacl") }
  639. configuration { "pnacl", "Debug" }
  640. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Debug" }
  641. configuration { "pnacl", "Release" }
  642. libdirs { "$(NACL_SDK_ROOT)/lib/pnacl/Release" }
  643. configuration { "Xbox360" }
  644. targetdir (path.join(_buildDir, "xbox360/bin"))
  645. objdir (path.join(_buildDir, "xbox360/obj"))
  646. includedirs { path.join(bxDir, "include/compat/msvc") }
  647. libdirs { path.join(_libDir, "lib/xbox360") }
  648. defines {
  649. "NOMINMAX",
  650. "_XBOX",
  651. }
  652. configuration { "osx", "x32" }
  653. targetdir (path.join(_buildDir, "osx32_clang/bin"))
  654. objdir (path.join(_buildDir, "osx32_clang/obj"))
  655. libdirs { path.join(_libDir, "lib/osx32_clang") }
  656. buildoptions {
  657. "-m32",
  658. }
  659. configuration { "osx", "x64" }
  660. targetdir (path.join(_buildDir, "osx64_clang/bin"))
  661. objdir (path.join(_buildDir, "osx64_clang/obj"))
  662. libdirs { path.join(_libDir, "lib/osx64_clang") }
  663. buildoptions {
  664. "-m64",
  665. }
  666. configuration { "osx" }
  667. buildoptions {
  668. "-Wfatal-errors",
  669. "-msse2",
  670. "-Wunused-value",
  671. "-Wundef",
  672. }
  673. includedirs { path.join(bxDir, "include/compat/osx") }
  674. configuration { "ios*" }
  675. linkoptions {
  676. "-lc++",
  677. }
  678. buildoptions {
  679. "-Wfatal-errors",
  680. "-Wunused-value",
  681. "-Wundef",
  682. }
  683. includedirs { path.join(bxDir, "include/compat/ios") }
  684. configuration { "ios-arm" }
  685. targetdir (path.join(_buildDir, "ios-arm/bin"))
  686. objdir (path.join(_buildDir, "ios-arm/obj"))
  687. libdirs { path.join(_libDir, "lib/ios-arm") }
  688. linkoptions {
  689. "-miphoneos-version-min=7.0",
  690. "-arch armv7",
  691. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  692. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/usr/lib/system",
  693. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  694. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  695. }
  696. buildoptions {
  697. "-miphoneos-version-min=7.0",
  698. "-arch armv7",
  699. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS" ..iosPlatform .. ".sdk",
  700. }
  701. configuration { "ios-simulator" }
  702. targetdir (path.join(_buildDir, "ios-simulator/bin"))
  703. objdir (path.join(_buildDir, "ios-simulator/obj"))
  704. libdirs { path.join(_libDir, "lib/ios-simulator") }
  705. linkoptions {
  706. "-mios-simulator-version-min=7.0",
  707. "-arch i386",
  708. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  709. "-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/usr/lib/system",
  710. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/Frameworks",
  711. "-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk/System/Library/PrivateFrameworks",
  712. }
  713. buildoptions {
  714. "-mios-simulator-version-min=7.0",
  715. "-arch i386",
  716. "--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator" ..iosPlatform .. ".sdk",
  717. }
  718. configuration { "qnx-arm" }
  719. targetdir (path.join(_buildDir, "qnx-arm/bin"))
  720. objdir (path.join(_buildDir, "qnx-arm/obj"))
  721. libdirs { path.join(_libDir, "lib/qnx-arm") }
  722. -- includedirs { path.join(bxDir, "include/compat/qnx") }
  723. buildoptions {
  724. "-Wno-psabi", -- note: the mangling of 'va_list' has changed in GCC 4.4.0
  725. "-Wunused-value",
  726. "-Wundef",
  727. }
  728. buildoptions_cpp {
  729. "-std=c++0x",
  730. }
  731. configuration { "rpi" }
  732. targetdir (path.join(_buildDir, "rpi/bin"))
  733. objdir (path.join(_buildDir, "rpi/obj"))
  734. libdirs {
  735. path.join(_libDir, "lib/rpi"),
  736. "/opt/vc/lib",
  737. }
  738. defines {
  739. "__VCCOREVER__=0x04000000", -- There is no special prefedined compiler symbol to detect RaspberryPi, faking it.
  740. "__STDC_VERSION__=199901L",
  741. }
  742. buildoptions {
  743. "-Wunused-value",
  744. "-Wundef",
  745. }
  746. buildoptions_cpp {
  747. "-std=c++0x",
  748. }
  749. includedirs {
  750. "/opt/vc/include",
  751. "/opt/vc/include/interface/vcos/pthreads",
  752. "/opt/vc/include/interface/vmcs_host/linux",
  753. }
  754. links {
  755. "rt",
  756. }
  757. linkoptions {
  758. "-Wl,--gc-sections",
  759. }
  760. configuration {} -- reset configuration
  761. return true
  762. end
  763. function strip()
  764. configuration { "android-arm", "Release" }
  765. postbuildcommands {
  766. "$(SILENT) echo Stripping symbols.",
  767. "$(SILENT) $(ANDROID_NDK_ARM)/bin/arm-linux-androideabi-strip -s \"$(TARGET)\""
  768. }
  769. configuration { "android-mips", "Release" }
  770. postbuildcommands {
  771. "$(SILENT) echo Stripping symbols.",
  772. "$(SILENT) $(ANDROID_NDK_MIPS)/bin/mipsel-linux-android-strip -s \"$(TARGET)\""
  773. }
  774. configuration { "android-x86", "Release" }
  775. postbuildcommands {
  776. "$(SILENT) echo Stripping symbols.",
  777. "$(SILENT) $(ANDROID_NDK_X86)/bin/i686-linux-android-strip -s \"$(TARGET)\""
  778. }
  779. configuration { "linux-* or rpi", "Release" }
  780. postbuildcommands {
  781. "$(SILENT) echo Stripping symbols.",
  782. "$(SILENT) strip -s \"$(TARGET)\""
  783. }
  784. configuration { "mingw*", "Release" }
  785. postbuildcommands {
  786. "$(SILENT) echo Stripping symbols.",
  787. "$(SILENT) $(MINGW)/bin/strip -s \"$(TARGET)\""
  788. }
  789. configuration { "pnacl" }
  790. postbuildcommands {
  791. "$(SILENT) echo Running pnacl-finalize.",
  792. "$(SILENT) " .. naclToolchain .. "finalize \"$(TARGET)\""
  793. }
  794. configuration { "*nacl*", "Release" }
  795. postbuildcommands {
  796. "$(SILENT) echo Stripping symbols.",
  797. "$(SILENT) " .. naclToolchain .. "strip -s \"$(TARGET)\""
  798. }
  799. configuration { "asmjs" }
  800. postbuildcommands {
  801. "$(SILENT) echo Running asmjs finalize.",
  802. "$(SILENT) $(EMSCRIPTEN)/emcc -O2 -s TOTAL_MEMORY=268435456 \"$(TARGET)\" -o \"$(TARGET)\".html"
  803. -- ALLOW_MEMORY_GROWTH
  804. }
  805. configuration {} -- reset configuration
  806. end