toolchain.lua 26 KB

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