Function daml_codegen::generator::daml_codegen
source · [−]pub fn daml_codegen(
dar_file: &str,
output_path: &str,
module_filter_regex: &[&str],
quote_method: RenderMethod,
module_output_mode: ModuleOutputMode
) -> Result<(), DamlCodeGenError>
Expand description
Code generator which is designed to be called from build.rs
files.
To use the daml_codegen
function you must first import the daml
crate and specify feature codegen
:
[dependencies]
daml = { version = "0.2.2", features = [ "codegen" ] }
In your build.rs
main function invoke the daml_codegen
function for a dar
file and specify where the
generated src code should be created:
use daml_codegen::generator::{daml_codegen, ModuleOutputMode, RenderMethod};
let method = RenderMethod::Full;
let mode = ModuleOutputMode::Combined;
daml_codegen("MyModel.dar", "src/autogen", &[], method, mode).unwrap();
In the example above we used RenderMethod::Full
to indicate that we want to render Rust types without
intermediate annotations (such as DamlTemplate
) and ModuleOutputMode::Combined
to combine all Daml modules
in a single Rust src file.