#build v0.1.0

Source
Compile-time information about the active build.

Package: Rux

Definition

intrinsic #build: Build;

struct Build {
    profile: Slice<char8>;
    mode: BuildMode;
    optimization: OptimizationMode;
    debugAssertions: bool;
    debugInfo: bool;
    isTest: bool;
    outputKind: OutputKind;
    timestamp: uint64;
    date: Slice<char8>;
    time: Slice<char8>;
}

#build is a compile-time value describing the profile and output of the current build. Read its fields in a when to compile differently by mode, or embed the build date and time in a program.

Fields

FieldTypeDescription
profileSlice<char8>Name of the active build profile.
modeBuildModeDebug or Release.
optimizationOptimizationModeNone, Size, or Speed.
debugAssertionsboolWhether DebugAssert checks are compiled.
debugInfoboolWhether debug information is emitted.
isTestboolWhether this is a test build.
outputKindOutputKindExecutable, SharedLibrary, StaticLibrary, or SourceLibrary.
timestampuint64Build time as a Unix timestamp.
dateSlice<char8>Build date as text.
timeSlice<char8>Build time of day as text.

Enums

enum BuildMode: uint8 { Debug = 0, Release = 1 }
enum OptimizationMode: uint8 { None = 0, Size = 1, Speed = 2 }
enum OutputKind: uint8 { Executable = 0, SharedLibrary = 1, StaticLibrary = 2, SourceLibrary = 3 }

A standalone SourceLibrary check reports SourceLibrary. Source compiled into a dependent package reports the consuming package's output kind.

Example

import Core::{ #build };
import Io::PrintLine;

func Main() -> int {
    when #build.mode {
        .Debug => PrintLine("debug build"),
        .Release => PrintLine("release build")
    }
    return 0;
}

See also