Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
66 lines (59 loc) · 2.34 KB
/
Copy pathbuild.zig
File metadata and controls
66 lines (59 loc) · 2.34 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
60
61
62
63
64
65
66
const std = @import("std");
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardOptimizeOption(.{});
const strip = b.option(bool, "strip", "Omit debug symbols") orelse false;
// const emit_h = b.option(bool, "emit-h", "Generate a C header file (.h)") orelse false;
const filter = b.option([]const u8, "test-filter", "Skip tests that do not match filter");
const name = "plotille";
const entry = b.path("src/main.zig");
const version = try std.SemanticVersion.parse("0.1.0");
const module = b.addModule(name, .{
.root_source_file = entry,
.target = target,
.optimize = mode,
.strip = strip,
});
// Build static library by default
const c_entry = b.path("src/c-api.zig");
const c_module = b.addModule("plotille-c", .{
.root_source_file = c_entry,
.target = target,
.optimize = mode,
.strip = strip,
.link_libc = true,
});
const static_lib = b.addLibrary(.{
.name = name,
.root_module = c_module,
.version = version,
.linkage = .static,
});
const installed_static_lib = b.addInstallArtifact(static_lib, .{});
b.getInstallStep().dependOn(&installed_static_lib.step);
// Build dynamic library by default (unless static-only is requested)
const shared_lib = b.addLibrary(.{
.name = name,
.root_module = c_module,
.version = version,
.linkage = .dynamic,
});
const installed_shared_lib = b.addInstallArtifact(shared_lib, .{});
b.getInstallStep().dependOn(&installed_shared_lib.step);
const test_step = b.step("test", "Run library tests");
const tests = b.addTest(.{
.name = name,
.root_module = module,
});
if (filter) |f| {
tests.filters = &.{f};
}
const run_tests = b.addRunArtifact(tests);
test_step.dependOn(&run_tests.step);
}