silk.build.compilation.

Compilations as build steps that write explicit requests before invoking the compiler.

Import as Compilation with import silk.build.compilation { Compilation }.

Public declarations: 2.

Compilation#

silk
pub struct Compilation

A compilation whose settings freeze when its artifact is first used by the graph.

Implementation Compilation#

silk
impl Compilation

Method when#

silk
pub effect fn when<'env, E, ? R>(
    self: Self,
    condition: bool,
    transform: once effect fn<'env>(Self) -> Self ! E ? R,
  ) -> Self
    ! E
    ? R

Applies transform when condition is true, returning the original value otherwise.

Associated function fromDefinition#

silk
pub effect fn fromDefinition(definition: Definition, compiler: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem

Creates a compilation from an explicit package definition and compiler. Resolution runs as a graph prerequisite.

Associated function fromPackage#

silk
pub effect fn fromPackage(options: &Options) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Uses the current package's default root and artifact with the command's options. A compilation selects at most one target. Commands building several targets create one compilation per target and add them to a Build.

Associated function executable#

silk
pub effect fn executable(name: string, root: string) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Creates a program named name with root resolved against the package directory.

Associated function loadableModule#

silk
pub effect fn loadableModule(name: string, root: string) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Creates a loadable module named name with root resolved against the package directory.

Associated function staticArchive#

silk
pub effect fn staticArchive(name: string, root: string) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Creates a static archive named name with root resolved against the package directory.

Associated function object#

silk
pub effect fn object(name: string, root: string) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Creates a relocatable object named name with root resolved against the package directory.

Associated function test#

silk
pub effect fn test(name: string, root: string) -> Self
    ! StepFailure
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Creates a test runner named name with root resolved against the package directory.

Method package#

silk
pub effect fn package(self: Self, alias: string, settings: Package) -> Self
    ! StepFailure
    ? &mut Allocator

Configures one declared dependency alias, or self for this package.

Method without#

silk
pub effect fn without(self: Self, alias: string) -> Self
    ! StepFailure
    ? &mut Allocator

Removes a declared dependency from this compilation's available imports.

Method target#

silk
pub effect fn target(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets target from a declared deferred value.

Method cpu#

silk
pub effect fn cpu(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets cpu from a declared deferred value.

Method deployment#

silk
pub effect fn deployment(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets deployment from a declared deferred value.

Method libc#

silk
pub effect fn libc(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets libc from a declared deferred value.

Method entry#

silk
pub effect fn entry(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets entry from a declared deferred value.

Method runtime#

silk
pub effect fn runtime(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets runtime from a declared deferred value.

silk
pub effect fn link(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets link from a declared deferred value.

Method codeModel#

silk
pub effect fn codeModel(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets codeModel from a declared deferred value.

Method relocation#

silk
pub effect fn relocation(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets relocation from a declared deferred value.

Method safety#

silk
pub effect fn safety(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets safety from a declared deferred value.

Method threading#

silk
pub effect fn threading(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets threading from a declared deferred value.

Method unwind#

silk
pub effect fn unwind(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets unwind from a declared deferred value.

Method backend#

silk
pub effect fn backend(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets backend from a declared deferred value.

Method codegenUnits#

silk
pub effect fn codegenUnits(self: Self, value: Deferred<u64>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets codegenUnits from a declared deferred value.

Method maxMemory#

silk
pub effect fn maxMemory(self: Self, value: Deferred<u64>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets maxMemory from a declared deferred value.

Method stackSize#

silk
pub effect fn stackSize(self: Self, value: Deferred<u64>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets stackSize from a declared deferred value.

Method cpuFeatures#

silk
pub effect fn cpuFeatures(self: Self, value: Deferred<List<String>>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets cpuFeatures from a declared deferred value.

Method sanitizers#

silk
pub effect fn sanitizers(self: Self, value: Deferred<List<String>>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets sanitizers from a declared deferred value.

Method optimize#

silk
pub effect fn optimize(self: Self, value: Deferred<Optimize>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets optimize from a declared deferred value.

Method debug#

silk
pub effect fn debug(self: Self, value: Deferred<bool>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets debug from a declared deferred value.

Method runner#

silk
pub effect fn runner(self: Self, value: Deferred<Runner>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects the program and arguments used to launch this artifact or its tests. WASI artifacts use wasmtime run when no runner is supplied.

Method standardLibrary#

silk
pub effect fn standardLibrary(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects a declared standard-library directory before resolution.

Method platform#

silk
pub effect fn platform(self: Self, value: Deferred<Platform>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects the target sysroot, linker, and support installations.

Method windows#

silk
pub effect fn windows(self: Self, value: Deferred<Windows>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects Windows subsystem, resource, and manifest settings.

Method macos#

silk
pub effect fn macos(self: Self, value: Deferred<MacOS>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects macOS installation, framework, and signing settings.

Method wasm#

silk
pub effect fn wasm(self: Self, value: Deferred<Wasm>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects WebAssembly memory, execution, and component settings.

Method header#

silk
pub effect fn header(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Requests a C header at an absolute output path.

Method importLibrary#

silk
pub effect fn importLibrary(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Requests an import library at an absolute output path.

Method emit#

silk
pub effect fn emit(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Sets emit from a declared deferred value.

Method root#

silk
pub effect fn root(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects a deferred source file as the compilation's root module.

Method moduleFile#

silk
pub effect fn moduleFile(self: Self, name: string, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a generated module file to the root package.

Method module#

silk
pub effect fn module(self: Self, name: string, text: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Writes deferred source text as a generated module before compiling its consumer.

Method embed#

silk
pub effect fn embed(self: Self, name: string, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Embeds a file or another compilation's artifact in a generated module named name. Import that module's data constant to read its bytes; the producer runs before compilation.

Method compileC#

silk
pub effect fn compileC(
    self: Self,
    path: Deferred<Path>,
    flags: Deferred<List<String>>,
    include: List<Deferred<Path>>,
  ) -> Self
    ! StepFailure
    ? &mut Allocator

Compiles a deferred c source with declared flags and include directory trees.

Method compileCpp#

silk
pub effect fn compileCpp(
    self: Self,
    path: Deferred<Path>,
    flags: Deferred<List<String>>,
    include: List<Deferred<Path>>,
  ) -> Self
    ! StepFailure
    ? &mut Allocator

Compiles a deferred cpp source with declared flags and include directory trees.

Method compileObjectiveC#

silk
pub effect fn compileObjectiveC(
    self: Self,
    path: Deferred<Path>,
    flags: Deferred<List<String>>,
    include: List<Deferred<Path>>,
  ) -> Self
    ! StepFailure
    ? &mut Allocator

Compiles a deferred objc source with declared flags and include directory trees.

Method compileObjectiveCpp#

silk
pub effect fn compileObjectiveCpp(
    self: Self,
    path: Deferred<Path>,
    flags: Deferred<List<String>>,
    include: List<Deferred<Path>>,
  ) -> Self
    ! StepFailure
    ? &mut Allocator

Compiles a deferred objcpp source with declared flags and include directory trees.

Method linkArchive#

silk
pub effect fn linkArchive(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred archive input, including its contents in the key.

Method linkObject#

silk
pub effect fn linkObject(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred object input, including its contents in the key.

Method searchPath#

silk
pub effect fn searchPath(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred search-path input, including its contents in the key.

Method frameworkSearchPath#

silk
pub effect fn frameworkSearchPath(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred framework-search-path input, including its contents in the key.

Method linkerScript#

silk
pub effect fn linkerScript(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred linker-script input, including its contents in the key.

Method functionOrder#

silk
pub effect fn functionOrder(self: Self, path: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Selects a deferred function-order file, including its contents in the key.

Method linkLibrary#

silk
pub effect fn linkLibrary(self: Self, name: Deferred<String>, library: Library) -> Self
    ! StepFailure
    ? &mut Allocator

Links a deferred library name as library describes, for example Library.dynamicSearch().

Method linkFramework#

silk
pub effect fn linkFramework(self: Self, name: Deferred<String>, framework: Framework) -> Self
    ! StepFailure
    ? &mut Allocator

Links a deferred macOS framework name as framework describes, for example Framework.make().

Method rpath#

silk
pub effect fn rpath(self: Self, value: Deferred<String>) -> Self
    ! StepFailure
    ? &mut Allocator

Adds a deferred runtime library search path, preserving loader-relative tokens.

Method linkArtifact#

silk
pub effect fn linkArtifact(self: Self, artifact: Deferred<Path>) -> Self
    ! StepFailure
    ? &mut Allocator

Links another compilation's deferred artifact and schedules its producer first.

Method build#

silk
pub effect fn build(self: Self) -> Built
    ! BuildError
    ? &mut Allocator | &mut FileSystem | &mut HostInput

Executes this compilation through the build runner, publishing its request and artifact.

Method memoryBudget#

silk
pub effect fn memoryBudget(self: Self, bytes: u64) -> Self
    ! StepFailure
    ? &mut Allocator

Sets the runner's peak-memory estimate for this compiler process; the default is 3 GiB.

Method unsandboxedTools#

silk
pub effect fn unsandboxedTools(self: Self, allowed: bool) -> Self
    ! StepFailure
    ? &mut Allocator

Authorizes package tools to run without a sandbox for this graph execution. This setting is not serialized into compilation definitions or requests.

Method step#

silk
pub effect fn step(self: &Self) -> StepHandle
    ! StepFailure
    ? &mut Allocator

Registers the compilation once, freezing its settings. The step holds the compilation's description, which the compiler restores and runs.

Method artifact#

silk
pub effect fn artifact(self: &Self) -> Deferred<Path>
    ! StepFailure
    ? &mut Allocator

Returns the artifact's deferred path; consuming it adds this compilation as a dependency.

Method emittedHeader#

silk
pub effect fn emittedHeader(self: &Self) -> Deferred<Path>
    ! StepFailure
    ? &mut Allocator

Returns the generated C header as a deferred input. Configure header before using it. Consuming the path runs this compilation and rejects a missing header output.

Method emittedImportLibrary#

silk
pub effect fn emittedImportLibrary(self: &Self) -> Deferred<Path>
    ! StepFailure
    ? &mut Allocator

Returns the Windows import library as a deferred input. Configure importLibrary first. Consuming the path runs this compilation and rejects a missing import-library output.

restore#

silk
pub effect fn restore(step: &[u8]) -> StepHandle
  ! StepFailure
  ? &mut Allocator | &mut FileSystem

Restores a described compilation as the steps this process can run: one resolves its request and one compiles it. Answers the compiling step.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.

View the source of this page