summaryrefslogtreecommitdiff
path: root/build/addons.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build/addons.zig')
-rw-r--r--build/addons.zig31
1 files changed, 6 insertions, 25 deletions
diff --git a/build/addons.zig b/build/addons.zig
index d22abc7a..a3a23825 100644
--- a/build/addons.zig
+++ b/build/addons.zig
@@ -30,6 +30,9 @@ pub fn gpu(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.lang.O
pub const Pdf = struct {
lib: ?*std.Build.Step.Compile,
+ /// The same module, for a core with the addons compiled in, which
+ /// exports nothing there (addon.exportLib).
+ module: ?*std.Build.Module,
/// What a step that needs the addon depends on when it is not built.
no_pdf: ?*std.Build.Step,
};
@@ -43,21 +46,19 @@ pub const Pdf = struct {
/// `pardes_addon` alone.
pub fn pdf(b: *std.Build, c: struct {
addon_mod: *std.Build.Module,
- builtin_mods: []const *std.Build.Module,
c_optimize: std.lang.Optimize,
- core_module: *std.Build.Module,
enable_jpx: bool,
freetype: ?*std.Build.Step.Compile,
freetype_dep: ?*std.Build.Dependency,
io: std.Io,
mupdf_check: *std.Build.Step,
mupdf_dep: ?*std.Build.Dependency,
- optimize: std.lang.Optimize,
pdf_pointer_bench_step: *std.Build.Step,
pdf_scroll_bench_step: *std.Build.Step,
target: std.Build.ResolvedTarget,
}) Pdf {
var pdf_addon: ?*std.Build.Step.Compile = null;
+ var pdf_module: ?*std.Build.Module = null;
if (c.mupdf_dep) |md| if (c.freetype_dep) |fd| {
// ...and one zlib, the one FreeType links for its gzip module. Asked
// of FreeType's build with the options it asks with, the dependency
@@ -83,36 +84,16 @@ pub fn pdf(b: *std.Build, c: struct {
const lib = b.addLibrary(.{ .name = "pdf", .linkage = .dynamic, .root_module = pdf_mod });
lib.setVersionScript(b.addWriteFiles().add("pdf.map", "{ global: pardes_addon; local: *; };\n"));
pdf_addon = lib;
- // ...and the same module compiled into a pardes, which exports
- // nothing there (addon.exportLib).
- for (c.builtin_mods) |m| m.addImport("pdf_addon", pdf_mod);
+ pdf_module = pdf_mod;
c.mupdf_check.dependOn(mupdf_build.addProbe(b, mupdf, .{
.target = c.target,
.pdf = b.path("docs/design.pdf"),
}));
-
- // The PDF benches: the core over the addon, a pane of it.
- const config = b.addOptions();
- config.addOption(bool, "release_fast_core", c.optimize == .fast);
- config.addOption([]const u8, "core_optimize", @tagName(c.optimize));
- config.addOptionPath("pdf_addon", lib.getEmittedBin());
- for ([_]struct { step: *std.Build.Step, exe: []const u8, file: []const u8, optimize: std.lang.Optimize }{
- .{ .step = c.pdf_pointer_bench_step, .exe = "pardes-pdf-pointer-bench", .file = "test/pdf_pointer_bench.zig", .optimize = .fast },
- .{ .step = c.pdf_scroll_bench_step, .exe = "pardes-pdf-scroll-bench", .file = "test/pdf_scroll_bench.zig", .optimize = c.optimize },
- }) |bench| {
- const exe = b.addExecutable(.{ .name = bench.exe, .root_module = b.createModule(.{ .target = c.target, .optimize = bench.optimize, .root_source_file = b.path(bench.file), .link_libc = true }) });
- exe.root_module.addImport("pardes", c.core_module);
- exe.root_module.addOptions("pdf_bench_config", config);
- const run = b.addRunArtifact(exe);
- run.addPassthruArgs();
- run.setCwd(b.path("."));
- bench.step.dependOn(&run.step);
- }
};
// Without it, what needs it says how to have it.
const no_pdf: ?*std.Build.Step = if (pdf_addon == null) &b.addFail("this step needs the pdf addon, over MuPDF: add -Dpdf (it is fetched once, and on from then)").step else null;
if (no_pdf) |s| for ([_]*std.Build.Step{ c.mupdf_check, c.pdf_pointer_bench_step, c.pdf_scroll_bench_step }) |step| step.dependOn(s);
- return .{ .lib = pdf_addon, .no_pdf = no_pdf };
+ return .{ .lib = pdf_addon, .module = pdf_module, .no_pdf = no_pdf };
}
/// The image addon (addons/image/image.zig over stb_image, stb.c),