Skip to content

Commit

Permalink
Replace deprecated depset usage
Browse files Browse the repository at this point in the history
- use .to_list() instead of iterating
- use depset() constructor instead of .union()

See google#2.

Change-Id: I9bb75fe638e029f7b55dd3647c414e64f5c86066
GitOrigin-RevId: 857882805e01de0e880ed2154b6b39e1b7f28394
  • Loading branch information
drigz authored and Copybara-Service committed Mar 5, 2019
1 parent 10f6a8b commit 56e709a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bazel/build_rules/app_chart/cache_gcr_credentials.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def _get_runfile_path(ctx, f):
return "${RUNFILES}/" + f.short_path

def _impl(ctx):
runfiles = list(ctx.attr._sh_tpl.default_runfiles.files)
runfiles = ctx.attr._sh_tpl.default_runfiles.files.to_list()
runfiles.append(ctx.attr.target.files_to_run.executable)
runfiles.extend(list(ctx.attr.target.default_runfiles.files))
runfiles.extend(ctx.attr.target.default_runfiles.files.to_list())

variables = "PYTHON_RUNFILES=\"${RUNFILES}\" "
ctx.actions.expand_template(
Expand Down
4 changes: 2 additions & 2 deletions bazel/build_rules/app_chart/run_parallel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ def _get_runfile_path(ctx, f):
return "${RUNFILES}/" + f.short_path

def _impl(ctx):
runfiles = list(ctx.attr._sh_tpl.default_runfiles.files)
runfiles = ctx.attr._sh_tpl.default_runfiles.files.to_list()
for target in ctx.attr.targets:
runfiles.append(target.files_to_run.executable)
runfiles.extend(list(target.default_runfiles.files))
runfiles.extend(target.default_runfiles.files.to_list())

ctx.actions.expand_template(
template = ctx.file._sh_tpl,
Expand Down
4 changes: 2 additions & 2 deletions bazel/build_rules/app_chart/run_sequentially.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ def _get_runfile_path(ctx, f):
return "${RUNFILES}/" + f.short_path

def _impl(ctx):
runfiles = list(ctx.attr._sh_tpl.default_runfiles.files)
runfiles = ctx.attr._sh_tpl.default_runfiles.files.to_list()
for target in ctx.attr.targets:
runfiles.append(target.files_to_run.executable)
runfiles.extend(list(target.default_runfiles.files))
runfiles.extend(target.default_runfiles.files.to_list())

variables = "PYTHON_RUNFILES=\"${RUNFILES}\" "
ctx.actions.expand_template(
Expand Down
2 changes: 1 addition & 1 deletion bazel/build_rules/proto_descriptor.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# services.

def paths(files):
return [f.path for f in files]
return [f.path for f in files.to_list()]

def _impl(ctx):
descriptors = ctx.attr.proto_library.proto.transitive_descriptor_sets
Expand Down
11 changes: 6 additions & 5 deletions bazel/build_rules/rosmsg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ def _SynthesizePythonTargets(
msg_or_srv_dirname,
))

generated_files = depset([output_dir + "/__init__.py"])
generated_files = [output_dir + "/__init__.py"]
for src in srcs:
extension = src[-3:]
init_file = "%s/%s/__init__.py" % (output_dir, extension)
py_file = "%s/%s/_%s.py" % (output_dir, extension, _Stem(src))
generated_files = generated_files.union([init_file, py_file])
generated_files = list(generated_files)
generated_files.append("%s/%s/__init__.py" % (output_dir, extension))
generated_files.append("%s/%s/_%s.py" % (output_dir, extension, _Stem(src)))

# Remove duplicate entries.
generated_files = depset(direct = generated_files).to_list()

native.genrule(
name = "_%s_message_generation_for_python" % name,
Expand Down

0 comments on commit 56e709a

Please sign in to comment.