zcatpdf/build.zig
reugenio 3826cbaed4 Release v1.0 - Feature Complete PDF Generation Library
Major features added since v0.5:
- PNG support with alpha/transparency (soft masks)
- FlateDecode compression via libdeflate-zig
- Bookmarks/Outline for document navigation
- Bezier curves, circles, ellipses, arcs
- Transformations (rotate, scale, translate, skew)
- Transparency/opacity (fill and stroke alpha)
- Linear and radial gradients (Shading Patterns)
- Code128 (1D) and QR Code (2D) barcodes
- TrueType font parsing (metrics, glyph widths)
- RC4 encryption module (40/128-bit)
- AcroForms module (TextField, CheckBox)
- SVG import (basic shapes and paths)
- Template system (reusable layouts)
- Markdown styling (bold, italic, links, headings, lists)

Documentation:
- README.md: Complete API reference with code examples
- FUTURE_IMPROVEMENTS.md: Detailed roadmap for future development
- CLAUDE.md: Updated to v1.0 release status

Stats:
- 125+ unit tests passing
- 16 demo examples
- 46 source files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 02:01:17 +01:00

75 lines
4 KiB
Zig

const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Get libdeflate dependency
const libdeflate_dep = b.dependency("libdeflate", .{
.target = target,
.optimize = optimize,
});
const libdeflate_lib = libdeflate_dep.artifact("deflate");
// zpdf module with libdeflate
const zpdf_mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
zpdf_mod.linkLibrary(libdeflate_lib);
// Tests
const unit_tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
}),
});
unit_tests.root_module.linkLibrary(libdeflate_lib);
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_unit_tests.step);
// Example executables
const examples = [_]struct { name: []const u8, path: []const u8, step_name: []const u8, desc: []const u8 }{
.{ .name = "hello", .path = "examples/hello.zig", .step_name = "hello", .desc = "Run hello example" },
.{ .name = "invoice", .path = "examples/invoice.zig", .step_name = "invoice", .desc = "Run invoice example" },
.{ .name = "text_demo", .path = "examples/text_demo.zig", .step_name = "text_demo", .desc = "Run text demo example" },
.{ .name = "image_demo", .path = "examples/image_demo.zig", .step_name = "image_demo", .desc = "Run image demo example" },
.{ .name = "table_demo", .path = "examples/table_demo.zig", .step_name = "table_demo", .desc = "Run table demo example" },
.{ .name = "pagination_demo", .path = "examples/pagination_demo.zig", .step_name = "pagination_demo", .desc = "Run pagination demo example" },
.{ .name = "links_demo", .path = "examples/links_demo.zig", .step_name = "links_demo", .desc = "Run links demo example" },
.{ .name = "bookmarks_demo", .path = "examples/bookmarks_demo.zig", .step_name = "bookmarks_demo", .desc = "Run bookmarks demo example" },
.{ .name = "curves_demo", .path = "examples/curves_demo.zig", .step_name = "curves_demo", .desc = "Run curves demo example" },
.{ .name = "transforms_demo", .path = "examples/transforms_demo.zig", .step_name = "transforms_demo", .desc = "Run transforms demo example" },
.{ .name = "transparency_demo", .path = "examples/transparency_demo.zig", .step_name = "transparency_demo", .desc = "Run transparency demo example" },
.{ .name = "gradient_demo", .path = "examples/gradient_demo.zig", .step_name = "gradient_demo", .desc = "Run gradient demo example" },
.{ .name = "barcode_demo", .path = "examples/barcode_demo.zig", .step_name = "barcode_demo", .desc = "Run barcode demo example" },
.{ .name = "ttf_demo", .path = "examples/ttf_demo.zig", .step_name = "ttf_demo", .desc = "Run TTF font demo example" },
.{ .name = "template_demo", .path = "examples/template_demo.zig", .step_name = "template_demo", .desc = "Run template demo example" },
.{ .name = "markdown_demo", .path = "examples/markdown_demo.zig", .step_name = "markdown_demo", .desc = "Run markdown demo example" },
};
inline for (examples) |example| {
const exe = b.addExecutable(.{
.name = example.name,
.root_module = b.createModule(.{
.root_source_file = b.path(example.path),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "zpdf", .module = zpdf_mod },
},
}),
});
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step(example.step_name, example.desc);
run_step.dependOn(&run_cmd.step);
}
}