diff --git a/build.zig b/build.zig index b626b37..a4b8903 100644 --- a/build.zig +++ b/build.zig @@ -15,6 +15,7 @@ pub fn build(b: *std.Build) void { const pool = b.dependency("foxwhale_pool", .{ .target = target, .optimize = optimize }); const subset_pool = b.dependency("foxwhale_subset_pool", .{ .target = target, .optimize = optimize }); const iterable_pool = b.dependency("foxwhale_iterable_pool", .{ .target = target, .optimize = optimize }); + const wayland = b.dependency("foxwhale_wayland", .{ .target = target, .optimize = optimize }); const exe = b.addExecutable(.{ .name = "foxwhale", @@ -28,6 +29,7 @@ pub fn build(b: *std.Build) void { exe.root_module.addImport("foxwhale-pool", pool.module("foxwhale-pool")); exe.root_module.addImport("foxwhale-subset-pool", subset_pool.module("foxwhale-subset-pool")); exe.root_module.addImport("foxwhale-iterable-pool", iterable_pool.module("foxwhale-iterable-pool")); + exe.root_module.addImport("foxwhale-wayland", wayland.module("foxwhale-wayland")); exe.linkSystemLibrary("c"); exe.linkSystemLibrary("gl"); @@ -68,7 +70,7 @@ pub fn build(b: *std.Build) void { const foxwhale_gen = b.dependency("foxwhale_gen", .{ .target = target, .optimize = optimize }); const foxwhale_gen_exe = foxwhale_gen.artifact("foxwhale-gen"); - const output_path = "src/wl/protocols.zig"; + const output_path = "foxwhale-wayland/src/protocols.zig"; const gen_cmd = b.addRunArtifact(foxwhale_gen_exe); gen_cmd.addArg("server"); gen_cmd.addArg("--input-file"); diff --git a/build.zig.zon b/build.zig.zon index 63d7f36..111cd3d 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -42,6 +42,7 @@ .foxwhale_pool = .{ .path = "foxwhale-pool" }, .foxwhale_subset_pool = .{ .path = "foxwhale-subset-pool" }, .foxwhale_iterable_pool = .{ .path = "foxwhale-iterable-pool" }, + .foxwhale_wayland = .{ .path = "foxwhale-wayland" }, }, // Specifies the set of files and directories that are included in this package. diff --git a/foxwhale-wayland/build.zig b/foxwhale-wayland/build.zig new file mode 100644 index 0000000..46decef --- /dev/null +++ b/foxwhale-wayland/build.zig @@ -0,0 +1,37 @@ +const std = @import("std"); + +// Although this function looks imperative, note that its job is to +// declaratively construct a build graph that will be executed by an external +// runner. +pub fn build(b: *std.Build) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard optimization options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not + // set a preferred release mode, allowing the user to decide how to optimize. + const optimize = b.standardOptimizeOption(.{}); + + _ = b.addModule("foxwhale-wayland", .{ + .root_source_file = .{ .path = "src/root.zig" }, + }); + + // Creates a step for unit testing. This only builds the test executable + // but does not run it. + const lib_unit_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/root.zig" }, + .target = target, + .optimize = optimize, + }); + + const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); + + // Similar to creating the run step earlier, this exposes a `test` step to + // the `zig build --help` menu, providing a way for the user to request + // running the unit tests. + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_lib_unit_tests.step); +} diff --git a/foxwhale-wayland/build.zig.zon b/foxwhale-wayland/build.zig.zon new file mode 100644 index 0000000..5355e02 --- /dev/null +++ b/foxwhale-wayland/build.zig.zon @@ -0,0 +1,62 @@ +.{ + .name = "foxwhale-wayland", + // 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 = .{ + // See `zig fetch --save ` for a command-line interface for adding dependencies. + //.example = .{ + // // When updating this field to a new URL, be sure to delete the corresponding + // // `hash`, otherwise you are communicating that you expect to find the old hash at + // // the new URL. + // .url = "https://example.com/foo.tar.gz", + // + // // This is computed from the file contents of the directory of files that is + // // obtained after fetching `url` and applying the inclusion rules given by + // // `paths`. + // // + // // This field is the source of truth; packages do not come from a `url`; they + // // come from a `hash`. `url` is just one of many possible mirrors for how to + // // obtain a package matching this `hash`. + // // + // // Uses the [multihash](https://multiformats.io/multihash/) format. + // .hash = "...", + // + // // When this is provided, the package is found in a directory relative to the + // // build root. In this case the package's hash is irrelevant and therefore not + // // computed. This field and `url` are mutually exclusive. + // .path = "foo", + //}, + }, + + // Specifies the set of files and directories that are included in this package. + // Only files and directories listed here are included in the `hash` that + // is computed for this package. + // Paths are relative to the build root. Use the empty string (`""`) to refer to + // the build root itself. + // A directory listed here means that all files within, recursively, are included. + .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", + }, +} diff --git a/src/wl/protocols.zig b/foxwhale-wayland/src/protocols.zig similarity index 100% rename from src/wl/protocols.zig rename to foxwhale-wayland/src/protocols.zig diff --git a/foxwhale-wayland/src/root.zig b/foxwhale-wayland/src/root.zig new file mode 100644 index 0000000..9786e1b --- /dev/null +++ b/foxwhale-wayland/src/root.zig @@ -0,0 +1,2 @@ +pub const Wire = @import("wire.zig").Wire; +pub const Wayland = @import("protocols.zig").Wayland; diff --git a/src/wl/txrx.zig b/foxwhale-wayland/src/txrx.zig similarity index 100% rename from src/wl/txrx.zig rename to foxwhale-wayland/src/txrx.zig diff --git a/src/wl/wire.zig b/foxwhale-wayland/src/wire.zig similarity index 100% rename from src/wl/wire.zig rename to foxwhale-wayland/src/wire.zig diff --git a/src/client.zig b/src/client.zig index b6dac6c..c872e82 100644 --- a/src/client.zig +++ b/src/client.zig @@ -28,7 +28,7 @@ const endian = builtin.cpu.arch.endian(); const log = std.log.scoped(.client); -pub const wl = @import("wl/protocols.zig").Wayland(.{ +pub const wl = @import("foxwhale-wayland").Wayland(.{ .wl_surface = *Window, .wl_subsurface = *Window, .xdg_surface = *Window, diff --git a/src/server.zig b/src/server.zig index cb68037..9862418 100644 --- a/src/server.zig +++ b/src/server.zig @@ -5,7 +5,6 @@ const os = std.os; const Event = @import("subsystem.zig").Event; const SubsystemIterator = @import("subsystem.zig").SubsystemIterator; const Client = @import("client.zig").Client; -const Wire = @import("wl/wire.zig").Wire; const wl = @import("client.zig").wl; diff --git a/src/view.zig b/src/view.zig index 8bd8880..667a1a3 100644 --- a/src/view.zig +++ b/src/view.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const prot = @import("wl/protocols.zig"); const Focus = @import("focus.zig").Focus; const Window = @import("resource/window.zig").Window; const BackendOutput = @import("backend/backend.zig").BackendOutput;