toolchain.lua 25 KB

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