Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ltx_compiler

Compilation orchestration. Turns a validated manifest into a compiled PDF by dispatching to a configured engine. Currently only the tectonic engine is wired up; the other engines emit a warning.

Responsibilities

  • compilation pipeline (build)
  • engine abstraction (CompilerConfig, engine dispatch)
  • tectonic integration (tectonic_compile)
  • file watching for rebuild-on-save (watch)
  • compiler-specific diagnostics (owned by this crate)

Key types

TypeRole
CompilerConfigEngine, output name, main file, and compile options resolved from a manifest.
CompilerErrorAll compiler diagnostics (LTX::COMPILER::E001E006, W001).
build::buildEntry point: resolves the main file, then dispatches to the engine.
tectonic::tectonic_compileDrives tectonic’s ProcessingSessionBuilder to produce a PDF.
watch::WatchConfigDebounced, recursive watcher that rebuilds on relevant changes.

Error ownership

CompilerError (in src/error.rs):

CodeVariant
E001MissingMain — no [project].main at compile time
E002MissingBuild — no [build] section
E003MainFileNotFound — main file missing on disk
E004TectonicError — bundle fetch / session creation / compilation failed
E005Init — file watcher failed to start
E006ChannelClosed — watch event channel disconnected
W001EngineNotImplemented — engine not wired up yet (warning)

CompilerError implements miette::Diagnostic so it converts into miette::Report and can be returned directly from miette::Result functions. See the Compiler Errors table.

Engine behavior

  • tectonic — real compilation via the tectonic crate.
  • pdflatex / xelatex / lualatex — emit LTX::COMPILER::W001 through miette to stderr and return Ok(()) (a warning never fails the build).

Usage

#![allow(unused)]
fn main() {
use ltx_compiler::{CompilerConfig, build};

let manifest = ltx_config::LtxManifest::from_file("ltx.toml")?;
let config = CompilerConfig::from_manifest(&manifest)?;
build::build(&config, project_root)?;
}

Design notes

  • Input is a CompilerConfig; output always goes to target/.
  • watch.rs watches only the src/ root (structured ltx new --src projects) or the main file itself (single-structure ltx new projects), plus the manifest, and rebuilds through build::build on every relevant change (.tex, .sty, .cls, .bib). The compiler’s own target/ output is never watched, so builds cannot feed back into a rebuild loop. Driven by the ltx watch CLI command.