1 unstable release
0.1.0 | Dec 29, 2022 |
---|
#508 in Build Utils
97 downloads per month
12KB
195 lines
Bazel runfiles support for cargo.
The source code is just copied directly from rules_rust/tools/runfiles/runfiles.rs. Tests are not expected to work. This is mainly useful for:
- Bootstrapping cargo_universe.
- Allowing things depending on runfiles to be built with cargo.
- Allow requesting dependiencies on runfiles in cargo.toml.
- Support IDE code completion.
lib.rs
:
Runfiles lookup library for Bazel-built Rust binaries and tests.
USAGE:
-
Depend on this runfiles library from your build rule:
rust_binary( name = "my_binary", ... data = ["//path/to/my/data.txt"], deps = ["@rules_rust//tools/runfiles"], )
-
Import the runfiles library.
extern crate runfiles; use runfiles::Runfiles;
-
Create a Runfiles object and use rlocation to look up runfile paths:
use runfiles::Runfiles; let r = Runfiles::create().unwrap(); let path = r.rlocation("my_workspace/path/to/my/data.txt"); let f = File::open(path).unwrap(); // ...