Build structv0.1.0

Source
Properties of the active build profile and its output.
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

NameTypeDescription
profilechar8[..]The profile's name as the project spelled it, which may be a project-defined profile rather than one of the two standard ones.
modeBuildModeThe mode the profile implies, which is what a package should branch on.
optimizationOptimizationModeWhat the profile asked the optimizer to favor.
debugAssertionsboolWhether DebugAssert checks are kept. False means they are removed without their arguments being evaluated.
debugInfoboolWhether debug information is emitted alongside the output.
isTestboolWhether this build is a test build, which is how a package tells a test-only path from a shipped one.
outputKindOutputKindThe artifact being produced.
timestampuint64When the build started, in seconds since the Unix epoch. Fixed once per build, so it identifies the build and does not measure time.
datechar8[..]The build's start date as YYYY-MM-DD.
timechar8[..]The build's start time as HH:MM:SS.

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.

Source

Cases

NameValueDescription
Debug0Unoptimized, with debug assertions and debug information on by default.
Release1Optimized, 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.

Source

Cases

NameValueDescription
None0No optimization: the output follows the source as closely as it can.
Size1Smaller output preferred where it costs speed.
Speed2Faster 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.

Source

Cases

NameValueDescription
Executable0A program with an entry point.
SharedLibrary1A library linked at load time and shipped as its own file.
StaticLibrary2A library linked into whatever uses it, as compiled code.
SourceLibrary3A 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.

Source