Skip to content

Commit 465e98a

Browse files
authored
Merge pull request #1 from allyourcodebase/static
Static build
2 parents fb37c58 + deda59f commit 465e98a

File tree

14 files changed

+25239
-1018
lines changed

14 files changed

+25239
-1018
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
Pipewire client library, ported to the Zig build system.
44

5+
56
## Motivation
67

7-
I want a static executable that can play audio and turn screen contents into a video feed.
8+
I want a static executable that can play audio and turn screen contents into a video feed. The pipewire library makes heavy use of `dlopen` internally, so this is nontrivial.
89

910
## Status
1011

11-
I got the screen-play example that displays the current webcam feed compiling and running (see `zig build screen-play`.)
12-
13-
The pipewire library makes heavy use of `dlopen` internally, so further work will be needed to link statically to it.
12+
You can run the `video-play` example with `zig build video-play` to see the current webcam feed. This currently works without pipewire accessing the dynamic linker, but the example executable uses SDL so it still has access to it. I plan to port the example away from SDL so that this can be changed.

build.zig

Lines changed: 336 additions & 265 deletions
Large diffs are not rendered by default.

build.zig.zon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
.url = "git+https://github.com/allyourcodebase/SDL3#af9c32ce4824e0ad4337447434c40f2b672faf94",
2121
.hash = "sdl-0.0.0-i4QD0btgqAABajEXrQnyZr1xVsk7LM48w2nBmuQ5gdfr",
2222
},
23+
.zin = .{
24+
.url = "git+https://github.com/marler8997/zin#d3e230690f09debdb99dffe4586ad19f9dfb4716",
25+
.hash = "zin-0.0.0-W7QDx6kKAwCVg-wWMO4FdpvZMH66NJpc9wFDdxp5c8E2",
26+
},
2327
},
2428
.paths = .{
2529
"LICENSE",

src/generate_conf.zig renamed to src/build/generate_client_conf.zig

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
//! Generates the pipewire client config. We can almost use `addConfigHeader` for this with the
2+
//! `autoconf_at` style, but not quite as it adds a c style comment to the first line (explaining
3+
//! that the file is generated) which isn't allowed by this syntax.
4+
15
const std = @import("std");
26
const options = @import("options");
3-
47
const assert = std.debug.assert;
58

6-
/// Generate the pipewire config. We can almost use `addConfigHeader` for this with the
7-
/// `autoconf_at` style, but not quite as it adds a c style comment to the first line (explaining
8-
/// that the file is generated) which isn't allowed by this syntax.
99
pub fn main() !void {
1010
var gpa = std.heap.GeneralPurposeAllocator(.{ .thread_safe = false }){};
1111
defer if (gpa.deinit() != .ok) @panic("leak detected");
@@ -32,6 +32,17 @@ pub fn main() !void {
3232
var output_buf: [4096]u8 = undefined;
3333
var writer = output.writerStreaming(&output_buf);
3434

35+
// Ideally we'd just use embed file rather than emit this warning but I'm having trouble
36+
// getting `addEmbedPath` to work, so this will do for now. Not sure if this is a bug or user
37+
// error.
38+
try writer.interface.writeAll("# ");
39+
try writer.interface.splatByteAll('#', 80 - 2);
40+
try writer.interface.writeAll("\n");
41+
try writer.interface.writeAll("# Generated by Zig's build system. Do not edit.\n");
42+
try writer.interface.writeAll("# ");
43+
try writer.interface.splatByteAll('#', 80 - 2);
44+
try writer.interface.writeAll("\n\n");
45+
3546
while (true) {
3647
_ = reader.interface.streamDelimiter(&writer.interface, '@') catch |err| switch (err) {
3748
error.EndOfStream => break,

0 commit comments

Comments
 (0)