Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bzlmod #599

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
common --enable_bzlmod
common --lockfile_mode=off

# Add C++17 compiler flags.
build --cxxopt=-std=c++17
build --host_cxxopt=-std=c++17

build --force_pic
build --strip=never
build --strict_system_includes
build --fission=dbg
build --features=per_object_debug_info
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.0.0
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# CMake folders
build
build_*

# OS generated files
.DS_Store
*.swp

# Python generaated files
*.pyc

# Bazel generated files
bazel-*
83 changes: 38 additions & 45 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_configure_header",
"gz_export_header",
"gz_include_header",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)
load("@buildifier_prebuilt//:rules.bzl", "buildifier", "buildifier_test")
load("@rules_gz//gz:headers.bzl", "gz_configure_header", "gz_export_header", "gz_include_header")
load("@rules_license//rules:license.bzl", "license")

package(
default_applicable_licenses = [GZ_ROOT + "common:license"],
default_visibility = GZ_VISIBILITY,
features = GZ_FEATURES,
default_applicable_licenses = [":license"],
)

license(
name = "license",
package_name = "gz-common",
)

licenses(["notice"])

exports_files(["LICENSE"])
exports_files([
"LICENSE",
"MODULE.bazel",
])

gz_configure_header(
name = "config",
Expand All @@ -45,26 +33,21 @@ gz_export_header(
public_headers_no_gen = glob([
"include/gz/common/*.hh",
"include/gz/common/detail/*.hh",
"include/gz/common/graph/*.hh",
])

private_headers = glob(["src/*.hh"])

sources = glob(
["src/*.cc"],
exclude = [
"src/Plugin.cc",
"src/PluginLoader.cc",
"src/*_TEST.cc",
],
exclude = ["src/*_TEST.cc"],
)

gz_include_header(
name = "commonhh_genrule",
name = "common_hh_genrule",
out = "include/gz/common.hh",
hdrs = public_headers_no_gen + [
"include/gz/common/config.hh",
"include/gz/common/Export.hh",
"include/gz/common/config.hh",
],
)

Expand All @@ -75,39 +58,49 @@ public_headers = public_headers_no_gen + [
]

cc_library(
name = "common",
name = "gz-common",
srcs = sources + private_headers,
hdrs = public_headers,
copts = [
"-fexceptions",
"-Wno-unused-value",
],
copts = ["-fexceptions"],
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
GZ_ROOT + "utils",
GZ_ROOT + "math",
"@uuid",
"@gz-utils",
"@libuuid//:uuid",
],
)

# Tests
test_sources = glob(
include = ["src/*_TEST.cc"],
exclude = [
"src/PluginUtils_TEST.cc",
"src/PluginLoader_TEST.cc",
[
"src/*_TEST.cc",
],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
copts = ["-fexceptions"],
deps = [
":common",
GZ_ROOT + "common/testing",
"@gtest",
"@gtest//:gtest_main",
":gz-common",
"//testing",
"@gz-math",
"@googletest//:gtest_main",
],
) for src in test_sources]

add_lint_tests()
# Bazel linting
buildifier(
name = "buildifier.fix",
exclude_patterns = ["./.git/*"],
lint_mode = "fix",
mode = "fix",
)

buildifier_test(
name = "buildifier.test",
exclude_patterns = ["./.git/*"],
lint_mode = "warn",
mode = "diff",
no_sandbox = True,
workspace = "//:MODULE.bazel",
)
15 changes: 15 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## MODULE.bazel
module(
name = "gz-common",
repo_name = "org_gazebosim_gz-common",
)

bazel_dep(name = "buildifier_prebuilt", version = "6.1.2")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "rules_license", version = "0.0.8")

bazel_dep(name = "rules_gz")
bazel_dep(name = "gz-utils")
bazel_dep(name = "gz-math")

bazel_dep(name = "libuuid", version = "2.39.3.bcr.1")
Empty file added WORKSPACE.bazel
Empty file.
82 changes: 0 additions & 82 deletions av/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,82 +0,0 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_export_header",
"gz_include_header",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)

package(
default_applicable_licenses = [GZ_ROOT + "common:license"],
features = GZ_FEATURES,
)

public_headers_no_gen = glob([
"include/gz/common/*.hh",
"include/gz/common/**/*.hh",
])

sources = glob(
["src/*.cc"],
exclude = ["src/*_TEST.cc"],
)

test_sources = glob(["src/*_TEST.cc"])

gz_export_header(
name = "include/gz/common/av/Export.hh",
export_base = "GZ_COMMON_AV",
lib_name = "gz-common-av",
visibility = ["//visibility:private"],
)

gz_include_header(
name = "av_hh_genrule",
out = "include/gz/common/av.hh",
hdrs = public_headers_no_gen + [
"include/gz/common/av/Export.hh",
],
)

public_headers = public_headers_no_gen + [
"include/gz/common/av/Export.hh",
"include/gz/common/av.hh",
]

cc_library(
name = "av",
srcs = sources,
hdrs = public_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "utils",
"@ffmpeg//:libavcodec",
"@ffmpeg//:libavformat",
"@ffmpeg//:libavutil",
"@ffmpeg//:libswscale",
],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
data = [GZ_ROOT + "common/test:data"],
env = {
"GZ_BAZEL": "1",
"GZ_BAZEL_PATH": "common",
},
deps = [
":av",
GZ_ROOT + "common/testing",
"@gtest//:gtest_main",
],
) for src in test_sources]

add_lint_tests()
73 changes: 0 additions & 73 deletions events/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,73 +0,0 @@
load(
"@gz//bazel/skylark:build_defs.bzl",
"GZ_FEATURES",
"GZ_ROOT",
"GZ_VISIBILITY",
"gz_export_header",
"gz_include_header",
)
load(
"@gz//bazel/lint:lint.bzl",
"add_lint_tests",
)

package(
default_applicable_licenses = [GZ_ROOT + "common:license"],
features = GZ_FEATURES,
)

public_headers_no_gen = glob([
"include/gz/common/*.hh",
"include/gz/common/**/*.hh",
])

sources = glob(
["src/*.cc"],
exclude = ["src/*_TEST.cc"],
)

test_sources = glob(["src/*_TEST.cc"])

gz_export_header(
name = "include/gz/common/events/Export.hh",
export_base = "GZ_COMMON_EVENTS",
lib_name = "gz-common-events",
visibility = ["//visibility:private"],
)

gz_include_header(
name = "events_hh_genrule",
out = "include/gz/common/events.hh",
hdrs = public_headers_no_gen + [
"include/gz/common/events/Export.hh",
],
)

public_headers = public_headers_no_gen + [
"include/gz/common/events/Export.hh",
"include/gz/common/events.hh",
]

cc_library(
name = "events",
srcs = sources,
hdrs = public_headers,
includes = ["include"],
visibility = GZ_VISIBILITY,
deps = [
GZ_ROOT + "common",
GZ_ROOT + "utils",
],
)

[cc_test(
name = src.replace("/", "_").replace(".cc", "").replace("src_", ""),
srcs = [src],
deps = [
":events",
GZ_ROOT + "common/testing",
"@gtest//:gtest_main",
],
) for src in test_sources]

add_lint_tests()
Loading
Loading