Programmatic implementation of Scrypto compiler which is a wrapper around rust cargo tool.
To create an instance of ScryptoCompiler use builder() constructor which implements builder pattern,
provide any required parameter @see ScryptoCompilerInputParams and finally call compile() function.
ScryptoCompiler supports worspace compilation by providing workspace manifest as manifest_path parameter of
running compiler from directory containg workspace Cargo.toml file. Only packages with defined metadata group:
[package.metadata.scrypto] will be used during workspace compilation (so workspace manifest can contain also non
Scrypto packages). Alternativelly packages for workspace compilation can be provided in package input parameter,
metadata is not validated in that case.
Compilation results consists of list of BuildArtifacts which contains generated WASM file path and its content
and path to RPD file with package definition and PackageDefinition struct.
The default RustFlags defined in RustFlags::for_scrypto_compilation are sometimes not
enough to prevent the compiler from generating code that contains WASM features that we don’t
want. Especially, in cases where crates contain C code that gets compiled into WASM (minicov
is one example). In cases like these, we need to set the CFLAGS_wasm32_unknown_unknown
environment variable to this constant to ensure that of the compiled Rust code and C code adhere
to the same set of features that we allow.