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
| Type | Role |
|---|---|
CompilerConfig | Engine, output name, main file, and compile options resolved from a manifest. |
CompilerError | All compiler diagnostics (LTX::COMPILER::E001–E006, W001). |
build::build | Entry point: resolves the main file, then dispatches to the engine. |
tectonic::tectonic_compile | Drives tectonic’s ProcessingSessionBuilder to produce a PDF. |
watch::WatchConfig | Debounced, recursive watcher that rebuilds on relevant changes. |
Error ownership
CompilerError (in src/error.rs):
| Code | Variant |
|---|---|
E001 | MissingMain — no [project].main at compile time |
E002 | MissingBuild — no [build] section |
E003 | MainFileNotFound — main file missing on disk |
E004 | TectonicError — bundle fetch / session creation / compilation failed |
E005 | Init — file watcher failed to start |
E006 | ChannelClosed — watch event channel disconnected |
W001 | EngineNotImplemented — 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 thetectoniccrate.pdflatex/xelatex/lualatex— emitLTX::COMPILER::W001throughmietteto stderr and returnOk(())(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 totarget/. watch.rswatches only thesrc/root (structuredltx new --srcprojects) or the main file itself (single-structureltx newprojects), plus the manifest, and rebuilds throughbuild::buildon every relevant change (.tex,.sty,.cls,.bib). The compiler’s owntarget/output is never watched, so builds cannot feed back into a rebuild loop. Driven by theltx watchCLI command.