Skip to main content

Crate ferroui_build_scan

Crate ferroui_build_scan 

Source
Expand description

ferroui-build-scan

The build-time type model of a crate, the source scanner that fills it and the export of the model through the build script of the crate (docs/porting/xaml.md, 9.5.1, 9.5.13 and 9.6.3). No counterpart upstream: upstream’s compiler reads the types of a referenced assembly from its metadata; a Rust crate has none, so a crate writes what its declarations state into its .xamlmeta and hands the file to the crates that depend on it.

The crate depends on the standard library and on the three crates the scanner reads Rust source with, and on nothing of the framework: the base crate, the controls and the XAML runtime library take it as a build dependency to export their own models, which a crate that depends on the compiler (ferroui-build, which links the three) could not be.

ⓘ
// build.rs of a crate that declares types and has no documents
fn main() {
    ferroui_build_scan::export::Export::from_env().run();
}
# Cargo.toml of that crate
[package]
build = "build.rs"
links = "<crate>_xaml"

[build-dependencies]
ferroui-build-scan = { workspace = true }

What is here:

  • model: the type model of a crate (AssemblyModel, TypeModel, MemberModel, RegisteredModel) and its file, the .xamlmeta of format 2, which keeps the documents of format 1 where the compiler reads them;
  • xaml_metadata: the part of the file the compiler of a crate reads of another crate, its compiled documents (format 1);
  • scanner: the source scanner, which fills the model from the declaration macros of the sources of a crate (scan_crate), linking nothing;
  • model_set: the models of several crates read together, so that a type or a property of one crate is found by the path another crate names it by;
  • call_forms: how generated code calls each member a declaration states by a callable (xaml.md 9.5.3), chosen at the end of a scan and written into the model;
  • export: the scan of the crate whose build script is running, with the models of its dependencies, written into its .xamlmeta.

The compiler over the models (ModelTypeSystem, ModelEmitTypes, Build::compile_xaml) is in ferroui-build, which exports every module of this crate under its own name.

§The host and the target

A build script runs on the host whatever the target of the build is, and the scan reads the sources as text: a cfg condition is recorded with the declaration it guards and never evaluated, so the model of a crate is the same text for every target and every set of features. A cross build (the browser build of the framework for wasm32) builds this crate and the three it depends on for the host once and exports the same files.

Modules§

call_forms
The choice of a call form for every callable of a model (docs/porting/xaml.md, 9.5.3): how generated code calls a constructor, a method, a static field, an event, Parse or the accessor of a plain property that a declaration states by a callable.
export
The export of the type model of a crate from its build script (docs/porting/xaml.md, 9.5.13 and 9.6.3): the sources of the crate are scanned, with the models of the crates it depends on, and the model is written to $OUT_DIR/<crate>.xamlmeta, whose path Cargo hands to the build scripts of the crates that depend on this one (the links key of the manifest and the cargo::metadata=xamlmeta=<path> line: they read DEP_<LINKS>_XAMLMETA).
model
The build-time type model of a crate and its serialised form, the .xamlmeta file (docs/porting/xaml.md, 9.5.1).
model_set
The models of several crates read together: the model of a crate and the models of the crates it is built on (docs/porting/xaml.md, 9.5.1 and 9.6.3).
scanner
The source scanner: reads the sources of a crate and fills the build-time type model from its declarations (docs/porting/xaml.md, 9.5.1 and 9.5.2).
xaml_metadata
The .xamlmeta file of a crate with compiled markup, as far as the compiler reads it today: the assembly and its compiled documents (docs/porting/xaml.md, 9.5.1 AssemblyModel / DocumentModel, 9.6.3, 9.7.3).

Constants§

CREATE_SOURCE_INFO
The key of the assembly metadata that turns source information on (ferroui_base::metadata::MarkupAssembly::CREATE_SOURCE_INFO), stated here for the reason FERRO_XML_NAMESPACE is.
FERRO_XML_NAMESPACE
The XML namespace of the framework, as the base crate states it (ferroui_base::metadata::FERRO_XML_NAMESPACE). The scanner reads the MarkupAssembly of a crate that names the constant; this crate cannot link the base crate (the base crate scans itself with it), so the text is stated here, and a test of ferroui-build, which links both, compares the two.
USE_COMPILED_BINDINGS_BY_DEFAULT
The key of the assembly metadata that makes {Binding} a compiled binding by default (ferroui_base::metadata::MarkupAssembly::USE_COMPILED_BINDINGS_BY_DEFAULT), stated here for the reason FERRO_XML_NAMESPACE is.