silk.build.plan.

Pure package requirements built with the same standard actions and deferred paths as tasks.

A package declares pub const PLAN: Plan in build.silk. The compiler evaluates the value without effects. Generated files and processes execute later through the build graph; package processes require dependency authorization and a supported operating-system sandbox.

Import as Plan with import silk.build.plan { Plan }.

Public declarations: 4.

Operation#

silk
pub union Operation

One static package requirement, interpreted after its deferred producers complete.

Module#

silk
Module

A generated Silk module, named relative to the package's source root.

Field name#

silk
pub name: string<'static>

Field source#

silk
pub source: Input

Compile#

silk
Compile

A native source file in the indicated language.

Field language#

silk
pub language: string<'static>

Field source#

silk
pub source: Input

Field flags#

silk
pub flags: &'static [string<'static>]

Field include#

silk
pub include: Option<&'static Chain<Input>>

Field pattern#

silk
pub pattern: Option<string<'static>>

Flag#

silk
Flag

A native compiler flag, applied to the package's translation units in order.

Field value#

silk
pub value: string<'static>

Include#

silk
Include

An include directory shared by the package's native translation units.

Field path#

silk
pub path: Input

LinkFile#

silk
LinkFile

A linker file or search directory.

Field kind#

silk
pub kind: string<'static>

Field path#

silk
pub path: Input
silk
Link

A named library or framework.

Field kind#

silk
pub kind: string<'static>

Field name#

silk
pub name: string<'static>

Field mode#

silk
pub mode: string<'static>

Field weak#

silk
pub weak: bool

Field needed#

silk
pub needed: bool

RPath#

silk
RPath

A runtime library search path.

Field value#

silk
pub value: string<'static>

FunctionOrder#

silk
FunctionOrder

The package's native symbol order file.

Field path#

silk
pub path: Input

LinkDependency#

silk
LinkDependency

A declared dependency whose native plan links into this package's artifacts.

Field name#

silk
pub name: string<'static>

Library#

silk
pub struct Library

How a named library is linked: by static or dynamic search, and whether it is weak or retained.

When to use#

Pass it to Plan.linkLibrary or Compilation.linkLibrary. Start from Library.dynamicSearch or Library.staticSearch and add Library.weak or Library.needed only where the link needs them.

Field mode#

silk
pub mode: string<'static>

"dynamic" or "static".

Field isWeak#

silk
pub isWeak: bool

Whether the program may start when the library is absent.

Field isNeeded#

silk
pub isNeeded: bool

Whether the library stays linked when no symbol refers to it.

Implementation Library#

silk
impl Library

Associated function dynamicSearch#

silk
pub fn dynamicSearch() -> Library

A library found by dynamic search, strong and dropped when unused.

Associated function staticSearch#

silk
pub fn staticSearch() -> Library

A library found by static search, strong and dropped when unused.

Method weak#

silk
pub fn weak(self: Self) -> Library

Returns this library linked weakly, so the program may start when it is absent.

Method needed#

silk
pub fn needed(self: Self) -> Library

Returns this library retained even when no symbol refers to it.

Framework#

silk
pub struct Framework

How a named macOS framework is linked: whether it is weak or retained.

When to use#

Pass it to Plan.linkFramework or Compilation.linkFramework. Start from Framework.make and add Framework.weak or Framework.needed only where the link needs them.

Field isWeak#

silk
pub isWeak: bool

Whether the program may start when the framework is absent.

Field isNeeded#

silk
pub isNeeded: bool

Whether the framework stays linked when no symbol refers to it.

Implementation Framework#

silk
impl Framework

Associated function make#

silk
pub fn make() -> Framework

A framework linked strongly and dropped when unused.

Method weak#

silk
pub fn weak(self: Self) -> Framework

Returns this framework linked weakly, so the program may start when it is absent.

Method needed#

silk
pub fn needed(self: Self) -> Framework

Returns this framework retained even when no symbol refers to it.

Plan#

silk
pub struct Plan

The immutable requirements contributed by a package wherever it is used.

Field steps#

silk
pub steps: Option<&'static Chain<Operation>>

Requirements in reverse insertion order; producers are retained by their deferred inputs.

Implementation Plan#

silk
impl Plan

Method when#

silk
pub static fn when(self: Self, condition: bool, transform: fn(Self) -> Self) -> Self

Applies transform when condition is true, returning this plan without calling it otherwise.

Associated function archivePath#

silk
pub static fn archivePath(name: string<'static>, path: string<'static>) -> Deferred<Path>

Names a file or directory in this package's manifest-pinned native archive. The package plan resolves the target variant and root or machine override before running steps.

Associated function empty#

silk
pub static fn empty() -> Self

Starts a package plan without requirements.

Method module#

silk
pub static fn module(self: Self, name: string<'static>, source: Deferred<Path>) -> Self

Adds the file produced by a standard step as a generated Silk module.

Method compileC#

silk
pub static fn compileC(self: Self, source: Deferred<Path>) -> Self

Compiles a deferred C file into the package's native inputs.

Method compileCpp#

silk
pub static fn compileCpp(self: Self, source: Deferred<Path>) -> Self

Compiles a deferred C++ file into the package's native inputs.

Method compileObjectiveC#

silk
pub static fn compileObjectiveC(self: Self, source: Deferred<Path>) -> Self

Compiles a deferred Objective-C file into the package's native inputs.

Method compileObjectiveCpp#

silk
pub static fn compileObjectiveCpp(self: Self, source: Deferred<Path>) -> Self

Compiles a deferred Objective-C++ file into the package's native inputs.

Method compileNative#

silk
pub static fn compileNative(
    self: Self,
    language: string<'static>,
    source: Deferred<Path>,
    flags: &'static [string<'static>],
    include: &'static [Deferred<Path>],
  ) -> Self

Compiles one translation unit with flags and include directories applying only to that file. language is c, cpp, objc, or objcpp. Package-wide flags and includes are also applied.

Method compileSources#

silk
pub static fn compileSources(
    self: Self,
    language: string<'static>,
    directory: Deferred<Path>,
    pattern: string<'static>,
    flags: &'static [string<'static>],
    include: &'static [Deferred<Path>],
  ) -> Self

Compiles matching files from a declared directory with flags and include paths for those files. Resolution expands the glob after any producer or pinned archive has supplied the directory.

Method cFlag#

silk
pub static fn cFlag(self: Self, value: string<'static>) -> Self

Adds one allowed native compiler flag to this package's translation units.

Method includePath#

silk
pub static fn includePath(self: Self, path: Deferred<Path>) -> Self

Adds an include directory to this package's native translation units.

Method linkArchive#

silk
pub static fn linkArchive(self: Self, path: Deferred<Path>) -> Self

Links a deferred static archive.

Method linkObject#

silk
pub static fn linkObject(self: Self, path: Deferred<Path>) -> Self

Links a deferred object file.

Method searchPath#

silk
pub static fn searchPath(self: Self, path: Deferred<Path>) -> Self

Adds a deferred library search directory.

Method frameworkSearchPath#

silk
pub static fn frameworkSearchPath(self: Self, path: Deferred<Path>) -> Self

Adds a deferred framework search directory.

Method linkerScript#

silk
pub static fn linkerScript(self: Self, path: Deferred<Path>) -> Self

Supplies a deferred native linker script.

Method linkLibrary#

silk
pub static fn linkLibrary(self: Self, name: string<'static>, library: Library) -> Self

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

Method linkDependency#

silk
pub static fn linkDependency(self: Self, name: string<'static>) -> Self

Links the native plan of name, a dependency this package declares, into every artifact that links this package, even when nothing imports it: for a package of only C, whose functions this package declares itself. A name the manifest does not declare refuses the plan.

Method linkFramework#

silk
pub static fn linkFramework(self: Self, name: string<'static>, framework: Framework) -> Self

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

Method rpath#

silk
pub static fn rpath(self: Self, value: string<'static>) -> Self

Adds a runtime library search path.

Method functionOrder#

silk
pub static fn functionOrder(self: Self, path: Deferred<Path>) -> Self

Selects a deferred native symbol-order file.

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