fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreAdd `Runfiles::current_repository` to runfiles library (#1713)c75ea6f9

rust-analyzer
796 B26 linesraw
1"""Utilities for the `@rules_rust//tools/runfiles` library"""
2
3_RULES_RUST_RUNFILES_WORKSPACE_NAME = "RULES_RUST_RUNFILES_WORKSPACE_NAME"
4
5def _workspace_name_impl(ctx):
6    output = ctx.actions.declare_file(ctx.label.name)
7
8    ctx.actions.write(
9        output = output,
10        content = "{}={}\n".format(
11            _RULES_RUST_RUNFILES_WORKSPACE_NAME,
12            ctx.workspace_name,
13        ),
14    )
15
16    return [DefaultInfo(
17        files = depset([output]),
18    )]
19
20workspace_name = rule(
21    implementation = _workspace_name_impl,
22    doc = """\
23A rule for detecting the current workspace name and writing it to a file for
24for use with `rustc_env_files` attributes on `rust_*` rules. The workspace
25name is exposed by the variable `{}`.""".format(_RULES_RUST_RUNFILES_WORKSPACE_NAME),
26)