1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
//! Tiny library for setting/getting build-time values for your crate.
//!
//! # Setup
//!
//! ## Create `build.rs`
//!
//! Create new file `build.rs` at the top level of your crate (next to `Cargo.toml`).
//!
//! ```rust,no_run
//! use chksum_build::{BuildScript, Result};
//!
//! fn main() -> Result<()> {
//! BuildScript::default().setup()
//! }
//! ```
//!
//! Optionally you can use along with [`anyhow`].
//!
//! ```rust,no_run
//! use anyhow::Result;
//! use chksum_build::{setup, BuildScript};
//!
//! fn main() -> Result<()> {
//! setup(&BuildScript::default())
//! }
//! ```
//!
//! ## Update `Cargo.toml`
//!
//! ### Modify `package` section
//!
//! ```toml
//! [package]
//! # ...
//! build = "build.rs"
//! ```
//!
//! ### Modify `build-dependencies` section
//!
//! You can update `Cargo.toml` on your own.
//!
//! ```toml
//! [build-dependencies]
//! # ...
//! chksum-build = "0.0.3"
//! ```
//!
//! Or use [`cargo add`](https://doc.rust-lang.org/cargo/commands/cargo-add.html) subcommand.
//!
//! ```sh
//! cargo add --build chksum-build
//! ```
//!
//! ### Modify `dependencies` section
//!
//! As in the example above you can add entry manually.
//!
//! ```toml
//! [dependencies]
//! # ...
//! chksum-build = "0.0.3"
//! ```
//!
//! Or by using subcommand.
//!
//! ```sh
//! cargo add chksum-build
//! ```
//!
//! # Usage
//!
//! ## `build_info` macro
//!
//! [`build_info`] macro creates [`BuildInfo`].
//!
//! ```rust,ignore
//! use chksum_build::build_info;
//! # use chksum_build::Result;
//!
//! # fn wrapper() -> Result<()> {
//! let build_info = build_info!();
//! # Ok(())
//! # }
//! ```
//!
//! ## `env` or `option_env` macros
//!
//! [`env`] or [`option_env`] macros.
//!
//! **Notice:** Type conversion need to be done manually.
//!
//! ```rust,ignore
//! use std::str::FromStr;
//! use chksum_build::cargo::Profile;
//!
//! // ...
//!
//! let profile = env!("CHKSUM_BUILD_INFO_CARGO_PROFILE");
//! let profile = Profile::from_str(profile)?;
//!
//! // or
//!
//! let profile = option_env!("CHKSUM_BUILD_INFO_CARGO_PROFILE")
//! .map(Profile::from_str)
//! .transpose()?;
//! ```
//!
//! ## `cfg` or `cfg_attr` options
//!
//! Some variables are available as configuration options for [`cfg`](https://doc.rust-lang.org/stable/reference/conditional-compilation.html#the-cfg-attribute) or [`cfg_attr`](https://doc.rust-lang.org/stable/reference/conditional-compilation.html#the-cfg_attr-attribute).
//!
//! ### `Profile` variants
//!
//! Check [`Profile`] for more details.
//!
//! ```rust
//! #[cfg(debug)]
//! fn debug_function() {
//! // ...
//! }
//!
//! #[cfg_attr(release, inline)]
//! fn inline_when_release_function() {
//! // ...
//! }
//! ```
//!
//! ### `Channel` variants
//!
//! Check [`Channel`] for more details.
//!
//! ```rust
//! #[cfg(stable)]
//! fn stable_function() {
//! // ...
//! }
//!
//! #[cfg(nightly)]
//! fn nightly_function() {
//! // ...
//! }
//!
//! #[cfg_attr(nightly, optimize(size))]
//! fn optimize_when_nightly_function() {
//! // ...
//! }
//! ```
//!
//! # Feature flags
//!
//! * `info`: Enables items required by library or application.
//! * `script`: Enables items required by build script.
//!
//! By default both of them are enabled.
//!
//! # Alternatives
//!
//! * [build-data](https://crates.io/crates/build-data)
//! * [build-info](https://crates.io/crates/build-info)
//! * [built](https://crates.io/crates/built)
//! * [shadow-rs](https://crates.io/crates/shadow-rs)
//! * [vergen](https://crates.io/crates/vergen)
//!
//! # License
//!
//! MIT
pub use Profile;
pub use ;
pub use ;
pub use ;
pub use ;