toolchain.lua 27 KB

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