-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.zig
48 lines (41 loc) · 1.59 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const capstone = b.dependency("capstone", .{
.target = target,
.optimize = optimize,
});
const compiled_capstone = capstone.artifact("capstone");
compiled_capstone.getEmittedIncludeTree().addStepDependencies(&compiled_capstone.step);
const capstone_c = b.addTranslateC(.{
.root_source_file = compiled_capstone.getEmittedIncludeTree().path(b, "capstone/capstone.h"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const mod = b.addModule("capstone-bindings-zig", .{
.root_source_file = b.path("capstone.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{
.name = "capstone-c",
.module = capstone_c.createModule(),
},
},
});
mod.addLibraryPath(compiled_capstone.getEmittedBin().dirname());
mod.linkLibrary(capstone.artifact("capstone"));
mod.addIncludePath(compiled_capstone.getEmittedIncludeTree());
const mod_test = b.addTest(.{
.root_source_file = mod.root_source_file.?,
.target = target,
.optimize = optimize,
});
mod_test.step.dependOn(&compiled_capstone.step);
mod_test.root_module.addImport("capstone-c", capstone_c.createModule());
const run_lib_tests = b.addRunArtifact(mod_test);
const test_step = b.step("test", "Run the library tests");
test_step.dependOn(&run_lib_tests.step);
}