Skip to content

Commit 8fb86d5

Browse files
Removing flatbuffers dependency
1 parent 39bbd3d commit 8fb86d5

21 files changed

Lines changed: 260 additions & 972 deletions

File tree

MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ bazel_dep(name = "rules_oci", version = "2.3.0")
2525
bazel_dep(name = "aspect_rules_lint", version = "2.0.0")
2626
bazel_dep(name = "buildifier_prebuilt", version = "8.2.0.2")
2727
bazel_dep(name = "platforms", version = "1.0.0")
28-
bazel_dep(name = "flatbuffers", version = "25.12.19")
2928
bazel_dep(name = "download_utils", version = "1.2.2")
3029
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
3130

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/flatbuffers_rules.bzl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
def _flatbuffer_json_to_bin_impl(ctx):
2+
flatc = ctx.executable.flatc
3+
json = ctx.file.json
4+
schema = ctx.file.schema
5+
6+
# flatc will name the file the same as the json (can't be changed)
7+
out_name = json.basename[:-len(".json")] + ".bin"
8+
out = ctx.actions.declare_file(out_name, sibling = json)
9+
10+
# flatc args ---------------------------------
11+
flatc_args = [
12+
"-b",
13+
"-o",
14+
out.dirname,
15+
]
16+
17+
for inc in ctx.attr.includes:
18+
flatc_args.extend(["-I", inc.path])
19+
20+
if ctx.attr.strict_json:
21+
flatc_args.append("--strict-json")
22+
23+
flatc_args.extend([schema.path, json.path])
24+
# --------------------------------------------
25+
26+
ctx.actions.run(
27+
inputs = [json, schema] + list(ctx.files.includes),
28+
outputs = [out],
29+
executable = flatc,
30+
arguments = flatc_args,
31+
progress_message = "flatc generation {}".format(json.short_path),
32+
mnemonic = "FlatcGeneration",
33+
)
34+
35+
rf = ctx.runfiles(
36+
files = [out],
37+
root_symlinks = {
38+
("_main/" + ctx.attr.out_dir + "/" + out_name): out,
39+
},
40+
)
41+
42+
return DefaultInfo(files = depset([out]), runfiles = rf)
43+
44+
flatbuffer_json_to_bin = rule(
45+
implementation = _flatbuffer_json_to_bin_impl,
46+
attrs = {
47+
"json": attr.label(
48+
allow_single_file = [".json"],
49+
mandatory = True,
50+
doc = "Json file to convert. Note that the binary file will have the same name as the json (minus the suffix)",
51+
),
52+
"schema": attr.label(
53+
allow_single_file = [".fbs"],
54+
mandatory = True,
55+
doc = "FBS file to use",
56+
),
57+
"out_dir": attr.string(
58+
default = "etc",
59+
doc = "Directory to copy the generated file to, sibling to 'src' and 'tests' dirs. Do not include a trailing '/'",
60+
),
61+
"flatc": attr.label(
62+
default = Label("@flatbuffers//:flatc"),
63+
executable = True,
64+
cfg = "exec",
65+
doc = "Reference to the flatc binary",
66+
),
67+
# flatc arguments
68+
"includes": attr.label_list(
69+
allow_files = True,
70+
doc = "Flatc include paths",
71+
),
72+
"strict_json": attr.bool(
73+
default = False,
74+
doc = "Require strict JSON (no trailing commas etc)",
75+
),
76+
},
77+
)

examples/demo_verification/BUILD

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,8 @@ pkg_files(
3737

3838
pkg_files(
3939
name = "examples_etc_files",
40-
srcs = [":examples_test_config"],
41-
prefix = "tests/examples",
42-
)
43-
44-
pkg_files(
45-
name = "examples_logging_files",
4640
srcs = [
41+
":examples_test_config",
4742
"ecu_logging_config.json",
4843
"hm_logging.json",
4944
"logging.json",
@@ -55,7 +50,6 @@ pkg_tar(
5550
name = "examples_binaries",
5651
srcs = [
5752
":examples_etc_files",
58-
":examples_logging_files",
5953
":examples_main_files",
6054
],
6155
)

score/launch_manager/daemon/src/alive_monitor/BUILD

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,6 @@
1212
# *******************************************************************************
1313
load("@rules_cc//cc:defs.bzl", "cc_library")
1414

15-
filegroup(
16-
name = "am_flatcfg_fbs",
17-
srcs = ["config/hm_flatcfg.fbs"],
18-
visibility = ["//visibility:public"],
19-
)
20-
21-
filegroup(
22-
name = "am_core_flatcfg_fbs",
23-
srcs = ["config/hmcore_flatcfg.fbs"],
24-
visibility = ["//visibility:public"],
25-
)
26-
27-
exports_files(["config/hm_flatcfg.fbs"])
28-
29-
cc_library(
30-
name = "config",
31-
hdrs = [
32-
"config/hm_flatcfg_generated.h",
33-
"config/hmcore_flatcfg_generated.h",
34-
],
35-
include_prefix = "score/mw/launch_manager/alive_monitor",
36-
strip_include_prefix = "/score/launch_manager/daemon/src/alive_monitor",
37-
visibility = ["//score/launch_manager/daemon/src/alive_monitor:__subpackages__"],
38-
)
3915

4016
cc_library(
4117
name = "alive_monitor_h",

score/launch_manager/daemon/src/alive_monitor/config/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ cc_library(
4040
":hm_config",
4141
":hmcore_config",
4242
],
43-
strip_include_prefix = ".",
43+
include_prefix = "score/mw/launch_manager/alive_monitor/config",
4444
visibility = ["//visibility:public"],
4545
)

0 commit comments

Comments
 (0)