Skip to content
Open
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
4 changes: 4 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ common:qnx_arm64 --test_env=QEMU_CPU=Cascadelake-Server-v5

common:qnx --config=qnx_x86_64

# Enables FlatBuffers-based mw::com configuration tooling (disabled by default,
# see score/mw/com/impl/configuration/flatbuffers_flags.bzl).
common:flatbuffers --//score/mw/com/impl/configuration:enable_flatbuffers=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please name this experimental_enable_flatbuffer_configuration


# unshare /dev/shm and /tmp
test --sandbox_tmpfs_path=/dev/shm
test --sandbox_tmpfs_path=/tmp
Expand Down
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ bazel_dep(name = "bazel_skylib", version = "1.9.0")
bazel_dep(name = "boost.interprocess", version = "1.83.0.bcr.4")
bazel_dep(name = "boost.program_options", version = "1.83.0.bcr.4")
bazel_dep(name = "download_utils", version = "1.2.2")
bazel_dep(name = "flatbuffers", version = "25.12.19")
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
bazel_dep(name = "nlohmann_json", version = "3.11.3")
bazel_dep(name = "platforms", version = "1.0.0")
Expand Down
2 changes: 2 additions & 0 deletions quality/visibility_guard/public_targets.golden
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
//score/mw/com/dependability:mw_com_rst
//score/mw/com/example/com-api-example:com-api-example
//score/mw/com/impl/bindings/mock_binding:generic_skeleton_event
//score/mw/com/impl/configuration/converter:json_to_flatbuffer
//score/mw/com/impl/configuration/converter:mw_com_config.bin
Comment on lines +90 to +91

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should guard this via the experimental flag - and since the experimental flag is per default off, these targets should net yet be publicly visible.

//score/mw/com/impl/configuration:mw_com_config.json
//score/mw/com/impl/configuration:mw_com_config_disabled_trace_config.json
//score/mw/com/impl/configuration:mw_com_config_invalid_trace_config_path.json
Expand Down
30 changes: 30 additions & 0 deletions score/mw/com/impl/configuration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@flatbuffers//:build_defs.bzl", "flatbuffer_cc_library")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//bazel/tools:json_schema_validator.bzl", "validate_json_schema_test")
load("//quality/unit_testing:unit_testing.bzl", "cc_unit_test")
load("//score/mw:common_features.bzl", "COMPILER_WARNING_FEATURES")
load(":flatbuffers_flags.bzl", "FLATBUFFERS_TARGET_COMPATIBLE_WITH", "flatbuffers_build_settings")

validate_json_schema_test(
name = "validate_mw_com_config_schema",
Expand All @@ -24,6 +26,34 @@ validate_json_schema_test(
target_compatible_with = ["@platforms//os:linux"],
)

# Feature flag gating availability of FlatBuffers-based configuration tooling.
# Disabled by default; enable with:
# bazel build --config=flatbuffers //...
flatbuffers_build_settings(
visibility = ["//score/mw/com/impl/configuration:__subpackages__"],
)

# FlatBuffers schema mirroring mw_com_config_schema.json. Compiling it in-build
# validates the schema and provides the generated C++ header (mw_com_config_generated.h)
# to consumers that read the binary configuration produced by the converter tool
# (//score/mw/com/impl/configuration/converter:json_to_flatbuffer).
flatbuffer_cc_library(
name = "mw_com_config_fbs",
srcs = ["mw_com_config.fbs"],
target_compatible_with = FLATBUFFERS_TARGET_COMPATIBLE_WITH,
visibility = ["//score/mw/com:__subpackages__"],
)

# Exported so the converter tool package can reference the schema (as the flatc
# input) and the example config (in its rule/test).
exports_files(
[
"mw_com_config.fbs",
"example/mw_com_config.json",
],
visibility = ["//score/mw/com/impl/configuration/converter:__pkg__"],
)

filegroup(
name = "mw_com_config_schema",
srcs = ["mw_com_config_schema.json"],
Expand Down
59 changes: 59 additions & 0 deletions score/mw/com/impl/configuration/converter/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# *******************************************************************************
# Copyright (c) 2026 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************

load("@rules_python//python:defs.bzl", "py_binary", "py_test")
load("//score/mw/com/impl/configuration:flatbuffers_flags.bzl", "FLATBUFFERS_TARGET_COMPATIBLE_WITH")
load(":json_to_flatbuffer_rule.bzl", "mw_com_config_to_flatbuffer")

py_binary(
name = "json_to_flatbuffer",
srcs = [
"json_to_flatbuffer.py",
],
imports = ["."],
main = "json_to_flatbuffer.py",
visibility = ["//visibility:public"],
)

# Requires FlatBuffers support (see //score/mw/com/impl/configuration:flatbuffers_flags.bzl):
# bazel test --config=flatbuffers :json_to_flatbuffer_test
py_test(
name = "json_to_flatbuffer_test",
size = "small",
srcs = [
"json_to_flatbuffer.py",
"json_to_flatbuffer_test.py",
],
data = [
"//score/mw/com/impl/configuration:example/mw_com_config.json",
"//score/mw/com/impl/configuration:mw_com_config.fbs",
"@flatbuffers//:flatc",
],
env = {
"FLATC_PATH": "$(rootpath @flatbuffers//:flatc)",
},
imports = ["."],
main = "json_to_flatbuffer_test.py",
target_compatible_with = FLATBUFFERS_TARGET_COMPATIBLE_WITH,
)

# Example: build the FlatBuffer binary for the example configuration as part of
# the build graph. Requires FlatBuffers support to be enabled:
# bazel build --config=flatbuffers //score/mw/com/impl/configuration/converter:mw_com_config.bin
mw_com_config_to_flatbuffer(
name = "mw_com_config.bin",
out = "mw_com_config.bin",
config_json = "//score/mw/com/impl/configuration:example/mw_com_config.json",
target_compatible_with = FLATBUFFERS_TARGET_COMPATIBLE_WITH,
visibility = ["//visibility:public"],
)
Loading
Loading