Skip to content

Commit 31b9f25

Browse files
Refactor code
1 parent c3870de commit 31b9f25

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

repos/config/detail/ros2_config.bzl

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,23 @@ exports_files(glob(["**/*"]))
4848
def _ros2_config_impl(ctx):
4949
ctx.symlink(ctx.attr.repos_index, "ros.repos")
5050
ctx.symlink(ctx.attr.setup_file, "setup.bzl")
51-
i = 0
5251
overlay_files = []
53-
for file in ctx.attr.repos_index_overlays:
54-
filname = "overlay_{}.bzl".format(i)
55-
ctx.symlink(file, filname)
56-
i += 1
57-
overlay_files.append(filname)
58-
ctx.file("WORKSPACE", content = "workspace(name = {})".format(ctx.name), executable = False)
59-
ctx.file("BUILD.bazel", content = BUILD_FILE_CONTENT.format(overlays="\n".join([' "{}",'.format(filename) for filename in overlay_files])), executable = False)
52+
for i, file in enumerate(ctx.attr.repos_index_overlays):
53+
filename = "overlay_{}.bzl".format(i)
54+
ctx.symlink(file, filename)
55+
overlay_files.append(filename)
56+
ctx.file(
57+
"WORKSPACE",
58+
content = "workspace(name = {})".format(ctx.name),
59+
executable = False
60+
)
61+
ctx.file(
62+
"BUILD.bazel",
63+
content = BUILD_FILE_CONTENT.format(
64+
overlays="\n".join([' "{}",'.format(filename) for filename in overlay_files])
65+
),
66+
executable = False
67+
)
6068

6169
return update_attrs(ctx.attr, _archive_attrs.keys(), {})
6270

0 commit comments

Comments
 (0)