-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.zig
58 lines (51 loc) · 2.01 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
const std = @import("std");
const Build = std.Build;
const Mode = std.builtin.Mode;
pub fn build(b: *Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const xml = b.addModule("xml", .{
.root_source_file = b.path("src/xml.zig"),
.target = target,
.optimize = optimize,
});
const test_step = b.step("test", "Run the tests");
const xml_test = b.addTest(.{
.root_source_file = b.path("src/xml.zig"),
.target = target,
});
const xml_test_run = b.addRunArtifact(xml_test);
test_step.dependOn(&xml_test_run.step);
const docs_step = b.step("docs", "Build the documentation");
const xml_docs = b.addObject(.{
.name = "xml",
.root_source_file = b.path("src/xml.zig"),
.target = target,
.optimize = .Debug,
});
const xml_docs_copy = b.addInstallDirectory(.{
.source_dir = xml_docs.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
docs_step.dependOn(&xml_docs_copy.step);
const install_examples_step = b.step("install-examples", "Build and install the example programs");
const example_reader_exe = b.addExecutable(.{
.name = "reader",
.root_source_file = b.path("examples/reader.zig"),
.target = target,
.optimize = optimize,
});
example_reader_exe.root_module.addImport("xml", xml);
const example_reader_install = b.addInstallArtifact(example_reader_exe, .{});
install_examples_step.dependOn(&example_reader_install.step);
const example_canonicalize_exe = b.addExecutable(.{
.name = "canonicalize",
.root_source_file = b.path("examples/canonicalize.zig"),
.target = target,
.optimize = optimize,
});
example_canonicalize_exe.root_module.addImport("xml", xml);
const example_canonicalize_install = b.addInstallArtifact(example_canonicalize_exe, .{});
install_examples_step.dependOn(&example_canonicalize_install.step);
}