aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-05-01 18:50:54 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-05-01 18:50:54 +0200
commitf724ef3ee1ae51de809481fe93d8a16205702406 (patch)
tree8914965a9d1aa08d42d5d00ee0d534848abea8de
parent3e00c224007db19cdc7869435967c5decea570a5 (diff)
build(typst): optimize cargo
-rw-r--r--build.zig11
-rw-r--r--lib/typst/Cargo.toml9
2 files changed, 15 insertions, 5 deletions
diff --git a/build.zig b/build.zig
index cf4493c..5c65779 100644
--- a/build.zig
+++ b/build.zig
@@ -19,7 +19,14 @@ pub fn build(b: *std.Build) void {
"cargo", "build",
});
build_typst.setCwd(b.path(TYPST));
- if (optimize != .Debug) build_typst.addArg("--release");
+ switch (optimize) {
+ .ReleaseSmall => {
+ build_typst.addArg("--profile");
+ build_typst.addArg("small");
+ },
+ .ReleaseFast, .ReleaseSafe => build_typst.addArg("--release"),
+ else => {},
+ }
const typst = b.addTranslateC(.{
.root_source_file = b.path(TYPST ++ "/typdown_typst.h"),
@@ -45,7 +52,7 @@ pub fn build(b: *std.Build) void {
const lib = b.addLibrary(.{
.name = "typdown",
- .linkage = .dynamic,
+ .linkage = .static,
.root_module = mod,
.use_llvm = true, // zig internal backend crashes during linking (for 0.15.2)
});
diff --git a/lib/typst/Cargo.toml b/lib/typst/Cargo.toml
index dc7eb97..a87ce82 100644
--- a/lib/typst/Cargo.toml
+++ b/lib/typst/Cargo.toml
@@ -12,11 +12,14 @@ typst-kit = "0.14.2"
typst-svg = "0.14.2"
[profile.release]
-opt-level = 2
-codegen-units = 1
-lto = true
+lto = "thin"
+opt-level = 3
strip = true
+[profile.small]
+inherits = "release"
+opt-level = "s"
+
[features]
default = ["embed-fonts"]