-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
78 lines (66 loc) · 1.97 KB
/
build.zig
File metadata and controls
78 lines (66 loc) · 1.97 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
67
68
69
70
71
72
73
74
75
76
77
78
const std = @import("std");
pub fn linkPCRE(
exe_compile: *std.Build.Step.Compile,
jstring_dep: *std.Build.Dependency,
) void {
exe_compile.addCSourceFile(.{
.file = .{
.path = jstring_dep.builder.pathFromRoot(
jstring_dep.module("pcre_binding.c").root_source_file.?.path,
),
},
.flags = &.{"-std=c17"},
});
exe_compile.linkSystemLibrary2(
"libpcre2-8",
.{ .use_pkg_config = .yes },
);
}
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule(
"jstring",
.{
.root_source_file = .{ .path = "src/jstring.zig" },
},
);
_ = b.addModule(
"pcre_binding.c",
.{
.root_source_file = .{
.path = b.pathFromRoot("src/pcre/pcre_binding.c"),
},
},
);
const obj_pcre_binding = b.addObject(.{
.name = "pcre_binding",
.target = target,
.optimize = optimize,
});
obj_pcre_binding.linkLibC();
obj_pcre_binding.addCSourceFile(
.{
.file = .{ .path = "src/pcre/pcre_binding.c" },
.flags = &.{"-std=c17"},
},
);
const pcre_binding_lib = b.addStaticLibrary(.{
.name = "pcre_binding",
.target = target,
.optimize = optimize,
});
pcre_binding_lib.addObject(obj_pcre_binding);
pcre_binding_lib.linkLibC();
pcre_binding_lib.linkSystemLibrary2("libpcre2-8", .{ .use_pkg_config = .yes });
b.installArtifact(pcre_binding_lib);
const jstring_lib = b.addStaticLibrary(.{
.name = "jstring",
.root_source_file = .{ .path = "src/jstring.zig" },
.target = target,
.optimize = optimize,
});
jstring_lib.addObject(obj_pcre_binding);
jstring_lib.linkSystemLibrary2("libpcre2-8", .{ .use_pkg_config = .yes });
b.installArtifact(jstring_lib);
}