Skip to content

Commit

Permalink
Add a Bazel build for cartographer
Browse files Browse the repository at this point in the history
This does not include cartographer_grpc, nor any of the binaries
(*_main.cc). It has been tested with Bazel 0.9.0 on Ubuntu 14.04 with
the latest (at time of writing) dazel/dazel container, by running:

```
bazel build //...
bazel test //...
```
  • Loading branch information
drigz committed Jan 22, 2018
1 parent 9e30c1e commit 45cc26d
Show file tree
Hide file tree
Showing 26 changed files with 3,074 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build
bazel-*
28 changes: 28 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Cartographer is a system that provides real-time simultaneous localization
# and mapping (SLAM) in 2D and 3D across multiple platforms and sensor
# configurations.

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

exports_files(["LICENSE"])

filegroup(
name = "configuration_files",
srcs = glob([
"configuration_files/*.lua",
]),
)
25 changes: 25 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

workspace(name = "com_github_googlecartographer_cartographer")

load("//:repositories.bzl", "cartographer_repositories")

cartographer_repositories()

# This can't be inside cartographer_repositories() because of:
# https://github.com/bazelbuild/bazel/issues/1550
load("@com_github_nelhage_boost//:boost/boost.bzl", "boost_deps")

boost_deps()
96 changes: 96 additions & 0 deletions cartographer/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Top-level proto and C++ targets for Cartographer.

load("@com_github_antonovvk_bazel_rules//:config.bzl", "cc_fix_config")

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

licenses(["notice"]) # Apache 2.0

proto_library(
name = "protos",
srcs = glob([
"**/*.proto",
]),
deps = [
"@com_google_protobuf//:empty_proto",
],
)

cc_proto_library(
name = "cc_protos",
deps = [":protos"],
)

cc_fix_config(
name = "common_config_h",
cmake = True,
files = {"common/config.h.cmake": "common/config.h"},
values = {
"CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY": "todo_set_config_dir_in_cartographer.BUILD",
"PROJECT_SOURCE_DIR": "todo_set_project_source_dir_in_cartographer.BUILD",
},
visibility = ["//visibility:private"],
)

cc_library(
name = "cartographer",
srcs = glob(
[
"**/*.cc",
],
exclude = [
"**/*_main.cc",
"**/*_test.cc",
],
),
hdrs = [
"common/config.h",
] + glob([
"**/*.h",
]),
includes = ["."],
deps = [
":cc_protos",
"@boost//:iostreams",
"@com_google_glog//:glog",
"@org_cairographics_cairo//:cairo",
"@org_ceres_solver_ceres_solver//:ceres",
"@org_lua_lua//:lua",
"@org_tuxfamily_eigen//:eigen",
],
)

# TODO(rodrigoq): these tests need to read the configuration files, but they're
# not able to find them.
EXCLUDED_TESTS = [
"common/configuration_files_test.cc",
"mapping/map_builder_test.cc",
]

[cc_test(
name = src.replace("/", "_").replace(".cc", ""),
srcs = [src],
deps = [
":cartographer",
"@com_google_googletest//:gtest_main",
],
) for src in glob(
["**/*_test.cc"],
exclude = EXCLUDED_TESTS,
)]
213 changes: 213 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""External dependencies for Cartographer."""

def cartographer_repositories():
_maybe(native.http_archive,
name = "com_github_nelhage_boost",
sha256 = "5c88fc077f6b8111e997fec5146e5f9940ae9a2016eb9949447fcb4b482bcdb3",
strip_prefix = "rules_boost-7289bb1d8f938fdf98078297768c122ee9e11c9e",
urls = [
"https://mirror.bazel.build/github.com/nelhage/rules_boost/archive/7289bb1d8f938fdf98078297768c122ee9e11c9e.tar.gz",
"https://github.com/nelhage/rules_boost/archive/7289bb1d8f938fdf98078297768c122ee9e11c9e.tar.gz",
],
)

_maybe(native.http_archive,
name = "com_github_antonovvk_bazel_rules",
sha256 = "ba75b07d3fd297375a6688e9a16583eb616e7a74b3d5e8791e7a222cf36ab26e",
strip_prefix = "bazel_rules-98ddd7e4f7c63ea0868f08bcc228463dac2f9f12",
urls = [
"https://mirror.bazel.build/github.com/antonovvk/bazel_rules/archive/98ddd7e4f7c63ea0868f08bcc228463dac2f9f12.tar.gz",
"https://github.com/antonovvk/bazel_rules/archive/98ddd7e4f7c63ea0868f08bcc228463dac2f9f12.tar.gz",
],
)

_maybe(native.http_archive,
name = "com_github_gflags_gflags",
sha256 = "6e16c8bc91b1310a44f3965e616383dbda48f83e8c1eaa2370a215057b00cabe",
strip_prefix = "gflags-77592648e3f3be87d6c7123eb81cbad75f9aef5a",
urls = [
"https://mirror.bazel.build/github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
"https://github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
],
)

_maybe(native.http_archive,
name = "com_google_glog",
sha256 = "1ee310e5d0a19b9d584a855000434bb724aa744745d5b8ab1855c85bff8a8e21",
strip_prefix = "glog-028d37889a1e80e8a07da1b8945ac706259e5fd8",
urls = [
"https://mirror.bazel.build/github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz",
"https://github.com/google/glog/archive/028d37889a1e80e8a07da1b8945ac706259e5fd8.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "net_zlib_zlib",
build_file = "//third_party:zlib.BUILD",
sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45",
strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
urls = [
"https://mirror.bazel.build/github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
"https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_cairographics_pixman",
build_file = "//third_party/pixman:pixman.BUILD",
sha256 = "21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e",
strip_prefix = "pixman-0.34.0",
urls = [
"https://mirror.bazel.build/www.cairographics.org/releases/pixman-0.34.0.tar.gz",
"https://www.cairographics.org/releases/pixman-0.34.0.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_cairographics_cairo",
build_file = "//third_party/cairo:cairo.BUILD",
sha256 = "7e87878658f2c9951a14fc64114d4958c0e65ac47530b8ac3078b2ce41b66a09",
strip_prefix = "cairo-1.14.10",
urls = [
"https://mirror.bazel.build/www.cairographics.org/releases/cairo-1.14.10.tar.xz",
"https://www.cairographics.org/releases/cairo-1.14.10.tar.xz",
],
)

_maybe(native.new_http_archive,
name = "org_freetype_freetype2",
build_file = "//third_party:freetype2.BUILD",
sha256 = "33a28fabac471891d0523033e99c0005b95e5618dc8ffa7fa47f9dadcacb1c9b",
strip_prefix = "freetype-2.8",
urls = [
"https://mirror.bazel.build/download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz",
"http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_libgd_libgd",
build_file = "//third_party:gd.BUILD",
sha256 = "a66111c9b4a04e818e9e2a37d7ae8d4aae0939a100a36b0ffb52c706a09074b5",
strip_prefix = "libgd-2.2.5",
urls = [
"https://mirror.bazel.build/github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz",
"https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_freedesktop_fontconfig",
build_file = "//third_party/fontconfig:fontconfig.BUILD",
sha256 = "fd5a6a663f4c4a00e196523902626654dd0c4a78686cbc6e472f338e50fdf806",
strip_prefix = "fontconfig-2.12.4",
urls = [
"https://mirror.bazel.build/www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.gz",
"https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_ceres_solver_ceres_solver",
build_file = "//third_party:ceres.BUILD",
sha256 = "cb69d1ca4900bc9c4703116a9facba00413eafd893430659fab63246f5320288",
strip_prefix = "ceres-solver-f58eacf082ddf198b2bf982e3cdb57ed3b5ea025",
urls = [
"https://mirror.bazel.build/github.com/ceres-solver/ceres-solver/archive/f58eacf082ddf198b2bf982e3cdb57ed3b5ea025.tar.gz",
"https://github.com/ceres-solver/ceres-solver/archive/f58eacf082ddf198b2bf982e3cdb57ed3b5ea025.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_tuxfamily_eigen",
build_file = "//third_party:eigen.BUILD",
sha256 = "ca7beac153d4059c02c8fc59816c82d54ea47fe58365e8aded4082ded0b820c4",
strip_prefix = "eigen-eigen-f3a22f35b044",
urls = [
"http://mirror.bazel.build/bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",
"https://bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "com_github_libexpat_libexpat",
build_file = "//third_party:expat.BUILD",
sha256 = "b5dcb503e40f615a0296a18acc6d975f2f1a3d01c7b3a4b3bb69de27bc9475c3",
strip_prefix = "libexpat-R_2_2_4/expat",
urls = [
"https://mirror.bazel.build/github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz",
"https://github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "libjpeg",
build_file = "//third_party:libjpeg.BUILD",
sha256 = "240fd398da741669bf3c90366f58452ea59041cacc741a489b99f2f6a0bad052",
strip_prefix = "jpeg-9b",
urls = [
"https://mirror.bazel.build/www.ijg.org/files/jpegsrc.v9b.tar.gz",
"http://www.ijg.org/files/jpegsrc.v9b.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_libpng_libpng",
build_file = "//third_party:libpng.BUILD",
sha256 = "7f415186d38ca71c23058386d7cf5135c8beda821ee1beecdc2a7a26c0356615",
strip_prefix = "libpng-1.2.57",
urls = [
"https://mirror.bazel.build/github.com/glennrp/libpng/archive/v1.2.57.tar.gz",
"https://github.com/glennrp/libpng/archive/v1.2.57.tar.gz",
],
)

_maybe(native.http_archive,
name = "com_google_googletest",
sha256 = "c18f281fd6621bb264570b99860a0241939b4a251c9b1af709b811d33bc63af8",
strip_prefix = "googletest-e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d",
urls = [
"https://mirror.bazel.build/github.com/google/googletest/archive/e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d.tar.gz",
"https://github.com/google/googletest/archive/e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d.tar.gz",
],
)

_maybe(native.http_archive,
name = "com_google_protobuf",
sha256 = "0cc6607e2daa675101e9b7398a436f09167dffb8ca0489b0307ff7260498c13c",
strip_prefix = "protobuf-3.5.0",
urls = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.5.0.tar.gz",
"https://github.com/google/protobuf/archive/v3.5.0.tar.gz",
],
)

_maybe(native.new_http_archive,
name = "org_lua_lua",
build_file = "//third_party:lua.BUILD",
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
strip_prefix = "lua-5.2.4",
urls = [
"https://mirror.bazel.build/www.lua.org/ftp/lua-5.2.4.tar.gz",
"https://www.lua.org/ftp/lua-5.2.4.tar.gz",
],
)


def _maybe(repo_rule, name, **kwargs):
if name not in native.existing_rules():
repo_rule(name=name, **kwargs)
20 changes: 20 additions & 0 deletions third_party/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Bazel build support for third-party packages.

exports_files(
glob(["*.BUILD"]),
visibility = ["//visibility:public"],
)
Loading

0 comments on commit 45cc26d

Please sign in to comment.