Repository navigation
fix(spec-gen): copy Typst specs into crate so vendored builds succeed - #2
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why this is needed
Lockbook embeds both MiTeX and Typst inside one native Rust binary, so our fork added
TYPST_SPECStocrates/mitex-spec-gen/src/lib.rsto bake MiTeX's three Typst definition files (mod.typ,prelude.typ, andlatex/standard.typ) directly into the compiled binary.Previously,
lib.rspulled those files in withinclude_str!("../../../packages/mitex/specs/..."), climbing out of thecrates/mitex-spec-gen/crate folder into the repo's top-levelpackages/mitex/specs/directory.That works during normal online Cargo builds (where Cargo clones the entire git repository), but breaks offline/vendored builds like Flathub (
flatpak-cargo-generator),cargo vendor, andcargo package. Those tools extract only each Rust crate's own folder (crates/mitex-spec-gen/) intocargo/vendor/mitex-spec-gen/and leavepackages/mitex/specs/behind, causing the Flathub build to fail withNo such file or directory.What this PR changes
.typfiles intocrates/mitex-spec-gen/assets/specs/so everything the crate compiles lives inside its own directory (the same wayassets/artifacts/spec/default.jsonalready does).mod.typ(12),prelude.typ(230), andlatex/standard.typ(1,222). Only 31 lines are Rust changes insrc/lib.rs.packages/mitex/specs/is the source of truth used by the Typst package (packages/mitex/mitex.typ),build.rsingeneratemode,mitex-cli, and upstreammitex-rs/mitex. Leaving it in place avoids breaking those paths and keeps merges from upstream clean.TYPST_SPECSincrates/mitex-spec-gen/src/lib.rstoinclude_str!from../assets/specs/....vendored_typst_specs_match_package) that verifies the crate-local copies matchpackages/mitex/specs/byte-for-byte during workspace test runs, so the two copies can't silently drift apart.Verification
cargo test -p mitex-spec-gen --features prebuilt,cargo test -p mitex --features mitex-spec-gen/prebuilt,cargo clippy -p mitex-spec-gen --all-targets --features prebuilt,cargo fmt --check --all, andcargo doc -p mitex-spec-gen --no-deps --features prebuilt(all withRUSTFLAGS="-Dwarnings"andRUSTDOCFLAGS="-Dwarnings").crates/mitex-specandcrates/mitex-spec-geninto a fresh workspace withoutpackages/and runningcargo checkandcargo test.