diff --git a/examples/boost/BUILD b/examples/boost/BUILD new file mode 100644 index 000000000..bb5b284fc --- /dev/null +++ b/examples/boost/BUILD @@ -0,0 +1,6 @@ +load("//tools/build_defs:boost_build.bzl", "boost_build") + +boost_build( + name = "boost", + lib_source = "@boost//:all" +) \ No newline at end of file diff --git a/examples/cmake_pcl/BUILD b/examples/cmake_pcl/BUILD index 52f193330..6e4c1142e 100644 --- a/examples/cmake_pcl/BUILD +++ b/examples/cmake_pcl/BUILD @@ -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", @@ -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" ], -) +) \ No newline at end of file diff --git a/examples/examples_repositories.bzl b/examples/examples_repositories.bzl index d98724a80..04921706d 100644 --- a/examples/examples_repositories.bzl +++ b/examples/examples_repositories.bzl @@ -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"], + ) diff --git a/tools/build_defs/boost_build.bzl b/tools/build_defs/boost_build.bzl new file mode 100644 index 000000000..5e14798ff --- /dev/null +++ b/tools/build_defs/boost_build.bzl @@ -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, +)