replace libxkbcommon system library with build.zig.zon dependency

dev
LeRoyce Pearson 2024-02-21 12:22:59 -07:00
parent 025ab53055
commit 3043d5c175
4 changed files with 52 additions and 5 deletions

View File

@ -4,12 +4,21 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const libxkbcommon = b.dependency("libxkbcommon", .{
.target = target,
.optimize = optimize,
});
const xkbcommon_module = b.createModule(.{
.root_source_file = .{ .path = "deps/zig-xkbcommon/src/xkbcommon.zig" },
});
xkbcommon_module.linkLibrary(libxkbcommon.artifact("xkbcommon"));
const module = b.addModule("wayland", .{
.root_source_file = .{ .path = "src/main.zig" },
.imports = &.{
.{ .name = "xkbcommon", .module = xkbcommon_module },
},
});
const lib = b.addStaticLibrary(.{
@ -48,16 +57,15 @@ pub fn build(b: *std.Build) void {
client_connect_exe.root_module.addImport("wayland", module);
b.installArtifact(client_connect_exe);
// Text Editor example
const text_editor_exe = b.addExecutable(.{
.name = "02_text_editor",
.root_source_file = .{ .path = "examples/02_text_editor.zig" },
.name = "10_text_editor",
.root_source_file = .{ .path = "examples/10_text_editor.zig" },
.target = target,
.optimize = optimize,
});
text_editor_exe.root_module.addImport("wayland", module);
text_editor_exe.root_module.addImport("xkbcommon", xkbcommon_module);
text_editor_exe.linkLibC();
text_editor_exe.linkSystemLibrary("xkbcommon");
text_editor_exe.addIncludePath(.{ .path = "deps/font8x8/" });
b.installArtifact(text_editor_exe);
}

36
build.zig.zon Normal file
View File

@ -0,0 +1,36 @@
.{
.name = "zig-wayland-wire",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.version = "0.0.0",
// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
//.minimum_zig_version = "0.11.0",
// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
// Once all dependencies are fetched, `zig build` no longer requires
// internet connectivity.
.dependencies = .{
.libxkbcommon = .{
.url = "https://git.samsehu.perli.casa/StreetLight/libxkbcommon/archive/d6a9539e0ca8676ae2e8e379a68671c79cc4fd47.tar.gz",
.hash = "1220c133a5f7de0ba8c7cb59258cbdc611f51097c43b9240a092ee078e3e3ea09f45",
},
},
.paths = .{
// This makes *all* files, recursively, included in this package. It is generally
// better to explicitly list the files and directories instead, to insure that
// fetching from tarballs, file system paths, and version control all result
// in the same contents hash.
"",
// For example...
//"build.zig",
//"build.zig.zon",
//"src",
//"LICENSE",
//"README.md",
},
}

View File

@ -1,6 +1,6 @@
const std = @import("std");
const wayland = @import("wayland");
const xkbcommon = @import("xkbcommon");
const xkbcommon = wayland.xkbcommon;
const font8x8 = @cImport({
@cInclude("font8x8.h");
});

View File

@ -1,5 +1,8 @@
const std = @import("std");
const testing = std.testing;
pub const xkbcommon = @import("xkbcommon");
pub const core = @import("./core.zig");
pub const xdg = @import("./xdg.zig");
pub const zxdg = @import("./zxdg.zig");