premake4.lua 11 KB

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