Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight cleanup and added some documentation. #580

Merged
merged 1 commit into from
Feb 9, 2021
Merged
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
22 changes: 19 additions & 3 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -850,13 +850,29 @@ def _get_dirname(file):
return file.dirname

def _error_format_impl(ctx):
"""Implementation of the `error_format` rule

Args:
ctx (ctx): The rule's context object

Returns:
list: A list containing the ErrorFormatInfo provider
"""
raw = ctx.build_setting_value
if raw not in _error_format_values:
fail(str(ctx.label) + " expected a value in [" + ", ".join(_error_format_values) +
"] but got " + raw)
return ErrorFormatInfo(error_format = raw)
fail("{} expected a value in `{}` but got `{}`".format(
ctx.label,
_error_format_values,
raw,
))
return [ErrorFormatInfo(error_format = raw)]

error_format = rule(
doc = (
"A helper rule for controlling the rustc " +
"[--error-format](https://doc.rust-lang.org/rustc/command-line-arguments.html#option-error-format) " +
"flag."
),
implementation = _error_format_impl,
build_setting = config.string(flag = True),
)