Skip to content

Commit 56ca39e

Browse files
Making changes backwards compatible
1 parent b77e8da commit 56ca39e

9 files changed

Lines changed: 67 additions & 26 deletions

File tree

examples/demo_verification/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pkg_files(
4343
"logging.json",
4444
":examples_test_config",
4545
],
46-
prefix = "tests/examples/etc",
46+
prefix = "tests/examples",
4747
)
4848

4949
pkg_tar(

scripts/config_mapping/config.bzl

Lines changed: 60 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
22
load("@score_baselibs//score/flatbuffers/bazel:tools.bzl", "serialize_buffer")
33

44
def _lm_config_splitter_impl(ctx):
5+
"""Run a script to convert from the new config structure to the old, this
6+
creates 3 seperate configs.
7+
"""
58
script = ctx.executable.script
69
config = ctx.file.config
710
schema = ctx.file.schema
@@ -24,6 +27,7 @@ def _lm_config_splitter_impl(ctx):
2427

2528
lm_config_splitter = rule(
2629
implementation = _lm_config_splitter_impl,
30+
doc = "Splits the new configuration format int othe old 3 formats.",
2731
attrs = {
2832
"config": attr.label(
2933
allow_single_file = [".json"],
@@ -49,6 +53,53 @@ lm_config_splitter = rule(
4953
},
5054
)
5155

56+
def _lm_config_combiner_impl(ctx):
57+
"""Declare a single directory that all three serialized buffers get copied
58+
into. Consumers receive this one directory instead of three individual
59+
files.
60+
"""
61+
etc_dir = ctx.actions.declare_directory(ctx.attr.dir_name)
62+
63+
srcs = [ctx.file.lm_config, ctx.file.hm_config, ctx.file.hm_core_config]
64+
65+
args = ctx.actions.args()
66+
args.add(etc_dir.path)
67+
args.add_all([f.path for f in srcs])
68+
69+
ctx.actions.run_shell(
70+
inputs = srcs,
71+
outputs = [etc_dir],
72+
arguments = [args],
73+
command = 'dest="$1"; shift; mkdir -p "$dest"; for f in "$@"; do cp "$f" "$dest/"; done',
74+
mnemonic = "LmConfigCombine",
75+
progress_message = "Combining launch manager configs into {}".format(etc_dir.short_path),
76+
)
77+
78+
return [DefaultInfo(files = depset([etc_dir]))]
79+
80+
lm_config_combiner = rule(
81+
implementation = _lm_config_combiner_impl,
82+
doc="Combines the generated .bin files into a single etc directory.",
83+
attrs = {
84+
"lm_config": attr.label(
85+
allow_single_file = [".bin"],
86+
mandatory = True,
87+
),
88+
"hm_config": attr.label(
89+
allow_single_file = [".bin"],
90+
mandatory = True,
91+
),
92+
"hm_core_config": attr.label(
93+
allow_single_file = [".bin"],
94+
mandatory = True,
95+
),
96+
"dir_name": attr.string(
97+
default = "etc",
98+
doc = "Name of the directory to place the combined config files into.",
99+
),
100+
},
101+
)
102+
52103
def launch_manager_config(
53104
name,
54105
config,
@@ -61,6 +112,8 @@ def launch_manager_config(
61112
**kwargs):
62113
split_name = name + "_split"
63114

115+
# note that the splitting and combining is a workaround as we have to return
116+
# the etc directory where all the .bin files are for backwards compatibility.
64117
lm_config_splitter(
65118
name = split_name,
66119
config = config,
@@ -81,25 +134,15 @@ def launch_manager_config(
81134
name = name + suffix,
82135
data = json_prefix + stem + ".json",
83136
schema = schema_file,
84-
output = flatbuffer_out_dir + "/" + stem + ".bin",
137+
output = name + "_serialized/" + stem + ".bin",
85138
**kwargs
86139
)
87140

88-
# native.filegroup(
89-
# name = name,
90-
# srcs = [
91-
# ":" + name + "_lm_bin",
92-
# ":" + name + "_hm_bin",
93-
# ":" + name + "_hmcore_bin",
94-
# ],
95-
96-
pkg_files(
141+
lm_config_combiner(
97142
name = name,
98-
srcs = [
99-
":" + name + "_lm_bin",
100-
":" + name + "_hm_bin",
101-
":" + name + "_hmcore_bin",
102-
],
103-
prefix = "/etc",
143+
lm_config = ":" + name + "_lm_bin",
144+
hm_config = ":" + name + "_hm_bin",
145+
hm_core_config = ":" + name + "_hmcore_bin",
146+
dir_name = flatbuffer_out_dir,
147+
**kwargs
104148
)
105-
# **kwargs

tests/integration/complex_monitoring/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pkg_files(
6969
pkg_files(
7070
name = "complex_monitoring_etc_files",
7171
srcs = [":lm_complex_monitoring_config"],
72-
prefix = "tests/complex_monitoring/etc",
72+
prefix = "tests/complex_monitoring",
7373
)
7474

7575
pkg_tar(

tests/integration/crash_on_startup/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pkg_files(
6363
pkg_files(
6464
name = "crash_on_startup_etc_files",
6565
srcs = [":lm_crash_on_startup_config"],
66-
prefix = "tests/crash_on_startup/etc",
66+
prefix = "tests/crash_on_startup",
6767
)
6868

6969
pkg_tar(

tests/integration/incorrect_config_non_reporting/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pkg_files(
5050
pkg_files(
5151
name = "non_reporting_etc_files",
5252
srcs = [":lm_non_reporting_config"],
53-
prefix = "tests/incorrect_config_non_reporting/etc",
53+
prefix = "tests/incorrect_config_non_reporting",
5454
)
5555

5656
pkg_tar(

tests/integration/process_crash_monitoring/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pkg_files(
5757
pkg_files(
5858
name = "process_crash_monitoring_etc_files",
5959
srcs = [":lm_process_crash_monitoring_config"],
60-
prefix = "tests/process_crash_monitoring/etc",
60+
prefix = "tests/process_crash_monitoring",
6161
)
6262

6363
pkg_tar(

tests/integration/process_launch_args/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ launch_manager_config(
2121
flatbuffer_out_dir = "etc",
2222
)
2323

24-
print(":lm_process_launch_args_config")
25-
2624
cc_binary(
2725
name = "process_initial",
2826
srcs = ["process_initial.cpp"],

tests/integration/smoke/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pkg_files(
6767
pkg_files(
6868
name = "smoke_etc_files",
6969
srcs = [":lm_smoketest_config"],
70-
prefix = "tests/smoke/etc",
70+
prefix = "tests/smoke",
7171
)
7272

7373
pkg_tar(

tests/integration/switch_run_target/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pkg_files(
8383
pkg_files(
8484
name = "switch_run_target_etc_files",
8585
srcs = [":lm_switch_run_target_config"],
86-
prefix = "tests/switch_run_target/etc",
86+
prefix = "tests/switch_run_target",
8787
)
8888

8989
pkg_tar(

0 commit comments

Comments
 (0)