From 5d8a49305709661fc03bf3329ee3b3801d8b35c5 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 29 Apr 2026 13:33:52 +0200 Subject: [PATCH] build: switch to translate-c package We require a recent version for FreeBSD compatibility References: https://codeberg.org/ziglang/translate-c/pulls/331 --- build.zig | 11 +++++++++++ build.zig.zon | 4 ++++ river/Cursor.zig | 2 +- river/InputConfig.zig | 2 +- river/InputDevice.zig | 2 +- river/Server.zig | 2 +- river/c.h | 3 +++ river/c.zig | 22 ---------------------- river/command/map.zig | 2 +- 9 files changed, 23 insertions(+), 27 deletions(-) create mode 100644 river/c.h delete mode 100644 river/c.zig diff --git a/build.zig b/build.zig index 0ba03fb..91647fd 100644 --- a/build.zig +++ b/build.zig @@ -8,6 +8,7 @@ const manifest = @import("build.zig.zon"); const version = manifest.version; const Scanner = @import("wayland").Scanner; +const Translator = @import("translate_c").Translator; pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); @@ -157,6 +158,15 @@ pub fn build(b: *Build) !void { const flags = b.createModule(.{ .root_source_file = b.path("common/flags.zig") }); const globber = b.createModule(.{ .root_source_file = b.path("common/globber.zig") }); + const translate_c: Translator = .init(b.dependency("translate_c", .{}), .{ + .name = "c", + .c_source_file = b.path("river/c.h"), + .target = target, + .optimize = optimize, + }); + translate_c.linkSystemLibrary("libevdev", .{}); + translate_c.linkSystemLibrary("libinput", .{}); + { const river = b.addExecutable(.{ .name = "river", @@ -185,6 +195,7 @@ pub fn build(b: *Build) !void { river.root_module.addImport("wlroots", wlroots); river.root_module.addImport("flags", flags); river.root_module.addImport("globber", globber); + river.root_module.addImport("c", translate_c.mod); river.root_module.addCSourceFile(.{ .file = b.path("river/wlroots_log_wrapper.c"), diff --git a/build.zig.zon b/build.zig.zon index 6c5f5ec..d6f5661 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -24,6 +24,10 @@ .url = "https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.3.0.tar.gz", .hash = "xkbcommon-0.3.0-VDqIe3K9AQB2fG5ZeRcMC9i7kfrp5m2rWgLrmdNn9azr", }, + .translate_c = .{ + .url = "git+https://codeberg.org/ziglang/translate-c/#7a1a9fdc4ab00835748a6657ecbb835e3d5d45f7", + .hash = "translate_c-0.0.0-Q_BUWvP1BgCjAk6PWv5286tOlvzD9-X-NkuTzh0KxY0Q", + }, }, .fingerprint = 0x3dae7aba2ea52a3b, } diff --git a/river/Cursor.zig b/river/Cursor.zig index feb19d2..795d5e6 100644 --- a/river/Cursor.zig +++ b/river/Cursor.zig @@ -26,7 +26,7 @@ const wayland = @import("wayland"); const wl = wayland.server.wl; const zwlr = wayland.server.zwlr; -const c = @import("c.zig").c; +const c = @import("c"); const server = &@import("main.zig").server; const util = @import("util.zig"); diff --git a/river/InputConfig.zig b/river/InputConfig.zig index 8557a26..81d95bb 100644 --- a/river/InputConfig.zig +++ b/river/InputConfig.zig @@ -25,7 +25,7 @@ const wlr = @import("wlroots"); const log = std.log.scoped(.input_config); -const c = @import("c.zig").c; +const c = @import("c"); const server = &@import("main.zig").server; const util = @import("util.zig"); diff --git a/river/InputDevice.zig b/river/InputDevice.zig index df26266..ffd8a66 100644 --- a/river/InputDevice.zig +++ b/river/InputDevice.zig @@ -24,7 +24,7 @@ const wl = @import("wayland").server.wl; const globber = @import("globber"); -const c = @import("c.zig").c; +const c = @import("c"); const server = &@import("main.zig").server; const util = @import("util.zig"); diff --git a/river/Server.zig b/river/Server.zig index dc277c5..c7b4643 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -26,7 +26,7 @@ const wayland = @import("wayland"); const wl = wayland.server.wl; const wp = wayland.server.wp; -const c = @import("c.zig").c; +const c = @import("c"); const util = @import("util.zig"); const Config = @import("Config.zig"); diff --git a/river/c.h b/river/c.h new file mode 100644 index 0000000..efef65c --- /dev/null +++ b/river/c.h @@ -0,0 +1,3 @@ +#include +#include +#include diff --git a/river/c.zig b/river/c.zig deleted file mode 100644 index 9ef5b97..0000000 --- a/river/c.zig +++ /dev/null @@ -1,22 +0,0 @@ -// This file is part of river, a dynamic tiling wayland compositor. -// -// Copyright 2020 The River Developers -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pub const c = @cImport({ - @cInclude("linux/input-event-codes.h"); - @cInclude("libevdev/libevdev.h"); - - @cInclude("libinput.h"); -}); diff --git a/river/command/map.zig b/river/command/map.zig index cd966f4..c0d34c1 100644 --- a/river/command/map.zig +++ b/river/command/map.zig @@ -22,7 +22,7 @@ const wlr = @import("wlroots"); const xkb = @import("xkbcommon"); const flags = @import("flags"); -const c = @import("../c.zig").c; +const c = @import("c"); const server = &@import("../main.zig").server; const util = @import("../util.zig");