Skip to content

Commit 81f5910

Browse files
Enable bazel build (core only) (#1144)
Signed-off-by: Shameek Ganguly <[email protected]>
1 parent 6bfbf92 commit 81f5910

File tree

14 files changed

+240
-68
lines changed

14 files changed

+240
-68
lines changed

.bazelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
common --enable_bzlmod
2+
common --lockfile_mode=off
3+
4+
# Add C++17 compiler flags.
5+
build --cxxopt=-std=c++17
6+
build --host_cxxopt=-std=c++17
7+
8+
build --force_pic
9+
build --strip=never
10+
build --strict_system_includes
11+
build --fission=dbg
12+
build --features=per_object_debug_info
13+
14+
# Enable header processing, required for layering checks with parse_header.
15+
build --process_headers_in_dependencies

.bazelversion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.3.1

.github/workflows/bazel.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Bazel CI
2+
on:
3+
push:
4+
branches: [gz-rendering9, main]
5+
pull_request:
6+
branches: [gz-rendering9, main]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test:
14+
uses: bazel-contrib/.github/.github/workflows/[email protected]
15+
with:
16+
folders: |
17+
[
18+
".",
19+
]
20+
exclude: |
21+
[
22+
{"folder": ".", "bzlmodEnabled": false},
23+
]

.github/workflows/ci.bazelrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file contains Bazel settings to apply on CI only.
2+
# It is referenced with a --bazelrc option in the call to bazel in ci.yaml
3+
4+
# Debug where options came from
5+
build --announce_rc
6+
# This directory is configured in GitHub actions to be persisted between runs.
7+
# We do not enable the repository cache to cache downloaded external artifacts
8+
# as these are generally faster to download again than to fetch them from the
9+
# GitHub actions cache.
10+
build --disk_cache=~/.cache/bazel
11+
# Don't rely on test logs being easily accessible from the test runner,
12+
# though it makes the log noisier.
13+
test --test_output=errors
14+
# Allows tests to run bazelisk-in-bazel, since this is the cache folder used
15+
test --test_env=XDG_CACHE_HOME

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ build_*
55
# OS generated files
66
.DS_Store
77
*.swp
8+
9+
# Bazel generated files
10+
bazel-*

BUILD.bazel

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
load("@rules_gazebo//gazebo:headers.bzl", "gz_configure_header", "gz_export_header")
2+
load("@rules_license//rules:license.bzl", "license")
3+
4+
package(
5+
default_applicable_licenses = [":license"],
6+
features = [
7+
"layering_check",
8+
"parse_headers",
9+
],
10+
)
11+
12+
license(
13+
name = "license",
14+
package_name = "gz-rendering",
15+
)
16+
17+
licenses(["notice"])
18+
19+
exports_files([
20+
"package.xml",
21+
"LICENSE",
22+
"MODULE.bazel",
23+
])
24+
25+
gz_configure_header(
26+
name = "Config",
27+
src = "include/gz/rendering/config.hh.in",
28+
package_xml = "package.xml",
29+
)
30+
31+
gz_export_header(
32+
name = "Export",
33+
out = "include/gz/rendering/Export.hh",
34+
export_base = "GZ_RENDERING",
35+
lib_name = "gz-rendering",
36+
)
37+
38+
public_headers_no_gen = glob([
39+
"include/gz/rendering/*.hh",
40+
"include/gz/rendering/base/*.hh",
41+
])
42+
43+
public_headers = public_headers_no_gen + [
44+
"include/gz/rendering/config.hh",
45+
"include/gz/rendering/Export.hh",
46+
]
47+
48+
sources = glob(
49+
[
50+
"src/*.cc",
51+
"src/base/*.cc",
52+
"src/bazel/*.cc",
53+
],
54+
exclude = ["src/*_TEST.cc"],
55+
)
56+
57+
cc_library(
58+
name = "gz-rendering",
59+
srcs = sources,
60+
hdrs = public_headers,
61+
includes = ["include"],
62+
local_defines = [
63+
"GZ_RENDERING_PLUGIN_PATH='\"\"'",
64+
"GZ_RENDERING_RELATIVE_RESOURCE_PATH='\"\"'",
65+
"GZ_RENDERING_ENGINE_RELATIVE_INSTALL_DIR='\"\"'",
66+
],
67+
visibility = ["//visibility:public"],
68+
deps = [
69+
"@gz-common",
70+
"@gz-common//events",
71+
"@gz-common//geospatial",
72+
"@gz-common//graphics",
73+
"@gz-math",
74+
"@gz-plugin//:loader",
75+
"@gz-utils//:ImplPtr",
76+
"@gz-utils//:SuppressWarning",
77+
],
78+
)
79+
80+
test_sources = glob([
81+
"src/*_TEST.cc",
82+
])
83+
84+
[
85+
cc_test(
86+
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
87+
srcs = [src],
88+
deps = [
89+
":gz-rendering",
90+
"@googletest//:gtest",
91+
"@googletest//:gtest_main",
92+
"@gz-common//geospatial",
93+
],
94+
)
95+
for src in test_sources
96+
]

MODULE.bazel

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## MODULE.bazel
2+
module(
3+
name = "gz-rendering",
4+
repo_name = "org_gazebosim_gz-rendering",
5+
)
6+
7+
bazel_dep(name = "googletest", version = "1.15.2")
8+
bazel_dep(name = "rules_license", version = "1.0.0")
9+
10+
# Gazebo Dependencies
11+
bazel_dep(name = "rules_gazebo", version = "0.0.3")
12+
bazel_dep(name = "gz-common")
13+
bazel_dep(name = "gz-math")
14+
bazel_dep(name = "gz-plugin")
15+
bazel_dep(name = "gz-utils")
16+
17+
archive_override(
18+
module_name = "gz-common",
19+
strip_prefix = "gz-common-gz-common6",
20+
urls = ["https://github.com/gazebosim/gz-common/archive/refs/heads/gz-common6.tar.gz"],
21+
)
22+
23+
archive_override(
24+
module_name = "gz-math",
25+
strip_prefix = "gz-math-gz-math8",
26+
urls = ["https://github.com/gazebosim/gz-math/archive/refs/heads/gz-math8.tar.gz"],
27+
)
28+
29+
archive_override(
30+
module_name = "gz-plugin",
31+
strip_prefix = "gz-plugin-gz-plugin3",
32+
urls = ["https://github.com/gazebosim/gz-plugin/archive/refs/heads/gz-plugin3.tar.gz"],
33+
)
34+
35+
archive_override(
36+
module_name = "gz-utils",
37+
strip_prefix = "gz-utils-gz-utils3",
38+
urls = ["https://github.com/gazebosim/gz-utils/archive/refs/heads/gz-utils3.tar.gz"],
39+
)

include/gz/rendering/Utils.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ namespace gz
8787
const float _offset = 0.0);
8888

8989
/// \brief Get the screen scaling factor.
90-
/// \return The screen scaling factor.
90+
/// This function always returns a value of 1.0 and will be marked as
91+
/// deprecated in the next release.
92+
/// \return Always returns a scaling factor of 1.0
9193
GZ_RENDERING_VISIBLE
9294
float screenScalingFactor();
9395

include/gz/rendering/base/BaseLidarVisual.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include <vector>
2121

22+
#include <gz/common/Console.hh>
23+
2224
#include "gz/rendering/LidarVisual.hh"
2325
#include "gz/rendering/base/BaseObject.hh"
2426
#include "gz/rendering/base/BaseRenderTypes.hh"

include/gz/rendering/base/BaseMesh.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include <map>
2121
#include <string>
2222
#include <unordered_map>
23+
24+
#include <gz/common/Console.hh>
25+
2326
#include "gz/rendering/Mesh.hh"
2427
#include "gz/rendering/RenderEngine.hh"
2528
#include "gz/rendering/Storage.hh"

0 commit comments

Comments
 (0)