Skip to content

Commit

Permalink
version bump for next release, docs, lints (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Ozias <[email protected]>
  • Loading branch information
CraZySacX and jasonozias authored Mar 16, 2021
1 parent dcea966 commit 22a2a26
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
name = "vergen"
readme = "README.md"
repository = "https://github.com/rustyhorde/vergen"
version = "4.2.0"
version = "5.0.0"

[features]
default = ["build", "cargo", "git", "rustc"]
Expand Down
63 changes: 28 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,34 @@ Generate build, git, and rustc related 'cargo:rustc-env' instructions via 'build
## Example Usage
See the documentation at [docs.rs](https://docs.rs/vergen) for example usage

## Release 4 Breaking Changes
* The main entry point for use has changed from `generate_cargo_keys` to `vergen`
* There are now 4 features that allow you to control what instructions can be generated (`build`, `cargo`, `git`, and `rustc`).
* The `build` feature enables the `VERGEN_BUILD_*` instructions.
* The `git` feature enables the `VERGEN_GIT_*` instructions and the `cargo:rerun-if-changed` instructions.
* The `rustc` feature enables the `VERGEN_RUSTC_*` instructions.
* The `cargo` feature enables the `VERGEN_CARGO_*` instructions.
* By default, all features are enabled.
* You can build with all features disabled, which basically make the `vergen` function a no-op.
* You can still use `ConstantsFlags` with the `gen` function to toggle individual cargo instructions, but it has been deprecated.
* The generated instructions have been normalized. Therefore, you may need to update what env variable you are referring to in code. I've included a list below of the full set of instructions that can be generated for reference.

```text, no_run
cargo:rustc-env=VERGEN_BUILD_TIMESTAMP=2021-02-25T23:28:39.493201+00:00
cargo:rustc-env=VERGEN_BUILD_SEMVER=4.1.0
cargo:rustc-env=VERGEN_GIT_BRANCH=feature/datetime-toggles
cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=2021-02-24T20:55:21+00:00
cargo:rustc-env=VERGEN_GIT_SEMVER=4.1.0-2-gf49246c
cargo:rustc-env=VERGEN_GIT_SHA=f49246ce334567bff9f950bfd0f3078184a2738a
cargo:rustc-env=VERGEN_RUSTC_CHANNEL=nightly
cargo:rustc-env=VERGEN_RUSTC_COMMIT_DATE=2021-02-24
cargo:rustc-env=VERGEN_RUSTC_COMMIT_HASH=a8486b64b0c87dabd045453b6c81500015d122d6
cargo:rustc-env=VERGEN_RUSTC_HOST_TRIPLE=x86_64-apple-darwin
cargo:rustc-env=VERGEN_RUSTC_LLVM_VERSION=11.0
cargo:rustc-env=VERGEN_RUSTC_SEMVER=1.52.0-nightly
cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=x86_64-unknown-linux-gnu
cargo:rustc-env=VERGEN_CARGO_PROFILE=debug
cargo:rustc-env=VERGEN_CARGO_FEATURES=git,build
cargo:rerun-if-changed=/Users/kon8116/projects/rust-lang/vergen/.git/HEAD
cargo:rerun-if-changed=/Users/kon8116/projects/rust-lang/vergen/.git/refs/heads/feature/datetime-toggles
```

* Under the hood, the `Command`s used for git have been removed in lieu of using the `git2` library directly.
* `git2` is also used to determine the `HEAD` path and the path that it refers to for the `cargo:rerun-if-changed` instructions. This is more reliable then the manual method that was in place before.
* I've migrated the CI stuff from Travis to GitHub Actions.
## Release 5 Breaking Changes
* The main entry point for use has changed from `gen` to `vergen`
* The old `ConstantsFlags` has been removed in lieu of `Config`.

## Environment Variables
A full list of environment variables that can be generated are listed in the following table.

| Variable | Sample |
| ------- | ------ |
| `VERGEN_BUILD_DATE` | 2021-02-25 |
| `VERGEN_BUILD_TIME` | 23:28:39.493201 |
| `VERGEN_BUILD_TIMESTAMP` | 2021-02-25T23:28:39.493201+00:00 |
| `VERGEN_BUILD_SEMVER` | 5.0.0 |
| `VERGEN_GIT_BRANCH` | feature/fun |
| `VERGEN_GIT_COMMIT_DATE` | 2021-02-24 |
| `VERGEN_GIT_COMMIT_TIME` | 20:55:21 |
| `VERGEN_GIT_COMMIT_TIMESTAMP` | 2021-02-24T20:55:21+00:00 |
| `VERGEN_GIT_SEMVER` | 5.0.0-2-gf49246c |
| `VERGEN_GIT_SHA` | f49246ce334567bff9f950bfd0f3078184a2738a |
| `VERGEN_RUSTC_CHANNEL` | nightly |
| `VERGEN_RUSTC_COMMIT_DATE` | 2021-02-24 |
| `VERGEN_RUSTC_COMMIT_HASH` | a8486b64b0c87dabd045453b6c81500015d122d6 |
| `VERGEN_RUSTC_HOST_TRIPLE` | x86_64-apple-darwin |
| `VERGEN_RUSTC_LLVM_VERSION` | 11.0 |
| `VERGEN_RUSTC_SEMVER` | 1.52.0-nightly |
| `VERGEN_CARGO_FEATURES` | git,build |
| `VERGEN_CARGO_PROFILE` | debug |
| `VERGEN_CARGO_TARGET_TRIPLE` | x86_64-unknown-linux-gnu |

## Contributing
See the documentation at [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
9 changes: 9 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub fn main() {
);
println!("cargo:rustc-env=VERGEN_GIT_SEMVER=v3.2.0-86-g95fc0f5");
nightly_lints();
beta_lints();
}

#[rustversion::nightly]
Expand All @@ -18,3 +19,11 @@ fn nightly_lints() {

#[rustversion::not(nightly)]
fn nightly_lints() {}

#[rustversion::any(beta, nightly)]
fn beta_lints() {
println!("cargo:rustc-cfg=beta_lints");
}

#[rustversion::stable]
fn beta_lints() {}
10 changes: 8 additions & 2 deletions src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ use std::{
///
/// # Errors
///
/// Any generated errors will be wrapped in [`vergen::Error`](crate::error::Error)
/// * Errors may be generated from the `git2` library.
/// * [I/O](std::io::Error) errors may be generated.
/// * Errors may be generated from the `rustc_version` library.
/// * [env](std::env::VarError) errors may be generated.
///
/// # Usage
///
Expand All @@ -45,7 +48,10 @@ pub fn vergen(config: crate::Config) -> Result<()> {
///
/// # Errors
///
/// Any generated errors will be wrapped in [`vergen::Error`](crate::error::Error)
/// * Errors may be generated from the `git2` library.
/// * [I/O](std::io::Error) errors may be generated.
/// * Errors may be generated from the `rustc_version` library.
/// * [env](std::env::VarError) errors may be generated.
///
/// # Usage
///
Expand Down
83 changes: 68 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
//!
//! ```text, no_run
//! cargo:rustc-env=VERGEN_BUILD_TIMESTAMP=2021-02-25T23:28:39.493201+00:00
//! cargo:rustc-env=VERGEN_BUILD_SEMVER=4.1.0
//! cargo:rustc-env=VERGEN_BUILD_SEMVER=5.0.0
//! cargo:rustc-env=VERGEN_GIT_BRANCH=feature/fun
//! cargo:rustc-env=VERGEN_GIT_COMMIT_TIMESTAMP=2021-02-24T20:55:21+00:00
//! cargo:rustc-env=VERGEN_GIT_SEMVER=4.1.0-2-gf49246c
Expand All @@ -83,13 +83,42 @@
//! cargo:rustc-env=VERGEN_RUSTC_HOST_TRIPLE=x86_64-apple-darwin
//! cargo:rustc-env=VERGEN_RUSTC_LLVM_VERSION=11.0
//! cargo:rustc-env=VERGEN_RUSTC_SEMVER=1.52.0-nightly
//! cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=x86_64-unknown-linux-gnu
//! cargo:rustc-env=VERGEN_CARGO_PROFILE=debug
//! cargo:rustc-env=VERGEN_CARGO_FEATURES=git,build
//! cargo:rustc-env=VERGEN_CARGO_PROFILE=debug
//! cargo:rustc-env=VERGEN_CARGO_TARGET_TRIPLE=x86_64-unknown-linux-gnu
//! cargo:rerun-if-changed=/Users/yoda/projects/rust-lang/vergen/.git/HEAD
//! cargo:rerun-if-changed=/Users/yoda/projects/rust-lang/vergen/.git/refs/heads/feature/fun
//! ```
//!
//! ## Environment Variables
//! A full list of environment variables that can be generated are listed in the following table
//!
//! | Variable | Sample |
//! | ------- | ------ |
//! | See [`Build`](crate::Build) to configure the following |
//! | `VERGEN_BUILD_DATE` | 2021-02-25 |
//! | `VERGEN_BUILD_TIME` | 23:28:39.493201 |
//! | `VERGEN_BUILD_TIMESTAMP` | 2021-02-25T23:28:39.493201+00:00 |
//! | `VERGEN_BUILD_SEMVER` | 5.0.0 |
//! | See [`Git`](crate::Git) to configure the following |
//! | `VERGEN_GIT_BRANCH` | feature/fun |
//! | `VERGEN_GIT_COMMIT_DATE` | 2021-02-24 |
//! | `VERGEN_GIT_COMMIT_TIME` | 20:55:21 |
//! | `VERGEN_GIT_COMMIT_TIMESTAMP` | 2021-02-24T20:55:21+00:00 |
//! | `VERGEN_GIT_SEMVER` | 5.0.0-2-gf49246c |
//! | `VERGEN_GIT_SHA` | f49246ce334567bff9f950bfd0f3078184a2738a |
//! | See [`Rustc`](crate::Rustc) to configure the following |
//! | `VERGEN_RUSTC_CHANNEL` | nightly |
//! | `VERGEN_RUSTC_COMMIT_DATE` | 2021-02-24 |
//! | `VERGEN_RUSTC_COMMIT_HASH` | a8486b64b0c87dabd045453b6c81500015d122d6 |
//! | `VERGEN_RUSTC_HOST_TRIPLE` | x86_64-apple-darwin |
//! | `VERGEN_RUSTC_LLVM_VERSION` | 11.0 |
//! | `VERGEN_RUSTC_SEMVER` | 1.52.0-nightly |
//! | See [`Cargo`](crate::Cargo) to configure the following |
//! | `VERGEN_CARGO_FEATURES` | git,build |
//! | `VERGEN_CARGO_PROFILE` | debug |
//! | `VERGEN_CARGO_TARGET_TRIPLE` | x86_64-unknown-linux-gnu |
//!
//! ## Usage
//!
//! 1. Ensure you have build scripts enabled via the `build` configuration in your `Cargo.toml`
Expand All @@ -107,9 +136,9 @@
//! #..
//!
//! [build-dependencies]
//! vergen = "4"
//! vergen = "5"
//! # or
//! vergen = { version = "4", default-features = false, features = ["build", "rustc"] }
//! vergen = { version = "5", default-features = false, features = ["build", "rustc"] }
//! # if you wish to disable certain features
//! ```
//!
Expand All @@ -135,6 +164,7 @@
//! [cargo:rustc-env]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-env
//! [cargo:rerun-if-changed]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-changed
//!
// rustc lints
#![deny(
absolute_paths_not_starting_with_crate,
anonymous_parameters,
Expand All @@ -145,21 +175,20 @@
box_pointers,
cenum_impl_drop_cast,
clashing_extern_declarations,
clippy::all,
clippy::pedantic,
clippy::cargo,
coherence_leak_check,
confusable_idents,
const_evaluatable_unchecked,
const_item_mutation,
dead_code,
deprecated,
// deprecated_in_future,
deprecated_in_future,
drop_bounds,
elided_lifetimes_in_paths,
ellipsis_inclusive_range_patterns,
explicit_outlives_requirements,
exported_private_dependencies,
forbidden_lint_groups,
function_item_references,
illegal_floating_point_literal_pattern,
improper_ctypes,
improper_ctypes_definitions,
Expand All @@ -174,28 +203,27 @@
meta_variable_misuse,
missing_copy_implementations,
missing_debug_implementations,
// missing_doc_code_examples,
missing_docs,
mixed_script_confusables,
mutable_borrow_reservation_conflict,
no_mangle_generic_items,
non_ascii_idents,
non_camel_case_types,
non_fmt_panic,
non_shorthand_field_patterns,
non_snake_case,
non_upper_case_globals,
nontrivial_structural_match,
overlapping_range_endpoints,
path_statements,
pointer_structural_match,
// private_doc_tests,
private_in_public,
proc_macro_derive_resolution_fallback,
redundant_semicolons,
renamed_and_removed_lints,
safe_packed_borrows,
single_use_lifetimes,
stable_features,
temporary_cstring_as_ptr,
trivial_bounds,
trivial_casts,
trivial_numeric_casts,
Expand All @@ -204,15 +232,16 @@
unaligned_references,
uncommon_codepoints,
unconditional_recursion,
uninhabited_static,
unknown_lints,
unnameable_test_items,
unreachable_code,
unreachable_patterns,
unreachable_pub,
unsafe_code,
// unsafe_op_in_unsafe_fn,
unstable_features,
unstable_name_collisions,
unsupported_naked_functions,
unused_allocation,
unused_assignments,
unused_attributes,
Expand All @@ -236,7 +265,7 @@
unused_variables,
variant_size_differences,
where_clauses_object_safety,
while_true,
while_true
)]
#![cfg_attr(
not(nightly_lints),
Expand All @@ -245,18 +274,42 @@
invalid_codeblock_attributes,
invalid_html_tags,
missing_crate_level_docs,
missing_doc_code_examples,
private_doc_tests,
)
)]
#![cfg_attr(
beta_lints,
deny(
disjoint_capture_drop_reorder,
missing_abi,
single_use_lifetimes,
semicolon_in_expressions_from_macros,
)
)]
#![cfg_attr(
nightly_lints,
deny(
legacy_derive_helpers,
noop_method_call,
proc_macro_back_compat,
unsafe_op_in_unsafe_fn,
)
)]
// clippy lints
#![deny(clippy::all, clippy::cargo, clippy::pedantic)]
// rustdoc lints
#![cfg_attr(
nightly_lints,
deny(
rustdoc::broken_intra_doc_links,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_html_tags,
rustdoc::missing_crate_level_docs,
rustdoc::missing_doc_code_examples,
rustdoc::private_doc_tests,
)
)]
#![allow(clippy::multiple_crate_versions)]

mod config;
mod constants;
Expand Down

0 comments on commit 22a2a26

Please sign in to comment.