Skip to content

Commit 5f944a7

Browse files
committed
zig: lazypath
1 parent ef0a113 commit 5f944a7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

build.zig

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
const std = @import("std");
2-
const FileSource = std.Build.FileSource;
2+
const Path = std.Build.LazyPath;
33

44
pub fn build(b: *std.Build) void {
55
const target = b.standardTargetOptions(.{});
66
const optimize = b.standardOptimizeOption(.{});
7+
78
const tests = b.option(bool, "Tests", "Build tests [default: false]") orelse false;
89

910
const config = b.addConfigHeader(.{
@@ -22,16 +23,21 @@ pub fn build(b: *std.Build) void {
2223
.optimize = optimize,
2324
});
2425
lib.addConfigHeader(config);
25-
lib.addIncludePath(".");
26+
lib.addIncludePath(Path.relative("."));
2627
lib.addCSourceFiles(&.{
2728
"sigc++/connection.cc",
2829
"sigc++/functors/slot_base.cc",
2930
"sigc++/signal_base.cc",
3031
"sigc++/trackable.cc",
3132
}, cxxFlags);
33+
lib.pie = true;
34+
switch (optimize) {
35+
.Debug, .ReleaseSafe => lib.bundle_compiler_rt = true,
36+
else => lib.strip = true,
37+
}
3238
lib.linkLibCpp();
3339
lib.installHeadersDirectoryOptions(.{
34-
.source_dir = FileSource.relative("sigc++"),
40+
.source_dir = Path.relative("sigc++"),
3541
.install_dir = .header,
3642
.install_subdir = "sigc++",
3743
.exclude_extensions = &.{
@@ -110,8 +116,8 @@ fn buildTest(b: *std.Build, info: BuildInfo) void {
110116
for (info.lib.include_dirs.items) |include| {
111117
test_exe.include_dirs.append(include) catch {};
112118
}
113-
test_exe.addCSourceFile(info.path, cxxFlags);
114-
test_exe.addCSourceFile("tests/testutilities.cc", cxxFlags);
119+
test_exe.addCSourceFile(.{ .file = Path.relative(info.path), .flags = cxxFlags });
120+
test_exe.addCSourceFile(.{ .file = Path.relative("tests/testutilities.cc"), .flags = cxxFlags });
115121
test_exe.linkLibrary(info.lib);
116122
test_exe.linkLibCpp();
117123
b.installArtifact(test_exe);

0 commit comments

Comments
 (0)