2018-12-25 16:03:36 +00:00
|
|
|
# rustc_tools_util
|
|
|
|
|
|
|
|
A small tool to help you generate version information
|
|
|
|
for packages installed from a git repo
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Add a `build.rs` file to your repo and list it in `Cargo.toml`
|
2022-10-06 07:44:38 +00:00
|
|
|
````toml
|
2018-12-25 16:03:36 +00:00
|
|
|
build = "build.rs"
|
|
|
|
````
|
|
|
|
|
|
|
|
List rustc_tools_util as regular AND build dependency.
|
2022-10-06 07:44:38 +00:00
|
|
|
````toml
|
2018-12-25 16:03:36 +00:00
|
|
|
[dependencies]
|
2024-10-07 17:23:40 +00:00
|
|
|
rustc_tools_util = "0.4.0"
|
2018-12-25 16:03:36 +00:00
|
|
|
|
|
|
|
[build-dependencies]
|
2024-10-07 17:23:40 +00:00
|
|
|
rustc_tools_util = "0.4.0"
|
2018-12-25 16:03:36 +00:00
|
|
|
````
|
|
|
|
|
|
|
|
In `build.rs`, generate the data in your `main()`
|
2022-12-17 13:12:54 +00:00
|
|
|
|
|
|
|
```rust
|
2018-12-25 16:03:36 +00:00
|
|
|
fn main() {
|
2022-12-17 13:12:54 +00:00
|
|
|
rustc_tools_util::setup_version_info!();
|
2018-12-25 16:03:36 +00:00
|
|
|
}
|
2022-12-17 13:12:54 +00:00
|
|
|
```
|
2018-12-25 16:03:36 +00:00
|
|
|
|
|
|
|
Use the version information in your main.rs
|
|
|
|
|
2022-12-17 13:12:54 +00:00
|
|
|
```rust
|
2018-12-25 16:03:36 +00:00
|
|
|
fn show_version() {
|
|
|
|
let version_info = rustc_tools_util::get_version_info!();
|
|
|
|
println!("{}", version_info);
|
|
|
|
}
|
2022-12-17 13:12:54 +00:00
|
|
|
```
|
|
|
|
|
2018-12-25 16:03:36 +00:00
|
|
|
This gives the following output in clippy:
|
2022-12-17 13:12:54 +00:00
|
|
|
`clippy 0.1.66 (a28f3c8 2022-11-20)`
|
|
|
|
|
|
|
|
## Repository
|
|
|
|
|
|
|
|
This project is part of the rust-lang/rust-clippy repository. The source code
|
|
|
|
can be found under `./rustc_tools_util/`.
|
2018-12-25 16:03:36 +00:00
|
|
|
|
2022-12-17 13:12:54 +00:00
|
|
|
The changelog for `rustc_tools_util` is available under:
|
|
|
|
[`rustc_tools_util/CHANGELOG.md`](https://github.com/rust-lang/rust-clippy/blob/master/rustc_tools_util/CHANGELOG.md)
|
2018-12-25 16:03:36 +00:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2022-11-15 11:09:31 +00:00
|
|
|
<!-- REUSE-IgnoreStart -->
|
|
|
|
|
2024-01-03 18:36:44 +00:00
|
|
|
Copyright 2014-2024 The Rust Project Developers
|
2018-12-25 16:03:36 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
option. All files in the project carrying such notice may not be
|
|
|
|
copied, modified, or distributed except according to those terms.
|
2022-11-15 11:09:31 +00:00
|
|
|
|
|
|
|
<!-- REUSE-IgnoreEnd -->
|