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-01-15 16:54:51 -08:00
|
|
|
.root_source_file = .{ .path = "src/cmark.zig" },
|
2023-09-03 20:41:02 -07:00
|
|
|
});
|
2024-01-15 16:54:51 -08:00
|
|
|
cmark.addIncludePath(.{ .path = b.getInstallPath(.header, "") });
|
2023-09-03 20:41:02 -07:00
|
|
|
|
|
|
|
const cmark_c = cmark_build.cmark_lib(b, .{
|
2023-09-09 23:45:22 -07:00
|
|
|
.name = "cmark-c",
|
2023-09-03 20:41:02 -07:00
|
|
|
.target = target,
|
|
|
|
.optimize = optimize,
|
|
|
|
});
|
|
|
|
|
2023-09-09 23:45:22 -07:00
|
|
|
add_examples(b, .{
|
|
|
|
.target = target,
|
|
|
|
.cmark_module = cmark,
|
|
|
|
.cmark_c = cmark_c,
|
2023-09-03 20:41:02 -07:00
|
|
|
});
|
2023-09-09 23:45:22 -07:00
|
|
|
}
|
2023-09-03 20:41:02 -07:00
|
|
|
|
2023-09-09 23:45:22 -07:00
|
|
|
const ExampleOptions = struct {
|
2024-01-15 16:54:51 -08:00
|
|
|
target: std.Build.ResolvedTarget,
|
2023-09-09 23:45:22 -07:00
|
|
|
cmark_module: *std.Build.Module,
|
|
|
|
cmark_c: *std.Build.Step.Compile,
|
|
|
|
};
|
|
|
|
|
|
|
|
const Example = struct {
|
|
|
|
name: []const u8,
|
|
|
|
file: []const u8,
|
|
|
|
};
|
|
|
|
|
|
|
|
const examples = [_]Example{
|
|
|
|
.{ .name = "render_html", .file = "examples/render_html.zig" },
|
|
|
|
};
|
|
|
|
|
2024-01-15 16:54:51 -08:00
|
|
|
pub fn add_examples(b: *std.Build, options: ExampleOptions) void {
|
2023-09-09 23:45:22 -07:00
|
|
|
const example_step = b.step("examples", "build examples");
|
|
|
|
|
|
|
|
inline for (examples) |example| {
|
|
|
|
const ex_exe = b.addExecutable(.{
|
|
|
|
.name = example.name,
|
|
|
|
.root_source_file = .{ .path = example.file },
|
|
|
|
.target = options.target,
|
|
|
|
.optimize = .Debug,
|
|
|
|
});
|
|
|
|
|
2024-01-15 16:54:51 -08:00
|
|
|
ex_exe.root_module.addImport("cmark", options.cmark_module);
|
2023-09-09 23:45:22 -07:00
|
|
|
ex_exe.linkLibrary(options.cmark_c);
|
|
|
|
|
|
|
|
const install = b.addInstallArtifact(ex_exe, .{});
|
|
|
|
example_step.dependOn(&install.step);
|
|
|
|
}
|
2023-09-03 20:41:02 -07:00
|
|
|
}
|