toolchain.lua 25 KB

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