Build structv0.1.0
pub struct Build {
pub profile: char8[..];
pub mode: BuildMode;
pub optimization: OptimizationMode;
pub debugAssertions: bool;
pub debugInfo: bool;
pub isTest: bool;
pub outputKind: OutputKind;
pub timestamp: uint64;
pub date: char8[..];
pub time: char8[..];
}
Every field is fixed when compiling begins and is the same everywhere in one build. Reading one produces no runtime code, so a branch on a field is decided while compiling and the untaken side is not emitted.
Fields
| Name | Type | Description |
|---|---|---|
profile | char8[..] | The profile's name as the project spelled it, which may be a project-defined profile rather than one of the two standard ones. |
mode | BuildMode | The mode the profile implies, which is what a package should branch on. |
optimization | OptimizationMode | What the profile asked the optimizer to favor. |
debugAssertions | bool | Whether DebugAssert checks are kept. False means they are removed without their arguments being evaluated. |
debugInfo | bool | Whether debug information is emitted alongside the output. |
isTest | bool | Whether this build is a test build, which is how a package tells a test-only path from a shipped one. |
outputKind | OutputKind | The artifact being produced. |
timestamp | uint64 | When the build started, in seconds since the Unix epoch. Fixed once per build, so it identifies the build and does not measure time. |
date | char8[..] | The build's start date as YYYY-MM-DD. |
time | char8[..] | The build's start time as HH:MM:SS. |
Related
BuildMode
pub enum BuildMode: uint8 {
Debug = 0,
Release = 1
}
The high-level mode of the active build profile. A profile is a name, and more than one profile may share a mode; this is the part a package can branch on without knowing which profiles a project defined.
Cases
| Name | Value | Description |
|---|---|---|
Debug | 0 | Unoptimized, with debug assertions and debug information on by default. |
Release | 1 | Optimized, with debug assertions removed by default. |
OptimizationMode
pub enum OptimizationMode: uint8 {
None = 0,
Size = 1,
Speed = 2
}
What the active build asked the optimizer to favor.
Cases
| Name | Value | Description |
|---|---|---|
None | 0 | No optimization: the output follows the source as closely as it can. |
Size | 1 | Smaller output preferred where it costs speed. |
Speed | 2 | Faster output preferred where it costs size. |
OutputKind
pub enum OutputKind: uint8 {
Executable = 0,
SharedLibrary = 1,
StaticLibrary = 2,
SourceLibrary = 3
}
The kind of artifact the active build produces.
Cases
| Name | Value | Description |
|---|---|---|
Executable | 0 | A program with an entry point. |
SharedLibrary | 1 | A library linked at load time and shipped as its own file. |
StaticLibrary | 2 | A library linked into whatever uses it, as compiled code. |
SourceLibrary | 3 | A library linked into whatever uses it, as source compiled with it. |
#build
pub const #build: Build;
The active build, as a compile-time value.
Reading a field produces no runtime code. A when on one keeps only the branch that applies, so the untaken side
is never resolved or type-checked and may name things this build does not have.