Skip to content

Commit

Permalink
Add semver_check internal crate
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaslueg committed Feb 9, 2025
1 parent 4b9abef commit 4b10302
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ jobs:
- run: cargo check --all-features
- run: cargo check --manifest-path=example_project/Cargo.toml

semver_crate:
name: cargo check of internal crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo check --manifest-path=semver_check/Cargo.toml

clippy:
name: cargo clippy
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions example_project/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.1.0"
authors = ["Lukas Lueg <[email protected]>"]
build = "build.rs"
edition = "2021"
publish = false

[dependencies]
built = { version = "0.7", path="../", features = ["chrono", "semver"] }
Expand Down
2 changes: 2 additions & 0 deletions semver_check/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
10 changes: 10 additions & 0 deletions semver_check/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "semver_check"
version = "0.1.0"
authors = ["Lukas Lueg <[email protected]>"]
build = "build.rs"
edition = "2021"
publish = false

[build-dependencies]
built = { version = "0.7", path="../", features = ["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }
3 changes: 3 additions & 0 deletions semver_check/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
built::write_built_file().expect("Failed to acquire build-time information");
}
66 changes: 66 additions & 0 deletions semver_check/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//! Internal crate to provide semver-checks on generated code.
//!
//! This ensures that the code *generated* by `built` does not semver-break
//! downstream crates.
//! All we do here is to assign/use items generated by `built` in a way that
//! was documented on the last semver-compatible version.
//! If `built` breaks this crate, it always breaks downstream crates. If updating
//! this crate is required, and this crate semver-breaks, `built` breaks downstream
//! crates as well. Both cases require a semver-bump of `built`.
mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}

pub const CI_PLATFORM: Option<&str> = built_info::CI_PLATFORM;
pub const PKG_VERSION: &str = built_info::PKG_VERSION;
pub const PKG_VERSION_MAJOR: &str = built_info::PKG_VERSION_MAJOR;
pub const PKG_VERSION_MINOR: &str = built_info::PKG_VERSION_MINOR;
pub const PKG_VERSION_PATCH: &str = built_info::PKG_VERSION_PATCH;
pub const PKG_VERSION_PRE: &str = built_info::PKG_VERSION_PRE;
pub const PKG_AUTHORS: &str = built_info::PKG_AUTHORS;
pub const PKG_NAME: &str = built_info::PKG_NAME;
pub const PKG_DESCRIPTION: &str = built_info::PKG_DESCRIPTION;
pub const PKG_HOMEPAGE: &str = built_info::PKG_HOMEPAGE;
pub const PKG_LICENSE: &str = built_info::PKG_LICENSE;
pub const PKG_REPOSITORY: &str = built_info::PKG_REPOSITORY;
pub const TARGET: &str = built_info::TARGET;
pub const HOST: &str = built_info::HOST;
pub const PROFILE: &str = built_info::PROFILE;
pub const RUSTC: &str = built_info::RUSTC;
pub const RUSTDOC: &str = built_info::RUSTDOC;
pub const RUSTC_VERSION: &str = built_info::RUSTC_VERSION;
pub const RUSTDOC_VERSION: &str = built_info::RUSTDOC_VERSION;
pub const OPT_LEVEL: &str = built_info::OPT_LEVEL;
pub const NUM_JOBS: u32 = built_info::NUM_JOBS;
pub const DEBUG: bool = built_info::DEBUG;
pub const FEATURES: &[&str] = &built_info::FEATURES;
pub const FEATURES_STR: &str = built_info::FEATURES_STR;
pub const FEATURES_LOWERCASE: &[&str] = &built_info::FEATURES_LOWERCASE;
pub const FEATURES_LOWERCASE_STR: &str = built_info::FEATURES_LOWERCASE_STR;
pub const CFG_TARGET_ARCH: &str = built_info::CFG_TARGET_ARCH;
pub const CFG_ENDIAN: &str = built_info::CFG_ENDIAN;
pub const CFG_ENV: &str = built_info::CFG_ENV;
pub const CFG_FAMILY: &str = built_info::CFG_FAMILY;
pub const CFG_OS: &str = built_info::CFG_OS;
pub const CFG_POINTER_WIDTH: &str = built_info::CFG_POINTER_WIDTH;

// cargo-lock
pub const DEPENDENCIES: &[(&str, &str)] = &built_info::DEPENDENCIES;
pub const DEPENDENCIES_STR: &str = built_info::DEPENDENCIES_STR;

// dependency-tree
pub const DIRECT_DEPENDENCIES: &[(&str, &str)] = &built_info::DIRECT_DEPENDENCIES;
pub const DIRECT_DEPENDENCIES_STR: &str = built_info::DIRECT_DEPENDENCIES_STR;
pub const INDIRECT_DEPENDENCIES: &[(&str, &str)] = &built_info::INDIRECT_DEPENDENCIES;
pub const INDIRECT_DEPENDENCIES_STR: &str = built_info::INDIRECT_DEPENDENCIES_STR;

// git2
pub const GIT_VERSION: Option<&str> = built_info::GIT_VERSION;
pub const GIT_DIRTY: Option<bool> = built_info::GIT_DIRTY;
pub const GIT_HEAD_REF: Option<&str> = built_info::GIT_HEAD_REF;
pub const GIT_COMMIT_HASH: Option<&str> = built_info::GIT_COMMIT_HASH;
pub const GIT_COMMIT_HASH_SHORT: Option<&str> = built_info::GIT_COMMIT_HASH_SHORT;

// chrono
pub const BUILT_TIME_UTC: &str = built_info::BUILT_TIME_UTC;

0 comments on commit 4b10302

Please sign in to comment.