Skip to main content

compile_to_dir

Function compile_to_dir 

Source
pub fn compile_to_dir(
    source: &str,
    output_dir: &Path,
) -> Result<(), CompileError>
Expand description

Compile LOGOS source and write output to a directory as a Cargo project.

Creates a complete Cargo project structure with:

  • src/main.rs containing the generated Rust code
  • Cargo.toml with runtime dependencies
  • crates/ directory with runtime crate copies

§Arguments

  • source - LOGOS source code as a string
  • output_dir - Directory to create the Cargo project in

§Errors

Returns CompileError if:

  • Compilation fails (wrapped as CompileError::Parse)
  • File system operations fail (wrapped as CompileError::Io)

§Example

let source = "## Main\nShow \"Hello\".";
compile_to_dir(source, Path::new("/tmp/my_project"))?;
// Now /tmp/my_project is a buildable Cargo project