diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-29 18:10:33 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2026-04-29 18:10:33 +0200 |
| commit | 0535fa152ae990a28d0b7b9a59e96911074118b8 (patch) | |
| tree | 2b78936f147429da5b593174ee2e6cabbf9becbd /build.zig | |
| parent | 99d2408ad3113f3d79b496ed30798bbd15bc6cfc (diff) | |
build(zig): include typst module
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -4,17 +4,36 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); + // build typst module + const build_typst = b.addSystemCommand(&[_][]const u8{ + "cargo", "build", + }); + build_typst.setCwd(b.path("typst/")); + if (optimize != .Debug) build_typst.addArg("--release"); + b.getInstallStep().dependOn(&build_typst.step); + const mod = b.addModule("typdown", .{ .root_source_file = b.path("src/root.zig"), .target = target, .optimize = optimize, }); if (!target.result.isWasiLibC()) mod.link_libc = true; + // link typst module during build + mod.addIncludePath(b.path("typst")); + mod.addLibraryPath( + if (optimize == .Debug) b.path("typst/target/debug/") + else b.path("typst/target/release/") + ); + if (optimize != .Debug) mod.strip = true; + const lib = b.addLibrary(.{ .name = "typdown", - .linkage = .dynamic, + .linkage = .static, .root_module = mod, }); + // link typst module to build + lib.linkSystemLibrary("typdown_typst"); + const installed_lib = b.addInstallArtifact(lib, .{}); // when emitting headers will be fixed //installed_lib.emitted_h = lib.getEmittedH(); @@ -42,10 +61,11 @@ pub fn build(b: *std.Build) void { const run_mod_tests = b.addRunArtifact(mod_tests); const test_step = b.step("test", "Run tests"); + test_step.dependOn(b.getInstallStep()); test_step.dependOn(&run_mod_tests.step); const examples_step = b.step("examples", "Run examples"); - examples_step.dependOn(&installed_lib.step); + examples_step.dependOn(b.getInstallStep()); const example_run = b.addRunArtifact(example); examples_step.dependOn(&example_run.step); |
