premake4.lua 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. -- Copyright (c) 2013 - 2014 Daniele Bartolini, Michele Rossi
  2. -- Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  3. --
  4. -- Permission is hereby granted, free of charge, to any person
  5. -- obtaining a copy of this software and associated documentation
  6. -- files (the "Software"), to deal in the Software without
  7. -- restriction, including without limitation the rights to use,
  8. -- copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. -- copies of the Software, and to permit persons to whom the
  10. -- Software is furnished to do so, subject to the following
  11. -- conditions:
  12. --
  13. -- The above copyright notice and this permission notice shall be
  14. -- included in all copies or substantial portions of the Software.
  15. --
  16. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  18. -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  20. -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  21. -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  23. -- OTHER DEALINGS IN THE SOFTWARE.
  24. ------------------------------------------------------------------------------
  25. -- Options
  26. newoption
  27. {
  28. trigger = "install-dir",
  29. value = "DIR",
  30. description = "Output directory"
  31. }
  32. newoption
  33. {
  34. trigger = "compiler",
  35. value = "COMPILER",
  36. description = "Choose compiler",
  37. allowed =
  38. {
  39. { "android", "Android (ARM only)" }, -- gcc
  40. -- { "android-mips", "Android - MIPS" }, -- gcc
  41. -- { "android-x86", "Android - x86" }, -- gcc
  42. { "linux-gcc", "Linux (GCC compiler)" }, -- gcc
  43. -- { "linux-clang", "Linux (Clang compiler)" }, -- clang
  44. -- { "osx-gcc", "OSX" }, -- gcc
  45. -- { "ios-arm", "iOS - ARM" }, -- clang
  46. -- { "ios-simulator", "iOS - Simulator" } -- clang
  47. }
  48. }
  49. -- if _OPTIONS["install-dir"] == nil then
  50. -- print("'install-dir' option must be specified")
  51. -- os.exit(1)
  52. -- end
  53. -- if not path.isabsolute(_OPTIONS["install-dir"]) then
  54. -- print("'install-dir' must be an absolute path")
  55. -- os.exit(1)
  56. -- end
  57. CROWN_SOURCE_DIR = path.getabsolute("..") .. "/"
  58. CROWN_THIRD_DIR = CROWN_SOURCE_DIR .. "third/"
  59. CROWN_BUILD_DIR = CROWN_SOURCE_DIR.. ".build/"
  60. CROWN_INSTALL_DIR = CROWN_SOURCE_DIR.. ".installation/"-- _OPTIONS["install-dir"]
  61. -------------------------------------------------------------------------------
  62. -- Solution
  63. solution "crown"
  64. configurations { "debug", "development", "release" }
  65. platforms { "native", "x32", "x64" }
  66. configuration { "debug" }
  67. defines { "_DEBUG", "CROWN_DEBUG" }
  68. configuration { "development" }
  69. flags { "OptimizeSpeed" }
  70. defines { "NDEBUG", "CROWN_DEVELOPMENT" }
  71. configuration { "release" }
  72. flags { "OptimizeSpeed" }
  73. defines { "NDEBUG", "CROWN_RELEASE" }
  74. configuration { "debug", "x32" }
  75. targetsuffix "-debug-32"
  76. configuration { "debug", "x64" }
  77. targetsuffix "-debug-64"
  78. configuration { "development", "x32" }
  79. targetsuffix "-development-32"
  80. configuration { "development", "x64" }
  81. targetsuffix "-development-64"
  82. configuration { "release", "x32" }
  83. targetsuffix "-release-32"
  84. configuration { "release", "x64" }
  85. targetsuffix "-release-64"
  86. configuration { "debug", "native" }
  87. targetsuffix "-debug"
  88. configuration { "debug", "native" }
  89. targetsuffix "-debug"
  90. configuration { "development", "native" }
  91. targetsuffix "-development"
  92. configuration { "development", "native" }
  93. targetsuffix "-development"
  94. configuration { "release", "native" }
  95. targetsuffix "-release"
  96. configuration { "release", "native" }
  97. targetsuffix "-release"
  98. -- Avoid error invoking premake4 --help
  99. if _ACTION == nil then return end
  100. if _ACTION == "clean" then os.rmdir(CROWN_BUILD_DIR) end
  101. if _ACTION == "gmake" then
  102. if _OPTIONS["compiler"] == "linux-gcc" then
  103. location(CROWN_BUILD_DIR .. "linux")
  104. elseif _OPTIONS["compiler"] == "android" then
  105. if not os.getenv("ANDROID_NDK") then
  106. print("Set ANDROID_NDK environment variable.")
  107. end
  108. premake.gcc.cc = "$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc"
  109. premake.gcc.cxx = "$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-g++"
  110. premake.gcc.ar = "$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar"
  111. location(CROWN_BUILD_DIR .. "android")
  112. end
  113. end
  114. flags
  115. {
  116. "StaticRuntime",
  117. "NoMinimalRebuild",
  118. "NoPCH",
  119. "NativeWChar",
  120. "NoRTTI",
  121. "NoExceptions",
  122. "NoEditAndContinue",
  123. "Symbols"
  124. }
  125. -------------------------------------------------------------------------------
  126. project "crown"
  127. language "C++"
  128. includedirs
  129. {
  130. CROWN_SOURCE_DIR .. "/engine",
  131. CROWN_SOURCE_DIR .. "/engine/core",
  132. CROWN_SOURCE_DIR .. "/engine/core/bv",
  133. CROWN_SOURCE_DIR .. "/engine/core/containers",
  134. CROWN_SOURCE_DIR .. "/engine/core/math",
  135. CROWN_SOURCE_DIR .. "/engine/core/mem",
  136. CROWN_SOURCE_DIR .. "/engine/core/compressors",
  137. CROWN_SOURCE_DIR .. "/engine/core/filesystem",
  138. CROWN_SOURCE_DIR .. "/engine/core/json",
  139. CROWN_SOURCE_DIR .. "/engine/core/strings",
  140. CROWN_SOURCE_DIR .. "/engine/core/settings",
  141. CROWN_SOURCE_DIR .. "/engine/os",
  142. CROWN_SOURCE_DIR .. "/engine/input",
  143. CROWN_SOURCE_DIR .. "/engine/renderers",
  144. CROWN_SOURCE_DIR .. "/engine/renderers/backend",
  145. CROWN_SOURCE_DIR .. "/engine/resource",
  146. CROWN_SOURCE_DIR .. "/engine/lua",
  147. CROWN_SOURCE_DIR .. "/engine/audio",
  148. CROWN_SOURCE_DIR .. "/engine/compilers",
  149. CROWN_SOURCE_DIR .. "/engine/physics",
  150. CROWN_SOURCE_DIR .. "/engine/world"
  151. }
  152. files
  153. {
  154. CROWN_SOURCE_DIR .. "engine/**.h",
  155. CROWN_SOURCE_DIR .. "engine/**.cpp"
  156. }
  157. configuration { "linux-*" }
  158. kind "ConsoleApp"
  159. targetdir(CROWN_INSTALL_DIR .. "linux") -- must be specified by user -- tmp
  160. defines { "CROWN_LINUX" }
  161. includedirs {
  162. CROWN_SOURCE_DIR .. "/engine/os/linux",
  163. CROWN_SOURCE_DIR .. "/engine/renderers/backend/gl/glx"
  164. }
  165. buildoptions
  166. {
  167. "-std=c++03",
  168. "-O0"
  169. }
  170. linkoptions
  171. {
  172. "-Wl,-rpath=\\$$ORIGIN"
  173. }
  174. links
  175. {
  176. "Xrandr",
  177. "pthread",
  178. "dl",
  179. "GL",
  180. "X11",
  181. "openal",
  182. "luajit-5.1"
  183. }
  184. excludes
  185. {
  186. CROWN_SOURCE_DIR .. "engine/os/android/*",
  187. CROWN_SOURCE_DIR .. "engine/os/win/*",
  188. CROWN_SOURCE_DIR .. "engine/renderers/backend/gl/egl/*",
  189. CROWN_SOURCE_DIR .. "engine/renderers/backend/gl/wgl/*",
  190. CROWN_SOURCE_DIR .. "engine/audio/backend/SLESSoundWorld.cpp"
  191. }
  192. configuration { "debug", "linux-*" }
  193. linkoptions
  194. {
  195. "-Wl,--start-group $(addprefix -l," ..
  196. " LowLevelClothCHECKED" ..
  197. " PhysX3CHECKED " ..
  198. " PhysX3CommonCHECKED" ..
  199. " PxTaskCHECKED" ..
  200. " LowLevelCHECKED" ..
  201. " PhysX3CharacterKinematicCHECKED" ..
  202. " PhysX3CookingCHECKED" ..
  203. " PhysX3ExtensionsCHECKED" ..
  204. " PhysX3VehicleCHECKED" ..
  205. " PhysXProfileSDKCHECKED" ..
  206. " PhysXVisualDebuggerSDKCHECKED" ..
  207. " PvdRuntimeCHECKED" ..
  208. " SceneQueryCHECKED" ..
  209. " SimulationControllerCHECKED" ..
  210. ") -Wl,--end-group"
  211. }
  212. configuration { "development", "linux-*" }
  213. linkoptions
  214. {
  215. "-Wl,--start-group $(addprefix -l," ..
  216. " LowLevelClothPROFILE" ..
  217. " PhysX3PROFILE " ..
  218. " PhysX3CommonPROFILE" ..
  219. " PxTaskPROFILE" ..
  220. " LowLevelPROFILE" ..
  221. " PhysX3CharacterKinematicPROFILE" ..
  222. " PhysX3CookingPROFILE" ..
  223. " PhysX3ExtensionsPROFILE" ..
  224. " PhysX3VehiclePROFILE" ..
  225. " PhysXProfileSDKPROFILE" ..
  226. " PhysXVisualDebuggerSDKPROFILE" ..
  227. " PvdRuntimePROFILE" ..
  228. " SceneQueryPROFILE" ..
  229. " SimulationControllerPROFILE" ..
  230. ") -Wl,--end-group"
  231. }
  232. configuration { "release", "linux-*" }
  233. linkoptions
  234. {
  235. "-Wl,--start-group $(addprefix -l," ..
  236. " LowLevelCloth" ..
  237. " PhysX3 " ..
  238. " PhysX3Common" ..
  239. " PxTask" ..
  240. " LowLevel" ..
  241. " PhysX3CharacterKinematic" ..
  242. " PhysX3Cooking" ..
  243. " PhysX3Extensions" ..
  244. " PhysX3Vehicle" ..
  245. " PhysXProfileSDK" ..
  246. " PhysXVisualDebuggerSDK" ..
  247. " PvdRuntime" ..
  248. " SceneQuery" ..
  249. " SimulationController" ..
  250. ") -Wl,--end-group"
  251. }
  252. configuration { "x32", "linux-*" }
  253. defines { "CROWN_LINUX" }
  254. buildoptions
  255. {
  256. "-m32",
  257. "-malign-double"
  258. }
  259. includedirs {
  260. CROWN_THIRD_DIR .. "luajit/x86/include/luajit-2.0",
  261. CROWN_THIRD_DIR .. "physx/x86/include",
  262. CROWN_THIRD_DIR .. "physx/x86/include/common",
  263. CROWN_THIRD_DIR .. "physx/x86/include/characterkinematic",
  264. CROWN_THIRD_DIR .. "physx/x86/include/cloth",
  265. CROWN_THIRD_DIR .. "physx/x86/include/common",
  266. CROWN_THIRD_DIR .. "physx/x86/include/cooking",
  267. CROWN_THIRD_DIR .. "physx/x86/include/extensions",
  268. CROWN_THIRD_DIR .. "physx/x86/include/foundation",
  269. CROWN_THIRD_DIR .. "physx/x86/include/geometry",
  270. CROWN_THIRD_DIR .. "physx/x86/include/particles",
  271. CROWN_THIRD_DIR .. "physx/x86/include/physxprofilesdk",
  272. CROWN_THIRD_DIR .. "physx/x86/include/physxvisualdebuggersdk",
  273. CROWN_THIRD_DIR .. "physx/x86/include/pvd",
  274. CROWN_THIRD_DIR .. "physx/x86/include/pxtask",
  275. CROWN_THIRD_DIR .. "physx/x86/include/RepX",
  276. CROWN_THIRD_DIR .. "physx/x86/include/RepXUpgrader",
  277. CROWN_THIRD_DIR .. "physx/x86/include/vehicle",
  278. CROWN_THIRD_DIR .. "opengl",
  279. CROWN_THIRD_DIR .. "openal/include",
  280. CROWN_THIRD_DIR .. "freetype",
  281. CROWN_THIRD_DIR .. "stb_image",
  282. CROWN_THIRD_DIR .. "stb_vorbis"
  283. }
  284. libdirs
  285. {
  286. CROWN_THIRD_DIR .. "luajit/x86/lib",
  287. CROWN_THIRD_DIR .. "physx/x86/lib"
  288. }
  289. configuration { "x64", "linux-gcc" }
  290. buildoptions
  291. {
  292. "-m64"
  293. }
  294. includedirs {
  295. CROWN_THIRD_DIR .. "luajit/x86_64/include/luajit-2.0",
  296. CROWN_THIRD_DIR .. "physx/x86_64/include",
  297. CROWN_THIRD_DIR .. "physx/x86_64/include/common",
  298. CROWN_THIRD_DIR .. "physx/x86_64/include/characterkinematic",
  299. CROWN_THIRD_DIR .. "physx/x86_64/include/cloth",
  300. CROWN_THIRD_DIR .. "physx/x86_64/include/common",
  301. CROWN_THIRD_DIR .. "physx/x86_64/include/cooking",
  302. CROWN_THIRD_DIR .. "physx/x86_64/include/extensions",
  303. CROWN_THIRD_DIR .. "physx/x86_64/include/foundation",
  304. CROWN_THIRD_DIR .. "physx/x86_64/include/geometry",
  305. CROWN_THIRD_DIR .. "physx/x86_64/include/particles",
  306. CROWN_THIRD_DIR .. "physx/x86_64/include/physxprofilesdk",
  307. CROWN_THIRD_DIR .. "physx/x86_64/include/physxvisualdebuggersdk",
  308. CROWN_THIRD_DIR .. "physx/x86_64/include/pvd",
  309. CROWN_THIRD_DIR .. "physx/x86_64/include/pxtask",
  310. CROWN_THIRD_DIR .. "physx/x86_64/include/RepX",
  311. CROWN_THIRD_DIR .. "physx/x86_64/include/RepXUpgrader",
  312. CROWN_THIRD_DIR .. "physx/x86_64/include/vehicle",
  313. CROWN_THIRD_DIR .. "opengl",
  314. CROWN_THIRD_DIR .. "openal/include",
  315. CROWN_THIRD_DIR .. "freetype",
  316. CROWN_THIRD_DIR .. "stb_image",
  317. CROWN_THIRD_DIR .. "stb_vorbis"
  318. }
  319. libdirs
  320. {
  321. CROWN_THIRD_DIR .. "luajit/x86_64/lib",
  322. CROWN_THIRD_DIR .. "physx/x86_64/lib"
  323. }
  324. configuration { "android"}
  325. kind "SharedLib"
  326. targetdir(CROWN_INSTALL_DIR .. "android") -- must be specified by user -- tmp
  327. defines { "CROWN_ANDROID" }
  328. buildoptions
  329. {
  330. "-std=c++03",
  331. "--sysroot=$(ANDROID_NDK)/platforms/android-18/arch-arm"
  332. }
  333. linkoptions
  334. {
  335. "-Wl,-rpath=\\$$ORIGIN",
  336. "-nostdlib",
  337. "-static-libgcc",
  338. "--sysroot=$(ANDROID_NDK)/platforms/android-18/arch-arm",
  339. "$(ANDROID_NDK)/platforms/android-18/arch-arm/usr/lib/crtbegin_so.o",
  340. "$(ANDROID_NDK)/platforms/android-18/arch-arm/usr/lib/crtend_so.o",
  341. }
  342. links
  343. {
  344. "log",
  345. "android",
  346. "EGL",
  347. "GLESv2",
  348. "z",
  349. "OpenSLES",
  350. }
  351. includedirs {
  352. CROWN_SOURCE_DIR .. "engine/os/android",
  353. CROWN_SOURCE_DIR .. "/engine/renderers/backend/gl/egl",
  354. CROWN_THIRD_DIR .. "luajit/android/include/luajit-2.0",
  355. CROWN_THIRD_DIR .. "physx/android/include",
  356. CROWN_THIRD_DIR .. "physx/android/include/common",
  357. CROWN_THIRD_DIR .. "physx/android/include/characterkinematic",
  358. CROWN_THIRD_DIR .. "physx/android/include/cloth",
  359. CROWN_THIRD_DIR .. "physx/android/include/common",
  360. CROWN_THIRD_DIR .. "physx/android/include/cooking",
  361. CROWN_THIRD_DIR .. "physx/android/include/extensions",
  362. CROWN_THIRD_DIR .. "physx/android/include/foundation",
  363. CROWN_THIRD_DIR .. "physx/android/include/geometry",
  364. CROWN_THIRD_DIR .. "physx/android/include/particles",
  365. CROWN_THIRD_DIR .. "physx/android/include/physxprofilesdk",
  366. CROWN_THIRD_DIR .. "physx/android/include/physxvisualdebuggersdk",
  367. CROWN_THIRD_DIR .. "physx/android/include/pvd",
  368. CROWN_THIRD_DIR .. "physx/android/include/pxtask",
  369. CROWN_THIRD_DIR .. "physx/android/include/RepX",
  370. CROWN_THIRD_DIR .. "physx/android/include/RepXUpgrader",
  371. CROWN_THIRD_DIR .. "physx/android/include/vehicle",
  372. CROWN_THIRD_DIR .. "opengl",
  373. CROWN_THIRD_DIR .. "openal/include",
  374. CROWN_THIRD_DIR .. "freetype",
  375. CROWN_THIRD_DIR .. "stb_image",
  376. CROWN_THIRD_DIR .. "stb_vorbis",
  377. "$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.8/include",
  378. "$(ANDROID_NDK)/sources/android/native_app_glue",
  379. "$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include"
  380. }
  381. libdirs
  382. {
  383. CROWN_THIRD_DIR .. "luajit/android/lib",
  384. CROWN_THIRD_DIR .. "physx/android/lib",
  385. "$(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a",
  386. "$(ANDROID_NDK)/platforms/android-18/arch-arm/usr/lib"
  387. }
  388. excludes
  389. {
  390. CROWN_SOURCE_DIR .. "engine/os/linux/*",
  391. CROWN_SOURCE_DIR .. "engine/os/win/*",
  392. CROWN_SOURCE_DIR .. "engine/renderers/backend/gl/glx/*",
  393. CROWN_SOURCE_DIR .. "engine/renderers/backend/gl/wgl/*",
  394. CROWN_SOURCE_DIR .. "engine/audio/backend/ALSoundWorld.cpp"
  395. }
  396. configuration { "debug", "android" }
  397. linkoptions
  398. {
  399. "-Wl,--start-group $(addprefix -l," ..
  400. " LowLevelClothCHECKED" ..
  401. " PhysX3CHECKED " ..
  402. " PhysX3CommonCHECKED" ..
  403. " PxTaskCHECKED" ..
  404. " LowLevelCHECKED" ..
  405. " PhysX3CharacterKinematicCHECKED" ..
  406. " PhysX3CookingCHECKED" ..
  407. " PhysX3ExtensionsCHECKED" ..
  408. " PhysX3VehicleCHECKED" ..
  409. " PhysXProfileSDKCHECKED" ..
  410. " PhysXVisualDebuggerSDKCHECKED" ..
  411. " PvdRuntimeCHECKED" ..
  412. " SceneQueryCHECKED" ..
  413. " SimulationControllerCHECKED" ..
  414. ") -Wl,--end-group"
  415. }
  416. configuration { "development", "android"}
  417. linkoptions
  418. {
  419. "-Wl,--start-group $(addprefix -l," ..
  420. " LowLevelClothPROFILE" ..
  421. " PhysX3PROFILE " ..
  422. " PhysX3CommonPROFILE" ..
  423. " PxTaskPROFILE" ..
  424. " LowLevelPROFILE" ..
  425. " PhysX3CharacterKinematicPROFILE" ..
  426. " PhysX3CookingPROFILE" ..
  427. " PhysX3ExtensionsPROFILE" ..
  428. " PhysX3VehiclePROFILE" ..
  429. " PhysXProfileSDKPROFILE" ..
  430. " PhysXVisualDebuggerSDKPROFILE" ..
  431. " PvdRuntimePROFILE" ..
  432. " SceneQueryPROFILE" ..
  433. " SimulationControllerPROFILE" ..
  434. ") -Wl,--end-group"
  435. }
  436. configuration { "release", "android"}
  437. linkoptions
  438. {
  439. "-Wl,--start-group $(addprefix -l," ..
  440. " LowLevelCloth" ..
  441. " PhysX3 " ..
  442. " PhysX3Common" ..
  443. " PxTask" ..
  444. " LowLevel" ..
  445. " PhysX3CharacterKinematic" ..
  446. " PhysX3Cooking" ..
  447. " PhysX3Extensions" ..
  448. " PhysX3Vehicle" ..
  449. " PhysXProfileSDK" ..
  450. " PhysXVisualDebuggerSDK" ..
  451. " PvdRuntime" ..
  452. " SceneQuery" ..
  453. " SimulationController" ..
  454. ") -Wl,--end-group"
  455. }