-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
59 lines (46 loc) · 1.52 KB
/
build.zig
File metadata and controls
59 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// 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", .{
.root_source_file = b.path("src/cmark.zig"),
});
const cmark_c = cmark_build.cmark_lib(b, .{
.name = "cmark-c",
.target = target,
.optimize = optimize,
});
cmark.linkLibrary(cmark_c);
add_examples(b, .{
.target = target,
.cmark_module = cmark,
});
}
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,
.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);
}
}