Skip to content

Commit

Permalink
Switch to ignition-math4.
Browse files Browse the repository at this point in the history
This is going to be needed to move to newer versions of ignition
libraries, newer sdformat, and for delphyne going forward.  While
we are at it, make ignition-math a shared library.

Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Dec 20, 2017
1 parent bc84e73 commit 3f91c0a
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 51 deletions.
6 changes: 3 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ new_local_repository(
bitbucket_archive(
name = "ignition_math",
repository = "ignitionrobotics/ign-math",
commit = "ignition-math3_3.2.0",
sha256 = "1948c1610fa4403bce7ba2a262a29662990ee66aab00882411a0868afe0e5309", # noqa
strip_prefix = "ignitionrobotics-ign-math-e86e5bb392e4",
commit = "392237e10ba4",
sha256 = "44068bb91c07c9305213057cad801ae5b689ac1a5f37cd8330dd6e729df8f5b0", # noqa
strip_prefix = "ignitionrobotics-ign-math-392237e10ba4",
build_file = "tools/workspace/ignition_math/ignition_math.BUILD.bazel",
)

Expand Down
1 change: 1 addition & 0 deletions tools/install/libdrake/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ cc_library(
":mosek_deps",
":vtk_deps",
"@bullet//:BulletCollision",
"@ignition_math",
"@lcm",
"@libprotobuf",
"@scs//:scsdir",
Expand Down
8 changes: 4 additions & 4 deletions tools/install/libdrake/drake.cps
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"Hints": ["@prefix@/lib/cmake/gflags"],
"X-CMake-Find-Args": ["CONFIG"]
},
"ignition-math3": {
"Version": "3.2.0",
"Hints": ["@prefix@/lib/cmake/ignition-math3"],
"ignition-math4": {
"Version": "4.0.0",
"Hints": ["@prefix@/lib/cmake/ignition-math4"],
"X-CMake-Find-Args": ["CONFIG"]
},
"ignition-rndf0": {
Expand Down Expand Up @@ -112,7 +112,7 @@
"Bullet:BulletCollision",
"Eigen3:Eigen",
"fcl:fcl",
"ignition-math3:ignition-math3",
"ignition-math4:ignition-math4",
"ignition-rndf0:ignition-rndf0",
"lcm:lcm",
"optitrack:lcmtypes_optitrack-cpp",
Expand Down
8 changes: 4 additions & 4 deletions tools/workspace/ignition_math/ignition_math-create-cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

from drake.tools.install.cpsutils import read_version_defs

def_re = "#define IGNITION_MATH_VERSION_FULL[\s]\"([0-9]+).([0-9]+).([0-9]+)\""
def_re = "#define IGNITION_MATH_VERSION_FULL[\s]\"([0-9]+).([0-9]+).([0-9]+).*\""
defs = read_version_defs(def_re)

content = """
{
"Cps-Version": "0.8.0",
"Name": "ignition-math3",
"Name": "ignition-math4",
"Description": "Math classes and functions for robot applications",
"License": "Apache-2.0",
"Version": "%(VERSION_MAJOR)s.%(VERSION_MINOR)s.%(VERSION_PATCH)s",
"Default-Components": [ ":ignition-math3" ],
"Default-Components": [ ":ignition-math4" ],
"Components": {
"ignition-math3": {
"ignition-math4": {
"Type": "dylib",
"Location": "@prefix@/lib/libignition_math.so",
"Includes": [ "@prefix@/include" ]
Expand Down
84 changes: 53 additions & 31 deletions tools/workspace/ignition_math/ignition_math.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,44 @@ load(
"install",
"install_cmake_config",
)
load("@drake//tools/workspace:generate_file.bzl", "generate_file")

package(default_visibility = ["//visibility:public"])

# Generates config.hh based on the version numbers in CMake code.
cmake_configure_file(
name = "config",
src = "cmake/config.hh.in",
src = "include/ignition/math/config.hh.in",
out = "include/ignition/math/config.hh",
cmakelists = ["CMakeLists.txt"],
defines = [
# It would be nice to get this information directly from
# CMakeLists.txt, but it ends up being too hard. ignition-math sets a
# project name as "ignition-math<version>", and then uses CMake
# substring to pick that version out. We'd have to extend the
# cmake_configure_file functionality to do the same, and I'm not sure
# it is worth it. We just hard code the major version here.
"PROJECT_MAJOR_VERSION=4",
"PROJECT_MINOR_VERSION=0",
"PROJECT_PATCH_VERSION=0",
"PROJECT_VERSION=4.0",
"PROJECT_VERSION_FULL=4.0.0~pre3",
"PROJECT_NAME_NO_VERSION=ignition-math",
"PROJECT_MAJOR_VERSION=3",
"PROJECT_VERSION_FULL=3.2.0",
],
visibility = ["//visibility:private"],
)

public_headers = [
generate_file(
name = "export_genrule",
out = "include/ignition/math/Export.hh",
content = """
#pragma once
#define IGNITION_MATH_VISIBLE __attribute__ ((visibility("default")))
#define IGN_DEPRECATED(version) __attribute__ ((__deprecated__))
""",
visibility = ["//visibility:private"],
)

public_headers_no_gen = [
"include/ignition/math/Angle.hh",
"include/ignition/math/Box.hh",
"include/ignition/math/Color.hh",
"include/ignition/math/Export.hh",
"include/ignition/math/Filter.hh",
"include/ignition/math/Frustum.hh",
"include/ignition/math/Helpers.hh",
Expand All @@ -66,24 +77,27 @@ public_headers = [
"include/ignition/math/SignalStats.hh",
"include/ignition/math/SphericalCoordinates.hh",
"include/ignition/math/Spline.hh",
"include/ignition/math/System.hh",
"include/ignition/math/Temperature.hh",
"include/ignition/math/Triangle.hh",
"include/ignition/math/Triangle3.hh",
"include/ignition/math/Vector2.hh",
"include/ignition/math/Vector3.hh",
"include/ignition/math/Vector3Stats.hh",
"include/ignition/math/Vector4.hh",
"include/ignition/math/graph/Edge.hh",
"include/ignition/math/graph/GraphAlgorithms.hh",
"include/ignition/math/graph/Graph.hh",
"include/ignition/math/graph/Vertex.hh",
]

private_headers = [
"include/ignition/math/BoxPrivate.hh",
"include/ignition/math/FrustumPrivate.hh",
"include/ignition/math/KmeansPrivate.hh",
"include/ignition/math/RotationSplinePrivate.hh",
"include/ignition/math/SignalStatsPrivate.hh",
"include/ignition/math/SplinePrivate.hh",
"include/ignition/math/Vector3StatsPrivate.hh",
"src/BoxPrivate.hh",
"src/FrustumPrivate.hh",
"src/KmeansPrivate.hh",
"src/RotationSplinePrivate.hh",
"src/SignalStatsPrivate.hh",
"src/SplinePrivate.hh",
"src/Vector3StatsPrivate.hh",
]

# Generates math.hh, which consists of #include statements for all of the
Expand All @@ -93,22 +107,25 @@ private_headers = [
drake_generate_include_header(
name = "mathhh_genrule",
out = "include/ignition/math.hh",
hdrs = [":config"] + public_headers,
hdrs = public_headers_no_gen + ["include/ignition/math/config.hh"],
)

check_lists_consistency(
file_list = private_headers + public_headers,
file_list = private_headers + public_headers_no_gen,
glob = ["include/**/*.hh"],
)

public_headers = public_headers_no_gen + [
"include/ignition/math/config.hh",
"include/ignition/math.hh",
]

# Generates the library exported to users. The explicitly listed srcs= matches
# upstream's explicitly listed sources plus private headers. The explicitly
# listed hdrs= matches upstream's public headers.
cc_library(
name = "ignition_math",
cc_binary(
name = "libignition_math.so",
srcs = [
"include/ignition/math.hh",
"include/ignition/math/config.hh", # created above
"src/Angle.cc",
"src/Box.cc",
"src/Color.cc",
Expand All @@ -126,13 +143,21 @@ cc_library(
"src/SplinePrivate.cc",
"src/Temperature.cc",
"src/Vector3Stats.cc",
] + private_headers,
] + private_headers + public_headers,
includes = ["include"],
linkshared = 1,
visibility = [],
)

cc_library(
name = "ignition_math",
srcs = ["libignition_math.so"],
hdrs = public_headers,
includes = ["include"],
visibility = ["//visibility:public"],
)

CMAKE_PACKAGE = "ignition-math3"
CMAKE_PACKAGE = "ignition-math4"

cmake_config(
package = CMAKE_PACKAGE,
Expand All @@ -146,11 +171,8 @@ install_cmake_config(package = CMAKE_PACKAGE)
install(
name = "install",
workspace = CMAKE_PACKAGE,
targets = [":ignition_math"],
hdrs = public_headers + [
":config",
":mathhh_genrule",
],
targets = [":libignition_math.so"],
hdrs = public_headers,
hdr_strip_prefix = ["include"],
docs = [
"COPYING",
Expand Down
8 changes: 4 additions & 4 deletions tools/workspace/ignition_rndf/ignition_rndf-create-cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"License": "Apache-2.0",
"Version": "%(MAJOR_VERSION)s.%(MINOR_VERSION)s.%(PATCH_VERSION)s",
"Requires": {
"ignition-math3": {
"Version": "%(ignition-math3_VERSION)s",
"Hints": ["@prefix@/lib/cmake/ignition-math3"],
"ignition-math4": {
"Version": "%(ignition-math4_VERSION)s",
"Hints": ["@prefix@/lib/cmake/ignition-math4"],
"X-CMake-Find-Args": [ "CONFIG" ]
}
},
Expand All @@ -26,7 +26,7 @@
"Type": "dylib",
"Location": "@prefix@/lib/libignition_rndf.so",
"Includes": [ "@prefix@/include" ],
"Requires": [ "ignition-math3:ignition-math3" ]
"Requires": [ "ignition-math4:ignition-math4" ]
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions tools/workspace/sdformat/sdformat-create-cps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"Version": "1.58",
"X-CMake-Find-Args": ["MODULE"]
},
"ignition-math3": {
"Version": "%(ignition-math3_VERSION)s",
"Hints": ["@prefix@/lib/cmake/ignition-math3"],
"X-CMake-Find-Args": ["CONFIG"]
"ignition-math4": {
"Version": "%(ignition-math4_VERSION)s",
"Hints": ["@prefix@/lib/cmake/ignition-math4"],
"X-CMake-Find-Args": [ "CONFIG" ]
}
},
"Default-Components": [ ":sdformat" ],
Expand All @@ -33,7 +33,7 @@
"Link-Flags": ["-ltinyxml"],
"Requires": [
"Boost:boost",
"ignition-math3:ignition-math3"
"ignition-math4:ignition-math4"
]
}
}
Expand Down

0 comments on commit 3f91c0a

Please sign in to comment.