Skip to content

Commit

Permalink
Add flann dependency to fix kdtree, segmentation, and search
Browse files Browse the repository at this point in the history
Previously, these libraries would appear to build, but would fail to
link when actually used in the deps of a cc_binary.

This commit also adds all the examples to the pcl build file. This will
help ensure the pcl libraries actually link properly in the future.

The examples that depend on visualization are added, but commented out
with a TODO.
  • Loading branch information
kgreenek committed Feb 16, 2022
1 parent bd7530f commit 04e3267
Show file tree
Hide file tree
Showing 4 changed files with 441 additions and 16 deletions.
39 changes: 26 additions & 13 deletions bzl/repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

def pcl_repositories():
_maybe_repo(
maybe(
http_archive,
name = "com_github_nelhage_rules_boost",
sha256 = "b64e6f7e96c5b0d7ebcb74c5ee29ab879b8ef8c37581ed0be5ff6c23168da985",
strip_prefix = "rules_boost-ed844db5990d21b75dc3553c057069f324b3916b",
urls = ["https://github.com/nelhage/rules_boost/archive/ed844db5990d21b75dc3553c057069f324b3916b.tar.gz"],
)

_maybe_repo(
maybe(
http_archive,
name = "eigen",
build_file = "@rules_pcl//third_party:eigen.BUILD",
Expand All @@ -24,7 +25,26 @@ def pcl_repositories():
urls = ["https://github.com/eigenteam/eigen-git-mirror/archive/3.3.7.tar.gz"],
)

_maybe_repo(
# Latest commit as of April 6, 2019
maybe(
http_archive,
name = "flann",
build_file = "@rules_pcl//third_party:flann.BUILD",
sha256 = "9080a91be5759a0b4ef41f62e58896a714ec85d37c2567341a0503039655b1eb",
strip_prefix = "flann-1d04523268c388dabf1c0865d69e1b638c8c7d9d",
urls = ["https://github.com/flann-lib/flann/archive/1d04523268c388dabf1c0865d69e1b638c8c7d9d.tar.gz"],
)

maybe(
http_archive,
name = "lz4",
build_file = "@rules_pcl//third_party:lz4.BUILD",
sha256 = "030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1",
strip_prefix = "lz4-1.9.3",
urls = ["https://github.com/lz4/lz4/archive/refs/tags/v1.9.3.tar.gz"],
)

maybe(
http_archive,
name = "net_zlib_zlib",
sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45",
Expand All @@ -36,7 +56,7 @@ def pcl_repositories():
],
)

_maybe_repo(
maybe(
http_archive,
name = "org_libpng_libpng",
build_file = "@rules_pcl//third_party:libpng.BUILD",
Expand All @@ -48,7 +68,7 @@ def pcl_repositories():
],
)

_maybe_repo(
maybe(
http_archive,
name = "pcl",
build_file = "@rules_pcl//third_party:pcl.BUILD",
Expand All @@ -57,18 +77,11 @@ def pcl_repositories():
urls = ["https://github.com/PointCloudLibrary/pcl/archive/1d3622c1e624994bc013e3e66bc5d98fbb807a89.tar.gz"],
)

_maybe_repo(
maybe(
http_archive,
name = "qhull",
build_file = "@rules_pcl//third_party:qhull.BUILD",
sha256 = "cf7235b76244595a86b9407b906e3259502b744528318f2178155e5899d6cf9f",
strip_prefix = "qhull-2019.1",
urls = ["https://github.com/qhull/qhull/archive/2019.1.tar.gz"],
)

def _maybe_repo(repo_rule, name, **kwargs):
"""A wrapper around repo rules to prevent adding a rule if it already exists, e.g. if it was
already added to a user's WORKSPACE file by other dependencies.
"""
if name not in native.existing_rules():
repo_rule(name = name, **kwargs)
25 changes: 25 additions & 0 deletions third_party/flann.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
licenses(["notice"]) # BSD 3-Clause

# Do not support cuda for now.
FLANN_CUDA_HDRS = [
"cpp/flann/algorithms/all_indices.h",
"cpp/flann/algorithms/kdtree_cuda_builder.h",
"cpp/flann/util/cutil_math.h",
]

cc_library(
name = "flann",
hdrs = glob(
[
"src/cpp/flann/*.h",
"src/cpp/flann/*.hpp",
"src/cpp/flann/algorithms/*.h",
"src/cpp/flann/nn/*.h",
"src/cpp/flann/util/*.h",
],
exclude = FLANN_CUDA_HDRS,
),
includes = ["src/cpp"],
visibility = ["//visibility:public"],
deps = ["@lz4"],
)
24 changes: 24 additions & 0 deletions third_party/lz4.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
licenses(["notice"]) # BSD 2-Clause

cc_library(
name = "lz4",
srcs = [
"lib/lz4.c",
"lib/lz4frame.c",
"lib/lz4hc.c",
"lib/xxhash.c",
],
hdrs = [
"lib/lz4.h",
"lib/lz4frame.h",
"lib/lz4frame_static.h",
"lib/lz4hc.h",
"lib/xxhash.h",
],
include_prefix = "lz4",
includes = ["lib"],
strip_include_prefix = "lib",
# This c file is included by lib/lz4hc.c
textual_hdrs = ["lib/lz4.c"],
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 04e3267

Please sign in to comment.