toolchain.lua 26 KB

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