compile_time/lib.rs
1//! This crate provides macros for getting compile time information.
2//!
3//! You can get the compile time either as
4//! [`time::Date`](time03::Date), [`time::Time`](time03::Time),
5//! [`time::OffsetDateTime`](time03::OffsetDateTime), string, or UNIX timestamp.
6//!
7//! You can get the Rust compiler version either as
8//! [`semver::Version`] or string,
9//! and the individual version parts as integer literals or strings, respectively.
10//!
11//! You can run arbitrary command at compile time and get its output as bytes or string.
12//!
13//! # Examples
14//!
15//! Getting the compile time and Rust version:
16//!
17//! ```rust
18//! const COMPILE_DATETIME: &str = compile_time::datetime_str!();
19//! const RUSTC_VERSION: &str = compile_time::rustc_version_str!();
20//!
21//! println!("Compiled using Rust {RUSTC_VERSION} on {COMPILE_DATETIME}.");
22//! ```
23//!
24//! Running an arbitrary command at compile time:
25//!
26//! ```rust
27//! const MAGIC_NUMBER: &str = compile_time::command_str!("echo", "42");
28//!
29//! assert_eq!(MAGIC_NUMBER, "42\n");
30//! ```
31#![no_std]
32
33pub use compile_time_macros::*;
34
35mod constants {
36 include!(concat!(env!("OUT_DIR"), "/constants.rs"));
37}
38
39/// The host platform triple.
40pub const HOST: &str = constants::HOST;
41
42/// The target platform triple.
43pub const TARGET: &str = constants::TARGET;
44
45#[doc(hidden)]
46pub mod __re_exports {
47 #[cfg(feature = "version")]
48 pub use semver;
49 #[cfg(feature = "time")]
50 pub use time03 as time;
51}
52
53#[doc = include_str!("../ReadMe.md")]
54#[doc(hidden)]
55pub fn __readme_doc_test() {}