-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.zig
69 lines (57 loc) · 1.8 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
_ = b.addModule("ini", .{
.root_source_file = b.path("src/ini.zig"),
});
const lib = b.addStaticLibrary(.{
.name = "ini",
.root_source_file = b.path("src/lib.zig"),
.target = target,
.optimize = optimize,
});
lib.bundle_compiler_rt = true;
lib.addIncludePath(b.path("src"));
lib.linkLibC();
b.installArtifact(lib);
const example_c = b.addExecutable(.{
.name = "example-c",
.optimize = optimize,
.target = target,
});
example_c.addCSourceFile(.{
.file = b.path("example/example.c"),
.flags = &.{
"-Wall",
"-Wextra",
"-pedantic",
},
});
example_c.addIncludePath(b.path("src"));
example_c.linkLibrary(lib);
example_c.linkLibC();
b.installArtifact(example_c);
const example_zig = b.addExecutable(.{
.name = "example-zig",
.root_source_file = b.path("example/example.zig"),
.optimize = optimize,
.target = target,
});
example_zig.root_module.addImport("ini", b.modules.get("ini").?);
b.installArtifact(example_zig);
var main_tests = b.addTest(.{
.root_source_file = b.path("src/test.zig"),
.optimize = optimize,
});
var binding_tests = b.addTest(.{
.root_source_file = b.path("src/lib-test.zig"),
.optimize = optimize,
});
binding_tests.addIncludePath(b.path("src"));
binding_tests.linkLibrary(lib);
binding_tests.linkLibC();
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
test_step.dependOn(&binding_tests.step);
}