Skip to content

Commit

Permalink
implements pcl cmake_external build rule (#68)
Browse files Browse the repository at this point in the history
* implements pcl cmake_external build rule

* Improve example with building PCL (Point Cloud Library):

- build boost library and use it as dependency
- add/correct some properties

* implements pcl cmake_external build rule

* Improve example with building PCL (Point Cloud Library):

- build boost library and use it as dependency
- add/correct some properties
  • Loading branch information
bbarnes52 authored and irengrig committed Sep 5, 2018
1 parent 6f81b6e commit 9949b17
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 10 deletions.
6 changes: 6 additions & 0 deletions examples/boost/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("//tools/build_defs:boost_build.bzl", "boost_build")

boost_build(
name = "boost",
lib_source = "@boost//:all"
)
43 changes: 33 additions & 10 deletions examples/cmake_pcl/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
load("//tools/build_defs:cmake.bzl", "cmake_external")
load("//tools/build_defs:boost_build.bzl", "boost_build")

# This takes something about 10 minutes
boost_build(
name = "boost",
lib_source = "@boost//:all"
)

cmake_external(
name = "openblas",
Expand All @@ -17,35 +24,51 @@ cmake_external(
"BLAS_LIBRARIES": "$EXT_BUILD_DEPS/openblas/lib/libopenblas.a",
},
headers_only = True,
out_include_dir = "include/eigen3",
lib_source = "@eigen//:all",
deps = [":openblas"],
)


cmake_external(
name = "flann",
cache_entries = {
},
lib_source = "@flann//:all",
static_libraries = [
"libflann_s.a",
"libflann_cpp_s.a",
],
static_libraries = ["libflann_s.a"],
)

# todo additional dependencies needed
# This takes about an hour
cmake_external(
name = "pcl",
cache_entries = {
"WITH_LIBUSB": "no",
"EIGEN_INCLUDE_DIR": "$EXT_BUILD_DEPS/eigen/include",
"EIGEN_INCLUDE_DIRS": "$EXT_BUILD_DEPS/eigen/include/eigen3",
"EIGEN_INCLUDE_DIR": "$EXT_BUILD_DEPS/eigen/include/eigen3",
"FLANN_LIBRARY": "$EXT_BUILD_DEPS/flann/lib/libflann_s.a",
"FLANN_INCLUDE_DIRS": "$EXT_BUILD_DEPS/flann/include",
"FLANN_INCLUDE_DIR": "$EXT_BUILD_DEPS/flann/include",
"WITH_PNG": "no",
"WITH_QHULL": "no",
"WITH_CUDA": "no",
"WITH_QT": "no",
"WITH_VTK": "no",
"WITH_PCAP": "no",
"WITH_OPENGL": "no",
"WITH_OPENNI": "no",
"WITH_OPENNI2": "no",
"WITH_FZAPI": "no",
"WITH_ENSENSO": "no",
"WITH_DAVIDSDK": "no",
"WITH_DSSDK": "no",
"WITH_RSSDK": "no",
"BOOST_ROOT": "$EXT_BUILD_DEPS/boost/",
"BOOST_INCLUDEDIR": "$EXT_BUILD_DEPS/boost/include",
},
cmake_options = ["-DBUILD_WITH_OPENMP=False"],
headers_only = True,
lib_source = "@pcl//:all",
out_include_dir = "include/pcl-1.8",
deps = [
":eigen",
":flann",
":boost"
],
)
)
8 changes: 8 additions & 0 deletions examples/examples_repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,11 @@ def include_examples_repositories():
strip_prefix = "pcl-pcl-1.8.1",
urls = ["https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.tar.gz"],
)

http_archive(
name = "boost",
build_file_content = all_content,
strip_prefix = "boost_1_68_0",
sha256 = "da3411ea45622579d419bfda66f45cd0f8c32a181d84adfa936f5688388995cf",
urls = ["https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz"],
)
80 changes: 80 additions & 0 deletions tools/build_defs/boost_build.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
""" Rule for building Boost from sources. """

load(
"//tools/build_defs:framework.bzl",
"CC_EXTERNAL_RULE_ATTRIBUTES",
"cc_external_rule_impl",
"create_attrs",
)
load("//tools/build_defs:detect_root.bzl", "detect_root")

def _boost_build(ctx):
root = detect_root(ctx.attr.lib_source)

configure_script = "\n".join([
"cd $INSTALLDIR",
"cp -R $EXT_BUILD_ROOT/{}/. .".format(root),
"./bootstrap.sh",
])

attrs = create_attrs(
ctx.attr,
configure_name = "BuildBoost",
configure_script = configure_script,
make_commands = ["./b2 install --prefix=."],
static_libraries = [
"libboost_atomic.a",
"libboost_chrono.a",
"libboost_container.a",
"libboost_context.a",
"libboost_contract.a",
"libboost_coroutine.a",
"libboost_date_time.a",
"libboost_exception.a",
"libboost_fiber.a",
"libboost_filesystem.a",
"libboost_graph.a",
"libboost_iostreams.a",
"libboost_locale.a",
"libboost_log.a",
"libboost_log_setup.a",
"libboost_math_c99.a",
"libboost_math_c99f.a",
"libboost_math_c99l.a",
"libboost_math_tr1.a",
"libboost_math_tr1f.a",
"libboost_math_tr1l.a",
"libboost_numpy27.a",
"libboost_prg_exec_monitor.a",
"libboost_program_options.a",
"libboost_python27.a",
"libboost_random.a",
"libboost_regex.a",
"libboost_serialization.a",
"libboost_signals.a",
"libboost_stacktrace_addr2line.a",
"libboost_stacktrace_backtrace.a",
"libboost_stacktrace_basic.a",
"libboost_stacktrace_noop.a",
"libboost_system.a",
"libboost_test_exec_monitor.a",
"libboost_thread.a",
"libboost_timer.a",
"libboost_type_erasure.a",
"libboost_unit_test_framework.a",
"libboost_wave.a",
"libboost_wserialization.a",
]
)
return cc_external_rule_impl(ctx, attrs)

""" Rule for building Boost. Invokes bootstrap.sh and then b2 install.
Attributes:
boost_srcs - target with the boost sources
"""
boost_build = rule(
attrs = CC_EXTERNAL_RULE_ATTRIBUTES,
fragments = ["cpp"],
output_to_genfiles = True,
implementation = _boost_build,
)

0 comments on commit 9949b17

Please sign in to comment.