diff options
| author | Adam Malczewski <[email protected]> | 2026-06-12 19:11:59 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-12 19:11:59 +0900 |
| commit | a21f705692595ea711a736e2ae9c256c1dde7b1e (patch) | |
| tree | 2cb3e6380e65f9b584a1dea1cd43e1a127a4f56d /packages/kernel | |
| parent | 6f45dc177540d6c6ae7596427209091d4c7adc20 (diff) | |
| download | unbox-a21f705692595ea711a736e2ae9c256c1dde7b1e.tar.gz unbox-a21f705692595ea711a736e2ae9c256c1dde7b1e.zip | |
Slice 1: Meson skeleton — kernel links wlroots 0.20 from C++, RMLUi 6.2 vendored
Root meson.build (C++23, WLR_USE_UNSTABLE, ccache-detected) with RMLUi 6.2
as a wrap-file tarball built through the cmake module (no git submodules —
settled decision) and doctest 2.5.2 from wrapdb. kernel unit: extern-"C"
wlr.hpp wrapper (with the C99 [static N] array-param workaround documented
in kernel.md), slice-1 probe contract, doctest suite (1/1 green). host-bin:
composition root printing versions, exit 0. tasks.md slice 1 done.
Diffstat (limited to 'packages/kernel')
| -rw-r--r-- | packages/kernel/include/unbox/kernel/kernel.hpp | 26 | ||||
| -rw-r--r-- | packages/kernel/include/unbox/kernel/wlr.hpp | 28 | ||||
| -rw-r--r-- | packages/kernel/kernel.md | 19 | ||||
| -rw-r--r-- | packages/kernel/meson.build | 26 | ||||
| -rw-r--r-- | packages/kernel/src/kernel.cpp | 26 | ||||
| -rw-r--r-- | packages/kernel/tests/test_kernel.cpp | 13 |
6 files changed, 138 insertions, 0 deletions
diff --git a/packages/kernel/include/unbox/kernel/kernel.hpp b/packages/kernel/include/unbox/kernel/kernel.hpp new file mode 100644 index 0000000..9836a14 --- /dev/null +++ b/packages/kernel/include/unbox/kernel/kernel.hpp @@ -0,0 +1,26 @@ +#pragma once + +#include <string> + +// Slice-1 probe surface: proves the kernel compiles against wlroots from +// C++ and links wlroots, libwayland-server, and the vendored RMLUi. The +// real contracts (extension host, bus, scene/seat glue, ui substrate) +// replace this from slice 2 on. +// +// Calling context: everything in unbox runs on the single wl_event_loop +// thread unless a contract explicitly states otherwise. + +namespace unbox::kernel { + +/// The wlroots version this kernel was compiled against (the 0.20 pin). +[[nodiscard]] auto wlroots_version() -> std::string; + +/// The RMLUi version linked from the vendored subproject. +[[nodiscard]] auto rmlui_version() -> std::string; + +/// Creates and immediately destroys a wl_display: proves we can call into +/// libwayland-server/wlroots at runtime, not just link. Returns true on +/// success. No side effects beyond wlroots log initialization. +[[nodiscard]] auto link_probe() -> bool; + +} // namespace unbox::kernel diff --git a/packages/kernel/include/unbox/kernel/wlr.hpp b/packages/kernel/include/unbox/kernel/wlr.hpp new file mode 100644 index 0000000..6374a52 --- /dev/null +++ b/packages/kernel/include/unbox/kernel/wlr.hpp @@ -0,0 +1,28 @@ +#pragma once + +// The ONLY file in the project allowed to include wlroots / libwayland +// headers (.unbox/rules/wlroots-include.md). wlroots is C; this wrapper +// provides the extern-"C" guards C++ needs. WLR_USE_UNSTABLE is defined +// project-wide in the root meson.build; the version pin is wlroots 0.20. +// +// Grow this include list as kernel glue needs more types — never include +// <wlr/...> anywhere else, in any unit. + +extern "C" { +#include <wayland-server-core.h> + +// wlroots headers use C99 array-parameter syntax (`float color[static 4]`), +// which is invalid C++. Blanking `static` around the wlr includes is the +// proven workaround (Hyprland shipped years on it): `static inline` header +// helpers become plain `inline`, which C++ ODR-merges safely. Keep the +// #define scoped to EXACTLY these includes. +#define static +#include <wlr/backend.h> +#include <wlr/render/allocator.h> +#include <wlr/render/wlr_renderer.h> +#include <wlr/types/wlr_output.h> +#include <wlr/types/wlr_scene.h> +#include <wlr/util/log.h> +#include <wlr/version.h> +#undef static +} diff --git a/packages/kernel/kernel.md b/packages/kernel/kernel.md new file mode 100644 index 0000000..e2ee684 --- /dev/null +++ b/packages/kernel/kernel.md @@ -0,0 +1,19 @@ +# kernel — package notes + +Slice-1 state: a probe surface (`kernel.hpp`) proving C++ ↔ wlroots ↔ RMLUi +compile/link. Real contracts (extension host, bus, scene/seat glue, ui +substrate) land from slice 2. + +Gotchas the headers can't express: + +- **`wlr.hpp` blanks `static` around the wlr includes.** wlroots headers + use C99 array-parameter syntax (`float color[static 4]`), invalid in + C++. With `static` blanked, `static inline` helpers become `inline` + (ODR-merged, safe). Cost: a function-local `static` inside a header + inline would silently lose persistence — none exist in our include set; + re-audit when ADDING includes to the wrapper. +- **RMLUi is kernel-private.** `rmlui_dep` is deliberately absent from + `kernel_dep` propagation (see meson.build): extensions contribute RML + documents + data bindings via the ui substrate, never RMLUi API calls. + Do not "fix" a missing-RMLUi-header error downstream by propagating it. +- Everything runs on the single `wl_event_loop` thread. diff --git a/packages/kernel/meson.build b/packages/kernel/meson.build new file mode 100644 index 0000000..4a67ced --- /dev/null +++ b/packages/kernel/meson.build @@ -0,0 +1,26 @@ +# kernel — the minimal runtime core. Public headers (the ABI): include/unbox/kernel/ + +kernel_inc = include_directories('include') + +kernel_lib = static_library( + 'unbox-kernel', + 'src/kernel.cpp', + include_directories: kernel_inc, + dependencies: [wlroots_dep, wayland_server_dep, rmlui_dep], +) + +# What consumers get. wlroots/wayland propagate because wlr.hpp is a public +# header; RMLUi does NOT — it is kernel-private (the ui substrate owns it, +# extensions contribute RML documents + data bindings, never RMLUi calls). +kernel_dep = declare_dependency( + link_with: kernel_lib, + include_directories: kernel_inc, + dependencies: [wlroots_dep, wayland_server_dep], +) + +kernel_test = executable( + 'kernel-tests', + 'tests/test_kernel.cpp', + dependencies: [kernel_dep, doctest_dep], +) +test('kernel', kernel_test, suite: 'kernel') diff --git a/packages/kernel/src/kernel.cpp b/packages/kernel/src/kernel.cpp new file mode 100644 index 0000000..3de39c0 --- /dev/null +++ b/packages/kernel/src/kernel.cpp @@ -0,0 +1,26 @@ +#include <unbox/kernel/kernel.hpp> +#include <unbox/kernel/wlr.hpp> + +#include <RmlUi/Core/Core.h> + +namespace unbox::kernel { + +auto wlroots_version() -> std::string { + return WLR_VERSION_STR; +} + +auto rmlui_version() -> std::string { + return Rml::GetVersion(); +} + +auto link_probe() -> bool { + wlr_log_init(WLR_ERROR, nullptr); + wl_display* display = wl_display_create(); + if (display == nullptr) { + return false; + } + wl_display_destroy(display); + return true; +} + +} // namespace unbox::kernel diff --git a/packages/kernel/tests/test_kernel.cpp b/packages/kernel/tests/test_kernel.cpp new file mode 100644 index 0000000..ebcfbc3 --- /dev/null +++ b/packages/kernel/tests/test_kernel.cpp @@ -0,0 +1,13 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include <doctest/doctest.h> + +#include <unbox/kernel/kernel.hpp> + +TEST_CASE("kernel compiles against and links wlroots + libwayland-server") { + CHECK(unbox::kernel::link_probe()); + CHECK(unbox::kernel::wlroots_version().substr(0, 4) == "0.20"); +} + +TEST_CASE("vendored RMLUi subproject compiled and linked") { + CHECK(!unbox::kernel::rmlui_version().empty()); +} |
