cmark-zig/build.zig

60 lines
1.5 KiB
Zig
Raw Permalink Normal View History

2023-09-03 20:41:02 -07:00
// This file is licensed under the CC0 1.0 license.
// See: https://creativecommons.org/publicdomain/zero/1.0/legalcode
const std = @import("std");
const cmark_build = @import("./cmark.build.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const cmark = b.addModule("cmark", .{
2024-06-18 18:20:49 -07:00
.root_source_file = b.path("src/cmark.zig"),
2023-09-03 20:41:02 -07:00
});
const cmark_c = cmark_build.cmark_lib(b, .{
.name = "cmark-c",
2023-09-03 20:41:02 -07:00
.target = target,
.optimize = optimize,
});
2024-06-18 18:20:49 -07:00
cmark.linkLibrary(cmark_c);
add_examples(b, .{
.target = target,
.cmark_module = cmark,
2023-09-03 20:41:02 -07:00
});
}
2023-09-03 20:41:02 -07:00
const ExampleOptions = struct {
target: std.Build.ResolvedTarget,
cmark_module: *std.Build.Module,
};
const Example = struct {
name: []const u8,
file: []const u8,
};
const examples = [_]Example{
.{ .name = "render_html", .file = "examples/render_html.zig" },
};
pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
const example_step = b.step("examples", "build examples");
inline for (examples) |example| {
const ex_exe = b.addExecutable(.{
.name = example.name,
2024-06-18 18:20:49 -07:00
.root_source_file = b.path(example.file),
.target = options.target,
.optimize = .Debug,
});
ex_exe.root_module.addImport("cmark", options.cmark_module);
const install = b.addInstallArtifact(ex_exe, .{});
example_step.dependOn(&install.step);
}
2023-09-03 20:41:02 -07:00
}