-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
44 lines (37 loc) · 1.14 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "hello",
.root_source_file = b.path("src/hello.zig"),
.target = target,
.optimize = optimize,
});
// build a c++ lib with c binding
const xlib = b.addStaticLibrary(.{
.name = "xlib",
.target = target,
.optimize = optimize,
.version = .{ .major = 0, .minor = 1, .patch = 0 },
});
xlib.linkLibC();
xlib.linkLibCpp();
xlib.addIncludePath(b.path("vendor/xlib"));
xlib.addCSourceFiles(.{
.root = b.path("vendor/xlib"),
.files = &.{
"binding.cpp",
"hello.cpp",
},
.flags = &.{"-DNDEBUG=1"},
});
xlib.installHeader(b.path("vendor/xlib/binding.h"), "xlib/binding.h");
b.installArtifact(xlib);
exe.linkLibrary(xlib);
// ---
b.installArtifact(exe);
const run_exe = b.addRunArtifact(exe);
const run_step = b.step("run", "Run the application");
run_step.dependOn(&run_exe.step);
}