-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
108 lines (99 loc) · 3.22 KB
/
build.zig
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const std = @import("std");
const EXAMPLES = [_][]const u8{
"arc",
"arc_negative",
"bezier",
"cairoscript",
"clip",
"clip_image",
"compositing",
"curve_rectangle",
"curve_to",
"dash",
"ellipse",
"fill_and_stroke2",
"fill_style",
"glyphs",
"glyphs_path",
"gradient",
"grid",
"group",
"image",
"image_pattern",
"mask",
"multi_segment_caps",
"pango_simple",
"pango_shape",
"pango_twisted",
"pythagoras_tree",
"rounded_rectangle",
"save_and_restore",
"set_line_cap",
"set_line_join",
"sierpinski",
"singular",
"spiral",
"spirograph",
"surface_image",
"surface_pdf",
"surface_svg",
// "surface_xcb",
"text",
"text_align_center",
"text_extents",
"three_phases",
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const opts = b.addOptions();
opts.addOption(bool, "no-pango", b.option(bool, "no-pango", "disable pango support") orelse false);
var opts_module = opts.createModule();
var safety_module = b.addModule("safety", .{ .source_file = .{ .path = "src/safety.zig" } });
var cairo_module = b.addModule("cairo", .{
.source_file = .{ .path = "src/cairo.zig" },
.dependencies = &.{
.{ .name = "build_options", .module = opts_module },
.{ .name = "safety", .module = safety_module },
},
});
var pango_module = b.addModule("pango", .{
.source_file = .{ .path = "src/pango.zig" },
.dependencies = &.{
.{ .name = "build_options", .module = opts_module },
.{ .name = "cairo", .module = cairo_module },
.{ .name = "safety", .module = safety_module },
},
});
var pangocairo_module = b.addModule("pangocairo", .{
.source_file = .{ .path = "src/pangocairo.zig" },
.dependencies = &.{
.{ .name = "build_options", .module = opts_module },
.{ .name = "cairo", .module = cairo_module },
.{ .name = "pango", .module = pango_module },
.{ .name = "safety", .module = safety_module },
},
});
cairo_module.dependencies.put("pangocairo", pangocairo_module) catch @panic("OOM");
pango_module.dependencies.put("pangocairo", pangocairo_module) catch @panic("OOM");
const examples_step = b.step("examples", "Run all examples");
inline for (EXAMPLES) |name| {
const example = b.addExecutable(.{
.name = name,
.root_source_file = .{ .path = "examples" ++ std.fs.path.sep_str ++ name ++ ".zig" },
.target = target,
.optimize = optimize,
.link_libc = true,
});
example.addModule("cairo", cairo_module);
example.linkSystemLibrary("cairo");
const run_cmd = b.addRunArtifact(example);
run_cmd.step.dependOn(b.getInstallStep());
const desc = "Run the " ++ name ++ " example";
const run_step = b.step(name, desc);
run_step.dependOn(&run_cmd.step);
example.addModule("pango", pango_module);
example.linkSystemLibrary("pangocairo");
examples_step.dependOn(&run_cmd.step);
}
}