premake4.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. ----------------------------------------------------------------------
  2. -- Premake4 configuration script for OpenDE
  3. -- Contributed by Jason Perkins ([email protected])
  4. -- For more information on Premake: http://industriousone.com/premake
  5. ----------------------------------------------------------------------
  6. ----------------------------------------------------------------------
  7. -- Demo list: add/remove demos from here and the rest of the build
  8. -- should just work.
  9. ----------------------------------------------------------------------
  10. local demos = {
  11. "boxstack",
  12. "buggy",
  13. "cards",
  14. "chain1",
  15. "chain2",
  16. "collision",
  17. "crash",
  18. "cylvssphere",
  19. "feedback",
  20. "friction",
  21. "gyroscopic",
  22. "heightfield",
  23. "hinge",
  24. "I",
  25. "jointPR",
  26. "jointPU",
  27. "joints",
  28. "kinematic",
  29. "motion",
  30. "motor",
  31. "ode",
  32. "piston",
  33. "plane2d",
  34. "slider",
  35. "space",
  36. "space_stress",
  37. "step",
  38. }
  39. local trimesh_demos = {
  40. "basket",
  41. "cyl",
  42. "moving_trimesh",
  43. "trimesh",
  44. }
  45. if not _OPTIONS["no-trimesh"] then
  46. demos = table.join(demos, trimesh_demos)
  47. end
  48. ----------------------------------------------------------------------
  49. -- Configuration options
  50. ----------------------------------------------------------------------
  51. newoption {
  52. trigger = "with-demos",
  53. description = "Builds the demo applications and DrawStuff library"
  54. }
  55. newoption {
  56. trigger = "with-tests",
  57. description = "Builds the unit test application"
  58. }
  59. newoption {
  60. trigger = "with-gimpact",
  61. description = "Use GIMPACT for trimesh collisions (experimental)"
  62. }
  63. newoption {
  64. trigger = "all-collis-libs",
  65. description = "Include sources of all collision libraries into the project"
  66. }
  67. newoption {
  68. trigger = "no-dif",
  69. description = "Exclude DIF (Dynamics Interchange Format) exports"
  70. }
  71. newoption {
  72. trigger = "no-trimesh",
  73. description = "Exclude trimesh collision geometry"
  74. }
  75. newoption {
  76. trigger = "no-alloca",
  77. description = "Use heap memory instead of the stack (experimental)"
  78. }
  79. newoption {
  80. trigger = "enable-ou",
  81. description = "Use TLS for global variables (experimental)"
  82. }
  83. newoption {
  84. trigger = "16bit-indices",
  85. description = "Use 16-bit indices for trimeshes (default is 32-bit)"
  86. }
  87. newoption {
  88. trigger = "old-trimesh",
  89. description = "Use old OPCODE trimesh-trimesh collider"
  90. }
  91. newoption {
  92. trigger = "to",
  93. value = "path",
  94. description = "Set the output location for the generated project files"
  95. }
  96. -- always clean all of the optional components and toolsets
  97. if _ACTION == "clean" then
  98. _OPTIONS["with-demos"] = ""
  99. _OPTIONS["with-tests"] = ""
  100. for action in pairs(premake.actions) do
  101. os.rmdir(action)
  102. end
  103. end
  104. ----------------------------------------------------------------------
  105. -- The solution, and solution-wide settings
  106. ----------------------------------------------------------------------
  107. solution "ode"
  108. language "C++"
  109. uuid "4DA77C12-15E5-497B-B1BB-5100D5161E15"
  110. location ( _OPTIONS["to"] or _ACTION )
  111. includedirs {
  112. "../include",
  113. "../ode/src"
  114. }
  115. -- define all the possible build configurations
  116. configurations {
  117. "DebugSingleDLL", "ReleaseSingleDLL",
  118. "DebugSingleLib", "ReleaseSingleLib",
  119. "DebugDoubleDLL", "ReleaseDoubleDLL",
  120. "DebugDoubleLib", "ReleaseDoubleLib"
  121. }
  122. configuration { "Debug*" }
  123. defines { "_DEBUG" }
  124. flags { "Symbols" }
  125. configuration { "Release*" }
  126. flags { "OptimizeSpeed", "NoFramePointer" }
  127. configuration { "*Single*" }
  128. defines { "dSINGLE" }
  129. configuration { "*Double*" }
  130. defines { "dDOUBLE" }
  131. configuration { "Windows" }
  132. defines { "WIN32" }
  133. configuration { "MacOSX" }
  134. linkoptions { "-framework Carbon" }
  135. -- give each configuration a unique output directory
  136. for _, name in ipairs(configurations()) do
  137. configuration { name }
  138. targetdir ( "../lib/" .. name )
  139. end
  140. -- disable Visual Studio security warnings
  141. configuration { "vs*" }
  142. defines { "_CRT_SECURE_NO_DEPRECATE" }
  143. -- don't remember why we had to do this
  144. configuration { "vs2002 or vs2003", "*Lib" }
  145. flags { "StaticRuntime" }
  146. ----------------------------------------------------------------------
  147. -- The demo projects, automated from list above. These go first so
  148. -- they will be selected as the active project automatically in IDEs
  149. ----------------------------------------------------------------------
  150. if _OPTIONS["with-demos"] then
  151. for _, name in ipairs(demos) do
  152. project ( "demo_" .. name )
  153. kind "ConsoleApp"
  154. location ( _OPTIONS["to"] or _ACTION )
  155. files { "../ode/demo/demo_" .. name .. ".*" }
  156. links { "ode", "drawstuff" }
  157. configuration { "Windows" }
  158. files { "../drawstuff/src/resources.rc" }
  159. links { "user32", "winmm", "gdi32", "opengl32", "glu32" }
  160. configuration { "MacOSX" }
  161. linkoptions { "-framework Carbon -framework OpenGL -framework AGL" }
  162. configuration { "not Windows", "not MacOSX" }
  163. links { "GL", "GLU" }
  164. end
  165. end
  166. ----------------------------------------------------------------------
  167. -- The ODE library project
  168. ----------------------------------------------------------------------
  169. project "ode"
  170. kind "StaticLib"
  171. location ( _OPTIONS["to"] or _ACTION )
  172. includedirs {
  173. "../ode/src/joints",
  174. "../OPCODE",
  175. "../GIMPACT/include",
  176. "../ou/include"
  177. }
  178. files {
  179. "../include/ode/*.h",
  180. "../ode/src/joints/*.h",
  181. "../ode/src/joints/*.cpp",
  182. "../ode/src/*.h",
  183. "../ode/src/*.c",
  184. "../ode/src/*.cpp",
  185. }
  186. excludes {
  187. "../ode/src/collision_std.cpp",
  188. }
  189. configuration { "no-dif" }
  190. excludes { "../ode/src/export-dif.cpp" }
  191. configuration { "no-trimesh" }
  192. excludes {
  193. "../ode/src/collision_trimesh_colliders.h",
  194. "../ode/src/collision_trimesh_internal.h",
  195. "../ode/src/collision_trimesh_opcode.cpp",
  196. "../ode/src/collision_trimesh_gimpact.cpp",
  197. "../ode/src/collision_trimesh_box.cpp",
  198. "../ode/src/collision_trimesh_ccylinder.cpp",
  199. "../ode/src/collision_cylinder_trimesh.cpp",
  200. "../ode/src/collision_trimesh_distance.cpp",
  201. "../ode/src/collision_trimesh_ray.cpp",
  202. "../ode/src/collision_trimesh_sphere.cpp",
  203. "../ode/src/collision_trimesh_trimesh.cpp",
  204. "../ode/src/collision_trimesh_plane.cpp"
  205. }
  206. configuration { "not no-trimesh", "with-gimpact or all-collis-libs" }
  207. files { "../GIMPACT/**.h", "../GIMPACT/**.cpp" }
  208. configuration { "not no-trimesh", "not with-gimpact" }
  209. files { "../OPCODE/**.h", "../OPCODE/**.cpp" }
  210. configuration { "enable-ou" }
  211. files { "../ou/**.h", "../ou/**.cpp" }
  212. defines { "_OU_NAMESPACE=odeou" }
  213. configuration { "windows" }
  214. links { "user32" }
  215. configuration { "*Lib" }
  216. kind "StaticLib"
  217. defines "ODE_LIB"
  218. configuration { "*DLL" }
  219. kind "SharedLib"
  220. defines "ODE_DLL"
  221. configuration { "DebugSingle*" }
  222. targetname "ode_singled"
  223. defines "dSINGLE"
  224. configuration { "ReleaseSingle*" }
  225. targetname "ode_single"
  226. defines "dSINGLE"
  227. configuration { "DebugDouble*" }
  228. targetname "ode_doubled"
  229. defines "dDOUBLE"
  230. configuration { "ReleaseDouble*" }
  231. targetname "ode_double"
  232. defines "dDOUBLE"
  233. ----------------------------------------------------------------------
  234. -- Write a custom <config.h> to src/ode, based on the supplied flags
  235. ----------------------------------------------------------------------
  236. if _ACTION then
  237. io.input("config-default.h")
  238. local text = io.read("*a")
  239. if _OPTIONS["no-trimesh"] then
  240. text = string.gsub(text, "#define dTRIMESH_ENABLED 1", "/* #define dTRIMESH_ENABLED 1 */")
  241. text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "/* #define dTRIMESH_OPCODE 1 */")
  242. elseif (_OPTIONS["with-gimpact"]) then
  243. text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1")
  244. end
  245. if _OPTIONS["no-alloca"] then
  246. text = string.gsub(text, "/%* #define dUSE_MALLOC_FOR_ALLOCA %*/", "#define dUSE_MALLOC_FOR_ALLOCA")
  247. end
  248. if _OPTIONS["enable-ou"] then
  249. text = string.gsub(text, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1")
  250. text = string.gsub(text, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1")
  251. text = string.gsub(text, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1")
  252. end
  253. if _OPTIONS["16bit-indices"] then
  254. text = string.gsub(text, "#define dTRIMESH_16BIT_INDICES 0", "#define dTRIMESH_16BIT_INDICES 1")
  255. end
  256. if _OPTIONS["old-trimesh"] then
  257. text = string.gsub(text, "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0", "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1")
  258. end
  259. io.output("../ode/src/config.h")
  260. io.write(text)
  261. io.close()
  262. end
  263. ----------------------------------------------------------------------
  264. -- The DrawStuff library project
  265. ----------------------------------------------------------------------
  266. if _OPTIONS["with-demos"] then
  267. project "drawstuff"
  268. location ( _OPTIONS["to"] or _ACTION )
  269. files {
  270. "../include/drawstuff/*.h",
  271. "../drawstuff/src/internal.h",
  272. "../drawstuff/src/drawstuff.cpp"
  273. }
  274. configuration { "Debug*" }
  275. targetname "drawstuffd"
  276. configuration { "*Lib" }
  277. kind "StaticLib"
  278. defines { "DS_LIB" }
  279. configuration { "*DLL" }
  280. kind "SharedLib"
  281. defines { "DS_DLL", "USRDLL" }
  282. configuration { "Windows" }
  283. files { "../drawstuff/src/resource.h", "../drawstuff/src/resources.rc", "../drawstuff/src/windows.cpp" }
  284. links { "user32", "opengl32", "glu32", "winmm", "gdi32" }
  285. configuration { "MacOSX" }
  286. defines { "HAVE_APPLE_OPENGL_FRAMEWORK" }
  287. files { "../drawstuff/src/osx.cpp" }
  288. linkoptions { "-framework Carbon -framework OpenGL -framework AGL" }
  289. configuration { "not Windows", "not MacOSX" }
  290. files { "../drawstuff/src/x11.cpp" }
  291. links { "X11", "GL", "GLU" }
  292. end
  293. ----------------------------------------------------------------------
  294. -- The automated test application
  295. ----------------------------------------------------------------------
  296. if _OPTIONS["with-tests"] then
  297. project "tests"
  298. kind "ConsoleApp"
  299. location ( _OPTIONS["to"] or _ACTION )
  300. includedirs {
  301. "../tests/UnitTest++/src"
  302. }
  303. files {
  304. "../tests/*.cpp",
  305. "../tests/joints/*.cpp",
  306. "../tests/UnitTest++/src/*"
  307. }
  308. links { "ode" }
  309. configuration { "Windows" }
  310. files { "../tests/UnitTest++/src/Win32/*" }
  311. configuration { "not Windows" }
  312. files { "../tests/UnitTest++/src/Posix/*" }
  313. -- add post-build step to automatically run test executable
  314. local path_to_lib = path.getrelative(location(), "../lib")
  315. local command = path.translate(path.join(path_to_lib, "%s/tests"))
  316. for _, name in ipairs(configurations()) do
  317. configuration { name }
  318. postbuildcommands { command:format(name) }
  319. end
  320. end