pkg-version-1.0.0/.gitignore010064400017500001750000000000221354614313200141610ustar0000000000000000target Cargo.lock pkg-version-1.0.0/.travis.yml010064400017500001750000000007471355565463600143400ustar0000000000000000language: rust rust: - 1.36.0 - stable - nightly sudo: false env: global: - RUSTFLAGS="--deny warnings" - RUST_BACKTRACE=1 - CARGO_INCREMENTAL=0 # decrease size of `target` to make the cache smaller - NO_STD_TARGET=thumbv7em-none-eabi script: # Run tests on x86-64 - cargo test --all # Make sure it builds on #![no_std]-only targets - rustup target add $NO_STD_TARGET - cargo build --target $NO_STD_TARGET notifications: email: on_success: never pkg-version-1.0.0/CHANGELOG.md010064400017500001750000000002771356604434000140210ustar0000000000000000# Changelog ## Unreleased No changes. ## 1.0.0 - 2019-11-22 No changes. ## 0.1.1 - 2019-09-04 The crate now supports `#![no_std]` environments. ## 0.1.0 - 2019-05-03 Initial release. pkg-version-1.0.0/Cargo.toml.orig010064400017500001750000000032761356604434000151010ustar0000000000000000[package] name = "pkg-version" version = "1.0.0" authors = ["Jonas Schievink "] edition = "2018" description = "Macros expanding to the package version" documentation = "https://docs.rs/pkg-version/" repository = "https://github.com/jonas-schievink/pkg-version.git" keywords = ["crate", "macro", "const", "constant"] categories = ["development-tools::build-utils"] readme = "README.md" license = "0BSD" # cargo-release configuration [package.metadata.release] tag-message = "{{version}}" no-dev-version = true pre-release-commit-message = "Release {{version}}" # Change the changelog's `Unreleased` section to refer to this release and # prepend new `Unreleased` section [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" search = "## Unreleased" replace = "## Unreleased\n\nNo changes.\n\n## {{version}} - {{date}}" # Bump the version inside the example manifest in `README.md` [[package.metadata.release.pre-release-replacements]] file = "README.md" search = 'pkg-version = "[a-z0-9\\.-]+"' replace = 'pkg-version = "{{version}}"' # Bump the version referenced by the `html_root_url` attribute in `lib.rs` [[package.metadata.release.pre-release-replacements]] file = "src/lib.rs" search = "https://docs.rs/pkg-version/[a-z0-9\\.-]+" replace = "https://docs.rs/pkg-version/{{version}}" # Bump the version referenced in the doc example in `lib.rs` [[package.metadata.release.pre-release-replacements]] file = "src/lib.rs" search = "\"[0-9\\.-]+[0-9a-z\\.-]*\"" replace = "\"{{version}}\"" [dependencies] pkg-version-impl = { path = "pkg-version-impl", version = "0.1.0" } proc-macro-hack = "0.5.5" [dev-dependencies] version-sync = "0.8" [workspace] pkg-version-1.0.0/Cargo.toml0000644000000035350000000000000113410ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "pkg-version" version = "1.0.0" authors = ["Jonas Schievink "] description = "Macros expanding to the package version" documentation = "https://docs.rs/pkg-version/" readme = "README.md" keywords = ["crate", "macro", "const", "constant"] categories = ["development-tools::build-utils"] license = "0BSD" repository = "https://github.com/jonas-schievink/pkg-version.git" [package.metadata.release] no-dev-version = true pre-release-commit-message = "Release {{version}}" tag-message = "{{version}}" [[package.metadata.release.pre-release-replacements]] file = "CHANGELOG.md" replace = "## Unreleased\n\nNo changes.\n\n## {{version}} - {{date}}" search = "## Unreleased" [[package.metadata.release.pre-release-replacements]] file = "README.md" replace = "pkg-version = \"{{version}}\"" search = "pkg-version = \"[a-z0-9\\\\.-]+\"" [[package.metadata.release.pre-release-replacements]] file = "src/lib.rs" replace = "https://docs.rs/pkg-version/{{version}}" search = "https://docs.rs/pkg-version/[a-z0-9\\.-]+" [[package.metadata.release.pre-release-replacements]] file = "src/lib.rs" replace = "\"{{version}}\"" search = "\"[0-9\\.-]+[0-9a-z\\.-]*\"" [dependencies.pkg-version-impl] version = "0.1.0" [dependencies.proc-macro-hack] version = "0.5.5" [dev-dependencies.version-sync] version = "0.8" pkg-version-1.0.0/LICENSE010064400017500001750000000012311354614313200132010ustar0000000000000000Copyright (C) Jonas Schievink Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. pkg-version-1.0.0/README.md010064400017500001750000000020711356604434000134610ustar0000000000000000# `pkg-version` - Macros for accessing your crate version [![crates.io](https://img.shields.io/crates/v/pkg-version.svg)](https://crates.io/crates/pkg-version) [![docs.rs](https://docs.rs/pkg-version/badge.svg)](https://docs.rs/pkg-version/) [![Build Status](https://travis-ci.org/jonas-schievink/pkg-version.svg?branch=master)](https://travis-ci.org/jonas-schievink/pkg-version) This crate provides macros (`pkg_version_major!`, etc.) that expand to the Cargo package version, as an integer literal. Previously, the only way to access the package version was by using `env!("CARGO_PKG_VERSION_MAJOR")` etc., but doing that always results in a *string* literal, which can only be parsed into a number at runtime. This crate fixes that problem by parsing the version during macro expansion. Please refer to the [changelog](CHANGELOG.md) to see what changed in the last releases. ## Usage Add an entry to your `Cargo.toml`: ```toml [dependencies] pkg-version = "1.0.0" ``` Check the [API Documentation](https://docs.rs/pkg-version/) for how to use the crate's functionality. pkg-version-1.0.0/RELEASE_PROCESS.md010064400017500001750000000010161354614313200147750ustar0000000000000000# What to do to publish a new release 1. Ensure all notable changes are in the changelog under "Unreleased". 2. Execute `cargo release ` to bump version(s), tag and publish everything. External subcommand, must be installed with `cargo install cargo-release`. `` can be one of `major|minor|patch`. If this is the first release (`0.1.0`), use `minor`, since the version start out as `0.0.0`. 3. Go to the GitHub releases, edit the just-pushed tag. Copy the release notes from the changelog. pkg-version-1.0.0/src/lib.rs010064400017500001750000000046411356604434000141120ustar0000000000000000//! Provides macros for fetching the Cargo package version at compile time. //! //! All macros defined by this crate return constant expressions, so they can be used inside //! `const fn`s or to initialize the value of a `const` or `static` item. //! //! # Example //! //! ``` //! use pkg_version::*; //! //! const MAJOR: u32 = pkg_version_major!(); //! const MINOR: u32 = pkg_version_minor!(); //! const PATCH: u32 = pkg_version_patch!(); //! //! fn main() { //! let version = format!("{}.{}.{}", MAJOR, MINOR, PATCH); //! assert_eq!(version, "1.0.0"); //! //! println!("I am version {}", version); //! } //! ``` #![no_std] #![doc(html_root_url = "https://docs.rs/pkg-version/1.0.0")] #![warn(missing_debug_implementations, rust_2018_idioms)] use proc_macro_hack::proc_macro_hack; /// Expands to the major version number of the Cargo package, as an integer literal. /// /// The resulting integer literal is *unsuffixed*, meaning that it does not use a type suffix like /// `1u32`. This means that it can be used to initialize a variable of any integer type, as long as /// the version number fits. If the number doesn't fit, the compiler will report an error. #[proc_macro_hack] pub use pkg_version_impl::pkg_version_major; /// Expands to the minor version number of the Cargo package, as an integer literal. /// /// The resulting integer literal is *unsuffixed*, meaning that it does not use a type suffix like /// `1u32`. This means that it can be used to initialize a variable of any integer type, as long as /// the version number fits. If the number doesn't fit, the compiler will report an error. #[proc_macro_hack] pub use pkg_version_impl::pkg_version_minor; /// Expands to the patch version number of the Cargo package, as an integer literal. /// /// The resulting integer literal is *unsuffixed*, meaning that it does not use a type suffix like /// `1u32`. This means that it can be used to initialize a variable of any integer type, as long as /// the version number fits. If the number doesn't fit, the compiler will report an error. #[proc_macro_hack] pub use pkg_version_impl::pkg_version_patch; /// Make sure passing any arguments results in an error. /// /// ```compile_fail /// use pkg_version::*; /// pkg_version_major!(_); /// ``` /// /// ```compile_fail /// use pkg_version::*; /// pkg_version_minor!(_); /// ``` /// /// ```compile_fail /// use pkg_version::*; /// pkg_version_patch!(_); /// ``` const _COMPILE_FAIL: () = (); pkg-version-1.0.0/tests/version-numbers.rs010064400017500001750000000003211354614313200170410ustar0000000000000000#[macro_use] extern crate version_sync; #[test] fn test_readme_deps() { assert_markdown_deps_updated!("README.md"); } #[test] fn test_html_root_url() { assert_html_root_url_updated!("src/lib.rs"); } pkg-version-1.0.0/.cargo_vcs_info.json0000644000000001120000000000000133270ustar00{ "git": { "sha1": "e70b217fd4508f6e4090edd6d6e7333b43036dd2" } }