Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#7582 from jamiesnape/shared-bullet
Browse files Browse the repository at this point in the history
Use shared libraries for Bullet
  • Loading branch information
sammy-tri authored Dec 12, 2017
2 parents a5bc1bc + c215ecb commit 97e5e79
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 60 deletions.
6 changes: 3 additions & 3 deletions tools/install/libdrake/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ cc_library(
# required *.so's that are WORKSPACE downloads (such as VTK, Gurobi, etc).
#
# TODO(jwnimmer-tri) Ideally, Bazel should be able to handle the depended-on
# *.so files (Gurobi, LCM, Mosek, SCS, TinyXML2, VTK) for us, without us having
# to know up-front here which dependencies are coming from the WORKSPACE in the
# form of *.so.
# *.so files for us, without us having to know up-front here which dependencies
# are coming from the WORKSPACE in the form of *.so.
cc_library(
name = "drake_shared_library",
hdrs = [":libdrake_headers"],
Expand All @@ -122,6 +121,7 @@ cc_library(
":gurobi_deps",
":mosek_deps",
":vtk_deps",
"@bullet//:BulletCollision",
"@lcm",
"@scs//:scsdir",
"@tinyxml2",
Expand Down
29 changes: 5 additions & 24 deletions tools/workspace/bullet/bullet-create-cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,24 @@
"Cps-Version": "0.8.0",
"Name": "Bullet",
"Description": "Real-time collision detection and multi-physics simulation",
"License": "Zlib",
"Version": "%s",
"Default-Components": [
":BulletCollision",
":BulletDynamics"
"License": [
"LGPL-2.1+",
"Zlib"
],
"Version": "%s",
"Default-Components": [":BulletCollision"],
"Components": {
"BulletCollision": {
"Type": "dylib",
"Location": "@prefix@/lib/libBulletCollision.so",
"Includes": ["@prefix@/include/bullet"],
"Requires": [":LinearMath"]
},
"BulletDynamics": {
"Type": "dylib",
"Location": "@prefix@/lib/libBulletDynamics.so",
"Includes": ["@prefix@/include/bullet"],
"Requires": [
":BulletCollision",
":LinearMath"
]
},
"LinearMath": {
"Type": "dylib",
"Location": "@prefix@/lib/libLinearMath.so",
"Definitions": ["BT_USE_DOUBLE_PRECISION"],
"Includes": ["@prefix@/include/bullet"]
},
"BulletSoftBody": {
"Type": "dylib",
"Location": "@prefix@/lib/libBulletSoftBody.so",
"Includes": ["@prefix@/include/bullet"],
"Requires": [
":BulletCollision",
":BulletDynamics",
":LinearMath"
]
}
}
}
Expand Down
64 changes: 31 additions & 33 deletions tools/workspace/bullet/bullet.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,53 +16,53 @@ BULLET_COPTS = ["-Wno-all"]

BULLET_INCLUDES = ["src"]

LINEAR_MATH_HDRS = glob(["src/LinearMath/**/*.h"])

# Keep defines in sync with Components.LinearMath.Definitions in
# bullet-create-cps.py.
cc_library(
name = "LinearMath",
srcs = glob(["src/LinearMath/**/*.cpp"]),
hdrs = glob(["src/LinearMath/**/*.h"]),
LINEAR_MATH_DEFINES = ["BT_USE_DOUBLE_PRECISION"]

cc_binary(
name = "libLinearMath.so",
srcs = glob(["src/LinearMath/**/*.cpp"]) + LINEAR_MATH_HDRS,
copts = BULLET_COPTS,
defines = ["BT_USE_DOUBLE_PRECISION"],
defines = LINEAR_MATH_DEFINES,
includes = BULLET_INCLUDES,
linkshared = 1,
visibility = ["//visibility:private"],
)

cc_library(
name = "BulletCollision",
srcs = glob(["src/BulletCollision/**/*.cpp"]),
hdrs = glob(["src/BulletCollision/**/*.h"]) + [
"src/btBulletCollisionCommon.h",
],
name = "LinearMath",
srcs = ["libLinearMath.so"],
hdrs = LINEAR_MATH_HDRS,
copts = BULLET_COPTS,
defines = LINEAR_MATH_DEFINES,
includes = BULLET_INCLUDES,
deps = [":LinearMath"],
)

cc_library(
name = "BulletDynamics",
srcs = glob(["src/BulletDynamics/**/*.cpp"]),
hdrs = glob(["src/BulletDynamics/**/*.h"]) + [
"src/btBulletDynamicsCommon.h",
],
BULLET_COLLISION_HDRS = glob(["src/BulletCollision/**/*.h"]) + [
"src/btBulletCollisionCommon.h",
]

# BulletCollision contains LGPL code so only build shared library.
cc_binary(
name = "libBulletCollision.so",
srcs = glob(["src/BulletCollision/**/*.cpp"]) + BULLET_COLLISION_HDRS,
copts = BULLET_COPTS,
includes = BULLET_INCLUDES,
deps = [
":BulletCollision",
":LinearMath",
],
linkshared = 1,
visibility = ["//visibility:private"],
deps = [":LinearMath"],
)

cc_library(
name = "BulletSoftBody",
srcs = glob(["src/BulletSoftBody/**/*.cpp"]),
hdrs = glob(["src/BulletSoftBody/**/*.h"]),
name = "BulletCollision",
srcs = ["libBulletCollision.so"],
hdrs = BULLET_COLLISION_HDRS,
copts = BULLET_COPTS,
includes = BULLET_INCLUDES,
deps = [
":BulletCollision",
":BulletDynamics",
":LinearMath",
],
deps = [":LinearMath"],
)

cmake_config(
Expand All @@ -76,10 +76,8 @@ install_cmake_config(package = "Bullet")
install(
name = "install",
targets = [
":BulletCollision",
":BulletDynamics",
":BulletSoftBody",
":LinearMath",
":libBulletCollision.so",
":libLinearMath.so",
],
hdr_dest = "include/bullet",
hdr_strip_prefix = BULLET_INCLUDES,
Expand Down

0 comments on commit 97e5e79

Please sign in to comment.