# Build

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-build/struct-build/

**struct** · [`ferroui-build`](/docs/0.5.0/api/ferroui-build/) · v0.5.0

```rust
struct Build
```

The build of the markup of a crate; see the crate documentation.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L339)

## Members

- [`from_env`](#function-from_env)
- [`new`](#function-new)
- [`full_themes`](#function-full_themes)
- [`theme_roots`](#function-theme_roots)
- [`hot_reload_manifest`](#function-hot_reload_manifest)
- [`type_system`](#function-type_system)
- [`default_compile_bindings`](#function-default_compile_bindings)
- [`analyzer_config_files`](#function-analyzer_config_files)
- [`warnings_as_errors`](#function-warnings_as_errors)
- [`export_metadata`](#function-export_metadata)
- [`source_root`](#function-source_root)
- [`assembly`](#function-assembly)
- [`xaml_root`](#function-xaml_root)
- [`input`](#function-input)
- [`embed_assets`](#function-embed_assets)
- [`compile_xaml`](#function-compile_xaml)
- [`compile_group`](#function-compile_group)
- [`loader`](#function-loader)
- [`checked_in_metadata`](#function-checked_in_metadata)
- [`run`](#function-run)
- [`execute`](#function-execute)

<a id="function-from_env"></a>

### from_env

```rust
fn from_env() -> Self
```

The build of the crate whose build script is running: `CARGO_MANIFEST_DIR`,
`OUT_DIR`, `CARGO_PKG_NAME`, and the `.xamlmeta` of every direct dependency
(`DEP_<CRATE>_XAML_XAMLMETA`), in the order of the names of the variables.
## Panics
Panics outside a build script (a variable Cargo sets is missing).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L372)

<a id="function-new"></a>

### new

```rust
fn new(manifest_dir: PathBuf, out_dir: PathBuf, package_name: &str, dependencies: Vec<PathBuf>) -> Self
```

The build of the package `package_name` in `manifest_dir`, writing below `out_dir`,
with the `.xamlmeta` files of its direct dependencies.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L385)

<a id="function-full_themes"></a>

### full_themes

```rust
fn full_themes(self: Self, value: bool) -> Self
```

Whether the base crate has `full-themes` in this build (`FULL_THEMES_VARIABLE`, which
`from_env` reads): a crate whose compiled markup has units is then built
with the `cfg` `FULL_THEMES_CFG`, and an application that trims its themes keeps every
unit (#568, step 3).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L414)

<a id="function-theme_roots"></a>

### theme_roots

```rust
fn theme_roots(self: Self, names: &[&str]) -> Self
```

Roots of the themes the application trims, beside its documents and the `theme-roots` of
its manifest (#568, step 3): units by the path of their document, types or keys. Nothing
when the manifest turns the trimming off (`[package.metadata.ferroui] theme-trimming = false`).

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L422)

<a id="function-hot_reload_manifest"></a>

### hot_reload_manifest

```rust
fn hot_reload_manifest(self: Self, enabled: bool) -> Self
```

Emits source metadata when enabled and the target has debug assertions enabled.
Cargo 1.93 and later state the target profile configuration; with older Cargo the
root of the profile (`PROFILE`, else `OPT_LEVEL`) decides, and an explicit
`-C debug-assertions` rustflag wins on every version. The build fails when the
configuration cannot be determined.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L432)

<a id="function-type_system"></a>

### type_system

```rust
fn type_system(self: Self, type_system: TypeSystem) -> Self
```

The type system the documents are compiled against; `TypeSystem::Runtime` without
the call.

With `TypeSystem::Model` the build scans the sources of the crate (as
`export_metadata` does, and writes the model the same
way), reads the models of the crates it depends on from their `.xamlmeta`, and
compiles every group against the type system over those models. The build script
registers nothing and needs no `assembly`: the assembly is the
`MarkupAssembly` the sources state. A document the models cannot answer a question
of the emitter for is an error of the build that names the document and the
question; it is never compiled from a guess.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L448)

<a id="function-default_compile_bindings"></a>

### default_compile_bindings

```rust
fn default_compile_bindings(self: Self, value: bool) -> Self
```

Whether `{Binding}` is a compiled binding in a document that does not say otherwise
(`x:CompileBindings`): the `DefaultCompileBindings` of upstream's build task. Compiled
bindings are the default without the call (#603). The manifest of the crate has the last
word: `[package.metadata.ferroui] compile-bindings = false` (or `true`) overrides the call,
as the project property overrides the default of upstream's build task.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L458)

<a id="function-analyzer_config_files"></a>

### analyzer_config_files

```rust
fn analyzer_config_files(self: Self, files: &[&str]) -> Self
```

The EditorConfig files of the build, relative to the crate directory (the
`AnalyzerConfigFiles` of upstream's build task): an entry
`ferro_xaml_diagnostic.<code>.severity = <severity>` states the severity a diagnostic
of the markup compiler with that code is reported with (`error`, `warning`,
`default`; anything else silences it). A file that does not exist is skipped; the
build runs again when one changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L469)

<a id="function-warnings_as_errors"></a>

### warnings_as_errors

```rust
fn warnings_as_errors(self: Self, value: bool) -> Self
```

Reports every warning of the markup compiler as an error of the build (the
`TreatWarningsAsErrors` upstream leaves to the build system), after the severities
of the EditorConfig files: a warning a file silences stays silent. Every document is
still compiled before the build fails.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L478)

<a id="function-export_metadata"></a>

### export_metadata

```rust
fn export_metadata(self: Self) -> Self
```

Scans the sources of the crate and writes its type model into its `.xamlmeta`
(format 2: the model next to the compiled documents), which the crates that depend
on this one read as they read its documents (xaml.md 9.6.3). The scan reads the
models of the dependencies of the crate first, so that what the crate names of
theirs is resolved (`ScanOptions::dependencies`).

The sources are read as files: nothing of the crate is linked, and a crate that
only exports its model needs no `assembly` (the scan reads the
`MarkupAssembly` the sources state; a crate without one is the assembly named after
the crate). What the scanner cannot read of a declaration is a `cargo::warning=`
line and does not fail the build.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L494)

<a id="function-source_root"></a>

### source_root

```rust
fn source_root(self: Self, file: &str) -> Self
```

The root file of the sources of the crate, relative to the crate directory, for
`export_metadata`. Without the call: `src/lib.rs`, else
`lib.rs`, else `src/main.rs`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L502)

<a id="function-assembly"></a>

### assembly

```rust
fn assembly(self: Self, assembly: &'static MarkupAssembly) -> Self
```

The assembly of the crate: its name is the host of the URIs of its documents and
assets, and its metadata the default of `CreateSourceInfo`. The same value the
crate registers in its `register_types()`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L520)

<a id="function-xaml_root"></a>

### xaml_root

```rust
fn xaml_root(self: Self, directory: &str) -> Self
```

The directory, relative to the crate directory, below which the documents of a
group without stated documents are found. The crate directory by default.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L527)

<a id="function-input"></a>

### input

```rust
fn input(self: Self, path: &str) -> Self
```

A file, relative to the crate directory, the build reads through the build
script (a file the script includes): the build runs again when it changes.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L534)

<a id="function-embed_assets"></a>

### embed_assets

```rust
fn embed_assets(self: Self, directories: &[&str]) -> Self
```

Embeds every file below the directories (relative to the crate directory) as an
asset of the crate, by its path below the crate directory, except the documents
the build compiles.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L542)

<a id="function-compile_xaml"></a>

### compile_xaml

```rust
fn compile_xaml(self: Self) -> Self
```

Compiles every `.xaml` file below the XAML root as the group
`DEFAULT_MODULE`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L549)

<a id="function-compile_group"></a>

### compile_group

```rust
fn compile_group(self: Self, group: XamlGroup) -> Self
```

Compiles a group of documents.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L554)

<a id="function-loader"></a>

### loader

```rust
fn loader(self: Self, path: &str) -> Self
```

The loader table of a checked-in generated file of the crate, by the path of its
`try_load` (`crate::compiled_main_window::try_load`): the table of the crate asks
it first, in the order of the calls.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L562)

<a id="function-checked_in_metadata"></a>

### checked_in_metadata

```rust
fn checked_in_metadata(self: Self, path: &str) -> Self
```

The `.xamlmeta` of a checked-in generated file of the crate, relative to the crate
directory: its documents are added to the `.xamlmeta` of the crate.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L569)

<a id="function-run"></a>

### run

```rust
fn run(self: Self)
```

Runs the build and prints its lines for Cargo. On an error every error is printed
and the process exits with a failure.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L576)

<a id="function-execute"></a>

### execute

```rust
fn execute(self: Self) -> Outcome
```

Runs the build and returns what `run` prints.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Build.Tasks/lib.rs#L591)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `ErasedDestructor`
- `IntoEither`

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
