1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
|
----------------------------------------------------------------------
-- Premake4 configuration script for OpenDE
-- Contributed by Jason Perkins (starkos@industriousone.com)
-- For more information on Premake: http://industriousone.com/premake
----------------------------------------------------------------------
ode_version = "0.16"
----------------------------------------------------------------------
-- Demo list: add/remove demos from here and the rest of the build
-- should just work.
----------------------------------------------------------------------
local demos = {
"boxstack",
"buggy",
"cards",
"chain1",
"chain2",
"collision",
"convex",
"crash",
"cylvssphere",
"dball",
"dhinge",
"feedback",
"friction",
"gyroscopic",
"gyro2",
"heightfield",
"hinge",
"I",
"jointPR",
"jointPU",
"joints",
"kinematic",
"motion",
"motor",
"ode",
"piston",
"plane2d",
"rfriction",
"slider",
"space",
"space_stress",
"step",
"transmission"
}
local trimesh_demos = {
"basket",
"cyl",
"moving_convex",
"moving_trimesh",
"tracks",
"trimesh"
}
if not _OPTIONS["no-trimesh"] then
demos = table.join(demos, trimesh_demos)
end
----------------------------------------------------------------------
-- Configuration options
----------------------------------------------------------------------
newoption {
trigger = "with-demos",
description = "Builds the demo applications and DrawStuff library"
}
newoption {
trigger = "with-tests",
description = "Builds the unit test application"
}
newoption {
trigger = "with-gimpact",
description = "Use GIMPACT for trimesh collisions (experimental)"
}
newoption {
trigger = "all-collis-libs",
description = "Include sources of all collision libraries into the project"
}
newoption {
trigger = "with-libccd",
description = "Uses libccd for handling some collision tests absent in ODE."
}
newoption {
trigger = "no-dif",
description = "Exclude DIF (Dynamics Interchange Format) exports"
}
newoption {
trigger = "no-trimesh",
description = "Exclude trimesh collision geometry"
}
newoption {
trigger = "with-ou",
description = "Use TLS for global caches (allows threaded collision checks for separated spaces)"
}
newoption {
trigger = "no-builtin-threading-impl",
description = "Disable built-in multithreaded threading implementation"
}
newoption {
trigger = "no-threading-intf",
description = "Disable threading interface support (external implementations cannot be assigned)"
}
newoption {
trigger = "16bit-indices",
description = "Use 16-bit indices for trimeshes (default is 32-bit)"
}
newoption {
trigger = "old-trimesh",
description = "Use old OPCODE trimesh-trimesh collider"
}
newoption {
trigger = "to",
value = "path",
description = "Set the output location for the generated project files"
}
newoption {
trigger = "only-shared",
description = "Only build shared (DLL) version of the library"
}
newoption {
trigger = "only-static",
description = "Only build static versions of the library"
}
newoption {
trigger = "only-single",
description = "Only use single-precision math"
}
newoption {
trigger = "only-double",
description = "Only use double-precision math"
}
-- always clean all of the optional components and toolsets
if _ACTION == "clean" then
_OPTIONS["with-demos"] = ""
_OPTIONS["with-tests"] = ""
for action in premake.action.each() do
os.rmdir(action.trigger)
end
os.remove("../ode/src/config.h")
os.remove("../include/ode/version.h")
os.remove("../include/ode/precision.h")
os.remove("../libccd/src/ccd/precision.h")
end
-- special validation for Xcode
if _ACTION == "xcode3" and (not _OPTIONS["only-static"] and not _OPTIONS["only-shared"]) then
error(
"Xcode does not support different library types in a single project.\n" ..
"Please use one of the flags: --only-static or --only-shared", 0)
end
-- build the list of configurations, based on the flags. Ends up
-- with configurations like "Debug", "DebugSingle" or "DebugSingleShared"
local configs = { "Debug", "Release" }
local function addconfigs(...)
local newconfigs = { }
for _, root in ipairs(configs) do
for _, suffix in ipairs(arg) do
table.insert(newconfigs, root .. suffix)
end
end
configs = newconfigs
end
if not _OPTIONS["only-single"] and not _OPTIONS["only-double"] then
addconfigs("Single", "Double")
end
if not _OPTIONS["only-shared"] and not _OPTIONS["only-static"] then
addconfigs("DLL", "Lib")
end
----------------------------------------------------------------------
-- The solution, and solution-wide settings
----------------------------------------------------------------------
solution "ode"
language "C++"
uuid "4DA77C12-15E5-497B-B1BB-5100D5161E15"
location ( _OPTIONS["to"] or _ACTION )
includedirs {
"../include",
"../ode/src"
}
defines { "_MT" }
-- apply the configuration list built above
configurations (configs)
configuration { "Debug*" }
defines { "_DEBUG" }
flags { "Symbols" }
configuration { "Release*" }
defines { "NDEBUG", "dNODEBUG" }
flags { "OptimizeSpeed", "NoFramePointer" }
configuration { "*Single*" }
defines { "dIDESINGLE", "CCD_IDESINGLE" }
configuration { "*Double*" }
defines { "dIDEDOUBLE", "CCD_IDEDOUBLE" }
configuration { "Windows" }
defines { "WIN32" }
configuration { "MacOSX" }
linkoptions { "-framework Carbon" }
-- give each configuration a unique output directory
for _, name in ipairs(configurations()) do
configuration { name }
targetdir ( "../lib/" .. name )
end
-- disable Visual Studio security warnings
configuration { "vs*" }
defines { "_CRT_SECURE_NO_DEPRECATE", "_SCL_SECURE_NO_WARNINGS" }
-- enable M_* macros from math.h
configuration { "vs*" }
defines { "_USE_MATH_DEFINES" }
-- don't remember why we had to do this
configuration { "vs2002 or vs2003", "*Lib" }
flags { "StaticRuntime" }
----------------------------------------------------------------------
-- The demo projects, automated from list above. These go first so
-- they will be selected as the active project automatically in IDEs
----------------------------------------------------------------------
if _OPTIONS["with-demos"] then
for _, name in ipairs(demos) do
project ( "demo_" .. name )
kind "ConsoleApp"
location ( _OPTIONS["to"] or _ACTION )
files { "../ode/demo/demo_" .. name .. ".*" }
links { "ode", "drawstuff" }
configuration { "Windows" }
files { "../drawstuff/src/resources.rc" }
links { "user32", "winmm", "gdi32", "opengl32", "glu32" }
configuration { "MacOSX" }
linkoptions { "-framework Carbon -framework OpenGL -framework AGL" }
configuration { "not Windows", "not MacOSX" }
links { "GL", "GLU" }
end
end
----------------------------------------------------------------------
-- The ODE library project
----------------------------------------------------------------------
project "ode"
-- kind "StaticLib"
location ( _OPTIONS["to"] or _ACTION )
includedirs {
"../ode/src/joints",
"../OPCODE",
"../GIMPACT/include",
"../libccd/src/custom",
"../libccd/src"
}
files {
"../include/ode/*.h",
"../ode/src/joints/*.h",
"../ode/src/joints/*.cpp",
"../ode/src/*.h",
"../ode/src/*.c",
"../ode/src/*.cpp",
}
excludes {
"../ode/src/collision_std.cpp",
}
includedirs { "../ou/include" }
files { "../ou/include/**.h", "../ou/src/**.h", "../ou/src/**.cpp" }
defines { "_OU_NAMESPACE=odeou" }
if _OPTIONS["with-ou"] then
defines { "_OU_FEATURE_SET=_OU_FEATURE_SET_TLS" }
elseif not _OPTIONS["no-threading-intf"] then
defines { "_OU_FEATURE_SET=_OU_FEATURE_SET_ATOMICS" }
else
defines { "_OU_FEATURE_SET=_OU_FEATURE_SET_BASICS" }
end
if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then
if _ACTION == "gmake" then
if os.get() == "windows" then
buildoptions { "-mthreads" }
linkoptions { "-mthreads" }
else
buildoptions { "-pthread" }
linkoptions { "-pthread" }
end
end
end
configuration { "no-dif" }
excludes { "../ode/src/export-dif.cpp" }
configuration { "no-trimesh" }
excludes {
"../ode/src/collision_trimesh_colliders.h",
"../ode/src/gimpact_contact_export_helper.cpp",
"../ode/src/gimpact_contact_export_helper.h",
"../ode/src/gimpact_gim_contact_accessor.h",
"../ode/src/gimpact_plane_contact_accessor.h",
"../ode/src/collision_trimesh_internal.cpp",
"../ode/src/collision_trimesh_opcode.cpp",
"../ode/src/collision_trimesh_gimpact.cpp",
"../ode/src/collision_trimesh_box.cpp",
"../ode/src/collision_trimesh_ccylinder.cpp",
"../ode/src/collision_cylinder_trimesh.cpp",
"../ode/src/collision_trimesh_ray.cpp",
"../ode/src/collision_trimesh_sphere.cpp",
"../ode/src/collision_trimesh_trimesh.cpp",
"../ode/src/collision_trimesh_trimesh_old.cpp",
"../ode/src/collision_trimesh_plane.cpp",
"../ode/src/collision_convex_trimesh.cpp"
}
configuration { "not no-trimesh", "with-gimpact or all-collis-libs" }
files { "../GIMPACT/**.h", "../GIMPACT/**.cpp" }
configuration { "not no-trimesh", "not with-gimpact" }
files { "../OPCODE/**.h", "../OPCODE/**.cpp" }
configuration { "not no-trimesh", "not all-collis-libs", "with-gimpact" }
excludes {
"../ode/src/collision_trimesh_opcode.cpp"
}
configuration { "not no-trimesh", "not all-collis-libs", "not with-gimpact" }
excludes {
"../ode/src/gimpact_contact_export_helper.cpp",
"../ode/src/gimpact_contact_export_helper.h",
"../ode/src/gimpact_gim_contact_accessor.h",
"../ode/src/gimpact_plane_contact_accessor.h",
"../ode/src/collision_trimesh_gimpact.cpp"
}
configuration { "with-libccd" }
files { "../libccd/src/custom/ccdcustom/*.h", "../libccd/src/ccd/*.h", "../libccd/src/*.c" }
defines { "dLIBCCD_ENABLED", "dLIBCCD_INTERNAL",
"dLIBCCD_BOX_CYL", "dLIBCCD_CYL_CYL", "dLIBCCD_CAP_CYL", "dLIBCCD_CONVEX_BOX",
"dLIBCCD_CONVEX_CAP", "dLIBCCD_CONVEX_CYL", "dLIBCCD_CONVEX_SPHERE", "dLIBCCD_CONVEX_CONVEX" }
configuration { "not with-libccd" }
excludes { "../ode/src/collision_libccd.cpp", "../ode/src/collision_libccd.h" }
configuration { "windows" }
links { "user32" }
configuration { "only-static or *Lib" }
kind "StaticLib"
defines "ODE_LIB"
configuration { "only-shared or *DLL" }
kind "SharedLib"
defines "ODE_DLL"
configuration { "*DLL" }
defines "_DLL"
configuration { "Debug" }
targetname "oded"
configuration { "Release" }
targetname "ode"
configuration { "DebugSingle*" }
targetname "ode_singled"
configuration { "ReleaseSingle*" }
targetname "ode_single"
configuration { "DebugDouble*" }
targetname "ode_doubled"
configuration { "ReleaseDouble*" }
targetname "ode_double"
----------------------------------------------------------------------
-- Write a custom <config.h> to build, based on the supplied flags
----------------------------------------------------------------------
if _ACTION and _ACTION ~= "clean" then
local infile = io.open("config-default.h", "r")
local text = infile:read("*a")
if _OPTIONS["no-trimesh"] then
text = string.gsub(text, "#define dTRIMESH_ENABLED 1", "/* #define dTRIMESH_ENABLED 1 */")
text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "/* #define dTRIMESH_OPCODE 1 */")
elseif (_OPTIONS["with-gimpact"]) then
text = string.gsub(text, "#define dTRIMESH_OPCODE 1", "#define dTRIMESH_GIMPACT 1")
end
text = string.gsub(text, "/%* #define dOU_ENABLED 1 %*/", "#define dOU_ENABLED 1")
if _OPTIONS["with-ou"] or not _OPTIONS["no-threading-intf"] then
text = string.gsub(text, "/%* #define dATOMICS_ENABLED 1 %*/", "#define dATOMICS_ENABLED 1")
end
if _OPTIONS["with-ou"] then
text = string.gsub(text, "/%* #define dTLS_ENABLED 1 %*/", "#define dTLS_ENABLED 1")
end
if _OPTIONS["no-threading-intf"] then
text = string.gsub(text, "/%* #define dTHREADING_INTF_DISABLED 1 %*/", "#define dTHREADING_INTF_DISABLED 1")
elseif not _OPTIONS["no-builtin-threading-impl"] then
text = string.gsub(text, "/%* #define dBUILTIN_THREADING_IMPL_ENABLED 1 %*/", "#define dBUILTIN_THREADING_IMPL_ENABLED 1")
end
if _OPTIONS["16bit-indices"] then
text = string.gsub(text, "#define dTRIMESH_16BIT_INDICES 0", "#define dTRIMESH_16BIT_INDICES 1")
end
if _OPTIONS["old-trimesh"] then
text = string.gsub(text, "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 0", "#define dTRIMESH_OPCODE_USE_OLD_TRIMESH_TRIMESH_COLLIDER 1")
end
local outfile = io.open("../ode/src/config.h", "w")
outfile:write(text)
outfile:close()
end
----------------------------
-- Write precision headers
----------------------------
if _ACTION and _ACTION ~= "clean" then
function generateheader(headerfile, placeholder, precstr)
local outfile = io.open(headerfile, "w")
for i in io.lines(headerfile .. ".in")
do
local j,_ = string.gsub(i, placeholder, precstr)
--print("writing " .. j .. " into " .. headerfile)
outfile:write(j .. "\n")
end
outfile:close()
end
function generate(precstr)
generateheader("../include/ode/precision.h", "@ODE_PRECISION@", "d" .. precstr)
generateheader("../libccd/src/ccd/precision.h", "@CCD_PRECISION@", "CCD_" .. precstr)
end
if _OPTIONS["only-single"] then
generate("SINGLE")
elseif _OPTIONS["only-double"] then
generate("DOUBLE")
else
generate("UNDEFINEDPRECISION")
end
generateheader("../include/ode/version.h", "@ODE_VERSION@", ode_version)
end
----------------------------------------------------------------------
-- The DrawStuff library project
----------------------------------------------------------------------
if _OPTIONS["with-demos"] then
project "drawstuff"
location ( _OPTIONS["to"] or _ACTION )
files {
"../include/drawstuff/*.h",
"../drawstuff/src/internal.h",
"../drawstuff/src/drawstuff.cpp"
}
configuration { "Debug*" }
targetname "drawstuffd"
configuration { "only-static or *Lib" }
kind "StaticLib"
defines { "DS_LIB" }
configuration { "only-shared or *DLL" }
kind "SharedLib"
defines { "DS_DLL", "USRDLL" }
configuration { "Windows" }
files { "../drawstuff/src/resource.h", "../drawstuff/src/resources.rc", "../drawstuff/src/windows.cpp" }
links { "user32", "opengl32", "glu32", "winmm", "gdi32" }
configuration { "MacOSX" }
defines { "HAVE_APPLE_OPENGL_FRAMEWORK" }
files { "../drawstuff/src/osx.cpp" }
linkoptions { "-framework Carbon -framework OpenGL -framework AGL" }
configuration { "not Windows", "not MacOSX" }
files { "../drawstuff/src/x11.cpp" }
links { "X11", "GL", "GLU" }
end
----------------------------------------------------------------------
-- The automated test application
----------------------------------------------------------------------
if _OPTIONS["with-tests"] then
project "tests"
kind "ConsoleApp"
location ( _OPTIONS["to"] or _ACTION )
includedirs {
"../tests/UnitTest++/src"
}
files {
"../tests/*.cpp",
"../tests/joints/*.cpp",
"../tests/UnitTest++/src/*"
}
links { "ode" }
configuration { "Windows" }
files { "../tests/UnitTest++/src/Win32/*" }
configuration { "not Windows" }
files { "../tests/UnitTest++/src/Posix/*" }
-- add post-build step to automatically run test executable
local path_to_lib = path.getrelative(location(), "../lib")
local command = path.translate(path.join(path_to_lib, "%s/tests"))
for _, name in ipairs(configurations()) do
configuration { name }
postbuildcommands { command:format(name) }
end
end
|