Skip to content

Commit

Permalink
Bazel module
Browse files Browse the repository at this point in the history
* Uses the temporary BCR fork from
  https://github.com/stonier/bazel-central-registry [1]
* MODULE.bazel - package and dependency information
* BUILD.bazel - build rules
* build.yml - a bazel build task

[1] It will take some time to get yaml-cpp, tinyxml and maliput into
the BCR itself.

NB: This is basic build only - tests and a working plugin framework in
bazel yet to come.

Signed-off-by: Daniel Stonier <d.stonier@gmail.com>
  • Loading branch information
stonier committed Sep 19, 2023
1 parent 555a300 commit a84563b
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 3 deletions.
31 changes: 31 additions & 0 deletions .bazelrc
@@ -0,0 +1,31 @@
########################################
# Bzlmod Configuration
########################################

# Uncomment to build with bzlmod (i.e. use MODULE.bazel) or
# use --enable_bzlmod on the command line.
common --enable_bzlmod

# TODO(daniel.stonier) Delete once 'yaml-cpp' has made it into the official BCR
build --registry=https://raw.githubusercontent.com/stonier/bazel-central-registry/maliput_releases/

########################################
# Bazel Configuration
########################################

# https://bazel.build/docs/user-manual#verbose-failures
build --verbose_failures

########################################
# C++ Configuration
########################################

build --cxxopt="-std=c++17"
build --cxxopt="-Werror"

# Silence compiler warnings for external dependencies.
# - https://github.com/bazelbuild/bazel/commit/08936aecb96f2937c61bdedfebcf1c5a41a0786d
build --features=external_include_paths
# In case that the above feature leaks some warnings, silence all warnings from the 'external' folder.
# If in the future there are warnings leaked from other 3rd libs, add more 'per_file_copt' to include their paths.
build --per_file_copt=external.*\.(cc|cpp|h|hpp|c)@-w
2 changes: 1 addition & 1 deletion .devcontainer/README.md
Expand Up @@ -30,7 +30,7 @@ Locally:
* Open a terminal in the container and run

```
(docker) zen@bazel-zen:/workspaces/maliput$ bazel build //...
(docker) zen@bazel-zen:/workspaces/maliput_malidrive$ bazel build //...
```

CodeSpaces:
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/build.yml
Expand Up @@ -11,9 +11,27 @@ env:
PACKAGE_NAME: maliput_malidrive
ROS_DISTRO: foxy


# Cancel previously running PR jobs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
compile_and_test:
name: Compile and test
bazel:
name: Compile and Test (Bazel)
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}-bazel-ci:latest
steps:
- uses: actions/checkout@v3
- name: Build
shell: bash
run: |
bazel build //...
cmake:
name: Compile and Test (CMake)
runs-on: ubuntu-latest
container:
image: ubuntu:20.04
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -33,3 +33,6 @@

# Python caches
__pycache__

# Bazel
bazel-*
96 changes: 96 additions & 0 deletions BUILD.bazel
@@ -0,0 +1,96 @@

# TODO(daniel.stonier): revise these, get in sync with cmake/DefaultCFlags.cmake.
# Be aware though that many do not work across platforms, e.g. there is no
# cross-platform mechanism for setting std=c++17 in bazel

COPTS = [
"-std=c++17",
"-Wno-builtin-macro-redefined",
"-Wno-missing-field-initializers",
"-Wno-unused-const-variable",

# Others from cmake/DefaultCFlags.cmake
# "-fdata-sections",
# "-fdiagnostics-color=always"
# "-ffunction-sections"
# "-fopenmp"
# "-fPIC"
# "-fstack-protector"
# "-fno-omit-frame-pointer"
# "-no-canonical-prefixes"
# "-Wall"
# "-Wregister"
# "-Wstrict-overflow"

# Some flags that were used in the TRI build
# "-Wno-unused-parameter",
# "-Wno-missing-braces",
# "-Wno-pessimizing-move",
# "-Wno-self-assign",
# "-Wno-deprecated-declarations",
# "-Wno-unused-private-field",
# "-Wno-maybe-uninitialized",
# "-Wno-deprecated-register",
]

cc_library(
name = "utility",
srcs = glob(["src/utility/**/*.cc"]),
hdrs = glob(["src/utility/**/*.h"]),
copts = COPTS,
strip_include_prefix = "src",
visibility = ["//visibility:public"],
)

cc_library(
name = "maliput_malidrive_public_headers",
hdrs = glob(["include/maliput_malidrive/**/*.h"]),
copts = COPTS,
strip_include_prefix = "include",
visibility = ["//visibility:public"],
deps = [
"@maliput//:api",
"@maliput//:base",
"@maliput//:common",
"@maliput//:plugin",
"@maliput//:geometry_base",
],
)

cc_library(
name = "maliput_malidrive",
srcs = glob(["src/maliput_malidrive/**/*.cc"]),
hdrs = glob(["src/maliput_malidrive/**/*.h"]),
copts = COPTS,
strip_include_prefix = "src",
visibility = ["//visibility:public"],
deps = [
":maliput_malidrive_public_headers",
":utility",
"@maliput//:api",
"@maliput//:base",
"@maliput//:geometry_base",
"@maliput//:utility",
"@maliput//:drake",
"@tinyxml2//:tinyxml2"
],
)

cc_library(
name = "plugin",
srcs = glob(["src/plugin/**/*.cc"]),
copts = COPTS,
visibility = ["//visibility:public"],
deps = [
":maliput_malidrive",
"@maliput//:api",
"@maliput//:base",
"@maliput//:common",
],
)

filegroup(
name = "xodr_resources",
srcs = glob(["resources/**/*"]),
visibility = ["//visibility:public"],
)
16 changes: 16 additions & 0 deletions MODULE.bazel
@@ -0,0 +1,16 @@
"""
Welcome to Maliput Malidrive!
"""

module(
name = "maliput_malidrive",
compatibility_level = 1,
version = "0.1.4",
)

bazel_dep(name = "rules_cc", version = "0.0.8")
bazel_dep(name = "maliput", version = "1.1.1")
bazel_dep(name = "tinyxml2", version = "9.0.0")

# bazel_dep(name = "fmt", version = "10.1.0", dev_dependency = True)
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)
1 change: 1 addition & 0 deletions WORKSPACE.bazel
@@ -0,0 +1 @@
workspace(name = "maliput_malidrive")

0 comments on commit a84563b

Please sign in to comment.