lib.rs |
Glean Rust build utility
`glean-build` generates the Rust bindings based on metrics and ping definitions,
using [`glean-parser`] under the hood.
## Requirements
* Python 3
* pip
## Usage
In your application add a `build.rs` file next to your `Cargo.toml`,
then add this code:
```rust,ignore
use glean_build::Builder;
fn main() {
Builder::default()
.file("metrics.yaml")
.generate()
.expect("Error generating Glean Rust bindings");
}
```
In your code add the following to include the generated code:
```rust,ignore
mod metrics {
include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs"));
}
```
You can then access your metrics and pings directly by name within the `metrics` module.
[`glean-parser`]: https://github.com/mozilla/glean_parser/ |
4956 |