Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,19 @@ pub fn build(b: *std.Build) !void {
);

// pkg-config
// FIXME: It is impossible since Zig 0.17 to obtain the
// installation prefix at the configure phase, as that
// is the responsibility of the maker.
// const pc: *Step.InstallFile = pc: {
// const file = b.addWriteFile("libxev.pc", b.fmt(
// \\prefix={s}
// \\includedir=${{prefix}}/include
// \\libdir=${{prefix}}/lib
// \\
// \\Name: libxev
// \\URL: https://github.com/mitchellh/libxev
// \\Description: High-performance, cross-platform event loop
// \\Version: 0.1.0
// \\Cflags: -I${{includedir}}
// \\Libs: -L${{libdir}} -lxev
// , .{b.install_prefix}));
// break :pc b.addInstallFileWithDir(
// file.getDirectory().path(b, "libxev.pc"),
// .prefix,
// "share/pkgconfig/libxev.pc",
// );
// };
const pc: *Step.InstallFile = pc: {
const pc_writer_exe = b.addExecutable(.{
.name = "pc_writer",
.root_module = b.createModule(.{
.root_source_file = b.path("build/write_pkgconfig.zig"),
.target = b.graph.host,
}),
});
const pc_writer_run = b.addRunArtifact(pc_writer_exe);
pc_writer_run.addDirectoryArg(.{ .relative = .{ .base = .deployed_prefix } });
const file = pc_writer_run.captureStdOut(.{});
break :pc b.addInstallFile(file, "share/pkgconfig/libxev.pc");
};

// Man pages
const man = try manPages(b);
Expand Down Expand Up @@ -141,7 +132,7 @@ pub fn build(b: *std.Build) !void {
if (static_lib) |v| b.installArtifact(v);
if (dynamic_lib) |v| b.installArtifact(v);
b.getInstallStep().dependOn(&c_header.step);
// b.getInstallStep().dependOn(&pc.step);
b.getInstallStep().dependOn(&pc.step);
b.installArtifact(test_exe);
if (emit_man) {
for (man) |step| b.getInstallStep().dependOn(step);
Expand Down
27 changes: 27 additions & 0 deletions build/write_pkgconfig.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const std = @import("std");

pub fn main(init: std.process.Init) !void {
var args_iter = try init.minimal.args.iterateAllocator(init.gpa);
defer args_iter.deinit();
if (!args_iter.skip()) @panic("Called without argv0");
const deployed_prefix = args_iter.next() orelse @panic("Did not get prefix");

var stdout_file = std.Io.File.stdout();
defer stdout_file.close(init.io);
var out_buf: [1024]u8 = undefined;
var stdout = stdout_file.writer(init.io, &out_buf);

try stdout.interface.print(
\\prefix={s}
\\includedir=${{prefix}}/include
\\libdir=${{prefix}}/lib
\\
\\Name: libxev
\\URL: https://github.com/mitchellh/libxev
\\Description: High-performance, cross-platform event loop
\\Version: 0.1.0
\\Cflags: -I${{includedir}}
\\Libs: -L${{libdir}} -lxev
, .{deployed_prefix});
try stdout.interface.flush();
}