Skip to content

Commit

Permalink
[workspace] Remove globbing from qhull build (RobotLocomotion#17227)
Browse files Browse the repository at this point in the history
Don't build unnecessary files: Coordinates.cpp, PointCoordinates.cpp,
QhullPoints.cpp, QhullStat.cpp, RboxPoints.cpp, rboxlib_r.c.

This makes our build and object code footprint smaller, and enables a
future commit to use a better technique for C++ symbol visibility.
  • Loading branch information
jwnimmer-tri authored May 19, 2022
1 parent e0b3f8c commit fe4431e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 17 deletions.
65 changes: 48 additions & 17 deletions tools/workspace/qhull/package.BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,66 @@ load(

licenses(["notice"]) # Qhull

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

_HDRS_C = glob([
"src/libqhull_r/*.h",
])

_HDRS_CPP = glob([
"src/libqhullcpp/*.h",
])

_SRCS_C = [
"src/libqhull_r/geom2_r.c",
"src/libqhull_r/geom_r.c",
"src/libqhull_r/global_r.c",
"src/libqhull_r/io_r.c",
"src/libqhull_r/libqhull_r.c",
"src/libqhull_r/mem_r.c",
"src/libqhull_r/merge_r.c",
"src/libqhull_r/poly2_r.c",
"src/libqhull_r/poly_r.c",
"src/libqhull_r/qset_r.c",
"src/libqhull_r/random_r.c",
"src/libqhull_r/stat_r.c",
"src/libqhull_r/user_r.c",
"src/libqhull_r/usermem_r.c",
]

_SRCS_CPP = [
"src/libqhullcpp/Qhull.cpp",
"src/libqhullcpp/QhullFacet.cpp",
"src/libqhullcpp/QhullFacetList.cpp",
"src/libqhullcpp/QhullFacetSet.cpp",
"src/libqhullcpp/QhullHyperplane.cpp",
"src/libqhullcpp/QhullPoint.cpp",
"src/libqhullcpp/QhullPointSet.cpp",
"src/libqhullcpp/QhullQh.cpp",
"src/libqhullcpp/QhullRidge.cpp",
"src/libqhullcpp/QhullSet.cpp",
"src/libqhullcpp/QhullUser.cpp",
"src/libqhullcpp/QhullVertex.cpp",
"src/libqhullcpp/QhullVertexSet.cpp",
"src/libqhullcpp/RoadError.cpp",
"src/libqhullcpp/RoadLogEvent.cpp",
]

cc_library(
name = "qhull",
hdrs = glob([
"src/libqhullcpp/*.h",
"src/libqhull_r/*.h",
]),
hdrs = _HDRS_C + _HDRS_CPP,
copts = [
"-fvisibility=hidden",
],
includes = ["src"],
srcs = glob(
[
"src/libqhullcpp/*.cpp",
"src/libqhull_r/*.c",
],
exclude = [
"src/libqhullcpp/qt-qhull.cpp",
"src/libqhullcpp/usermem_r-cpp.cpp",
"src/libqhull_r/userprintf_r.c",
"src/libqhull_r/userprintf_rbox_r.c",
],
),
srcs = _SRCS_C + _SRCS_CPP,
linkstatic = 1,
visibility = ["//visibility:public"],
)

# Install the license file.
install(
name = "install",
docs = ["COPYING.txt"],
visibility = ["//visibility:public"],
)
35 changes: 35 additions & 0 deletions tools/workspace/qhull/patches/disable_dead_code.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Don't try to compile functions that require sources files
that we've omitted from the build.

--- src/libqhullcpp/Qhull.cpp.orig 2020-09-03 19:33:16.000000000 -0700
+++ src/libqhullcpp/Qhull.cpp 2022-05-18 20:26:48.858174235 -0700
@@ -114,6 +114,7 @@
}
}//checkIfQhullInitialized

+#if 0
//! Return feasiblePoint for halfspace intersection
//! If called before runQhull(), then it returns the value from setFeasiblePoint. qh.feasible_string overrides this value if it is defined.
Coordinates Qhull::
@@ -127,6 +128,7 @@
}
return result;
}//feasiblePoint
+#endif

//! Return origin point for qh.input_dim
QhullPoint Qhull::
@@ -188,11 +190,13 @@
return QhullFacetList(beginFacet(), endFacet());
}//facetList

+#if 0
QhullPoints Qhull::
points() const
{
return QhullPoints(qh_qh, qh_qh->hull_dim, qh_qh->num_points*qh_qh->hull_dim, qh_qh->first_point);
}//points
+#endif

QhullPointSet Qhull::
otherPoints() const
3 changes: 3 additions & 0 deletions tools/workspace/qhull/repository.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ def qhull_repository(
commit = "2020.2",
sha256 = "59356b229b768e6e2b09a701448bfa222c37b797a84f87f864f97462d8dbc7c5", # noqa
build_file = "@drake//tools/workspace/qhull:package.BUILD.bazel",
patches = [
"@drake//tools/workspace/qhull:patches/disable_dead_code.patch",
],
mirrors = mirrors,
)

0 comments on commit fe4431e

Please sign in to comment.