Skip to content

Commit 09c2d6b

Browse files
committed
Fixes build with use zig module set to false
1 parent 5f02774 commit 09c2d6b

File tree

7 files changed

+20
-13
lines changed

7 files changed

+20
-13
lines changed

build.zig

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn build(b: *std.Build) void {
3232
.name = "pipewire-0.3",
3333
.linkage = .static,
3434
.root_module = b.createModule(.{
35-
.root_source_file = b.path("src/lib/wrap/root.zig"),
35+
.root_source_file = b.path("src/wrap/root.zig"),
3636
.target = target,
3737
.optimize = optimize,
3838
.link_libc = true,
@@ -105,7 +105,6 @@ pub fn build(b: *std.Build) void {
105105
const install_conf = b.addUpdateSourceFiles();
106106
install_conf.addCopyFileToSource(client_conf, b.pathJoin(&.{
107107
"src",
108-
"lib",
109108
"wrap",
110109
"client.conf",
111110
}));
@@ -297,13 +296,15 @@ pub fn build(b: *std.Build) void {
297296

298297
// Create the zig module. Using this rather than the static library allows for easier
299298
// integration, and ties logging to the standard library logger.
300-
const pipewire_zig = b.addModule("pipewire", .{
299+
const libpipewire_zig = b.addModule("pipewire", .{
301300
.root_source_file = b.path("src/lib/root.zig"),
302301
.target = target,
303302
.optimize = optimize,
304-
.imports = &.{.{ .name = "c", .module = c }},
303+
.imports = &.{
304+
.{ .name = "c", .module = c },
305+
.{ .name = "wrap", .module = libpipewire.root_module },
306+
},
305307
});
306-
pipewire_zig.linkLibrary(libpipewire);
307308

308309
// Build the video play example.
309310
{
@@ -322,7 +323,7 @@ pub fn build(b: *std.Build) void {
322323
});
323324

324325
if (use_zig_module) {
325-
video_play.root_module.addImport("pipewire", pipewire_zig);
326+
video_play.root_module.addImport("pipewire", libpipewire_zig);
326327
} else {
327328
video_play.linkLibrary(libpipewire);
328329
video_play.root_module.addImport("pipewire", c);

src/lib/root.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const std = @import("std");
44
pub const c = @import("c");
55

66
/// The wrapped standard calls that make it possible to link pipewire statically.
7-
pub const wrap = @import("wrap/root.zig");
7+
pub const wrap = @import("wrap");
88

99
comptime {
10-
// Force the compiler to reference all declarations in `wrap` since they contain externs.
11-
for (std.meta.declarations(wrap)) |decl| {
12-
_ = &@field(wrap, decl.name);
10+
// Reference all decls since they include exports.
11+
for (std.meta.declarations(@This())) |decl| {
12+
_ = &@field(@This(), decl.name);
1313
}
1414
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lib/wrap/fs.zig renamed to src/wrap/fs.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
//! Pipewire loads some config at runtime. This file stubs out the access to that config, thereby
2-
//! removing the requirement to ship config files alongside your executable or have a dependence on
1+
//! Pipewire checks for the presence of dynamic libraries and loads some config at runtime. This
2+
//! file stubs out the relevant file system accesses so the dynamic libraries don't need to be
3+
//! present, and the config files don't need to be shipped with the executable.
34
//! user installed config files.
45

56
const std = @import("std");

src/lib/wrap/root.zig renamed to src/wrap/root.zig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ const assert = std.debug.assert;
66
pub const dlfcn = @import("dlfcn.zig");
77
pub const fs = @import("fs.zig");
88

9-
// Check type assumptions.
109
comptime {
10+
// Check type assumptions.
1111
assert(@sizeOf(c_char) == @sizeOf(u8));
12+
13+
// Reference all decls since they include exports.
14+
for (std.meta.declarations(@This())) |decl| {
15+
_ = &@field(@This(), decl.name);
16+
}
1217
}

0 commit comments

Comments
 (0)