Vendor clay and bring the UI subsystem up: arena, lifecycle, status band
clay v0.14 (deps/clay, zlib licence) supplies the layout engine for the new akgl_ui subsystem. Sources-listed rather than add_subdirectory()'d, on the semver/libccd precedent: clay's CMakeLists declares no library target, builds its examples by default, and requires CMake 3.27 against this project's 3.10. src/ui_clay.c is the one CLAY_IMPLEMENTATION translation unit, compiled -w on the vendored-code terms but with clay's symbols deliberately exported -- consumers' CLAY() macros resolve against libakgl.so, and akgl/ui.h warns them never to link a second clay. The subsystem is runtime-optional the way collision is: always compiled in, inert until akgl_ui_init(), which bounds clay to the overridable AKGL_UI_* ceilings, checks Clay_MinMemorySize() against a static BSS arena (no malloc), and refuses with both numbers in the message when it does not fit. Measured: 812544 bytes at the default 1024 elements / 4096 measured words, against a 1 MiB arena. clay's void-callback layout errors are logged as they happen and the first is stashed for the error protocol to raise later. AKGL_ERR_UI joins the status band before AKGL_ERR_LIMIT, named in akgl_error_init. New `ui` test suite covers validation, the init/shutdown lifecycle, and arena exhaustion via the akgl_ui_arena_limit test hook (same contract as akgl_ccd_arena_set_limit). clay.h is installed beside semver.h, its licence beside libccd's, and the headers suite proves akgl/ui.h self-contained -- clay.h compiles clean under -Wall. Co-Authored-By: Claude Code (Claude Fable 5, claude-fable-5) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71 Co-Authored-By: Andrew Kesterson <andrew@aklabs.net>
This commit is contained in:
@@ -217,6 +217,7 @@ set(AKGL_PUBLIC_HEADERS
|
||||
text
|
||||
tilemap
|
||||
types
|
||||
ui
|
||||
util
|
||||
)
|
||||
|
||||
@@ -317,6 +318,8 @@ add_library(akgl SHARED
|
||||
src/sprite.c
|
||||
src/staticstring.c
|
||||
src/tilemap.c
|
||||
src/ui.c
|
||||
src/ui_clay.c
|
||||
src/util.c
|
||||
src/version.c
|
||||
)
|
||||
@@ -368,6 +371,26 @@ set_source_files_properties(${AKGL_CCD_SOURCES} PROPERTIES
|
||||
COMPILE_OPTIONS "-w;-fvisibility=hidden;-include;${CMAKE_CURRENT_SOURCE_DIR}/src/ccd_arena_shim.h"
|
||||
COMPILE_DEFINITIONS "CCD_STATIC_DEFINE")
|
||||
|
||||
# clay supplies the UI layout engine. Its sources are listed rather than
|
||||
# add_subdirectory()'d, on the semver/libccd precedent, because
|
||||
# deps/clay/CMakeLists.txt is unusable as a subproject and none of it is ours
|
||||
# to fix in a submodule:
|
||||
#
|
||||
# - it declares no library target at all -- clay is a single header, and the
|
||||
# add_library(INTERFACE) lines at the bottom are commented out upstream.
|
||||
# - option(CLAY_INCLUDE_ALL_EXAMPLES ... ON) add_subdirectory()s every
|
||||
# example by default, dragging raylib, cairo and sokol into our configure.
|
||||
# - cmake_minimum_required(VERSION 3.27) against this project's 3.10.
|
||||
#
|
||||
# src/ui_clay.c is the one translation unit that defines CLAY_IMPLEMENTATION;
|
||||
# it is 99% vendored code, so it gets -w on the same terms as semver and
|
||||
# libccd. Deliberately NOT -fvisibility=hidden, unlike libccd: the CLAY()
|
||||
# macros in a consuming game expand to Clay__OpenElement() and friends, which
|
||||
# must resolve against libakgl.so, so clay's symbols are part of the ABI on
|
||||
# purpose. The matching obligation -- a consumer must not link a second clay --
|
||||
# is documented in akgl/ui.h.
|
||||
set_source_files_properties(src/ui_clay.c PROPERTIES COMPILE_OPTIONS "-w")
|
||||
|
||||
# PRIVATE, so that ccd/*.h never reaches a consumer's include path. The `headers`
|
||||
# suite compiles each public header as the first include of a translation unit
|
||||
# with only include/ available, so a public header that pulled in <ccd/ccd.h>
|
||||
@@ -406,6 +429,7 @@ set(AKGL_TEST_SUITES
|
||||
staticstring
|
||||
text
|
||||
tilemap
|
||||
ui
|
||||
util
|
||||
version
|
||||
)
|
||||
@@ -516,6 +540,11 @@ set_tests_properties(
|
||||
target_include_directories(akgl PUBLIC
|
||||
include/
|
||||
deps/semver/
|
||||
# PUBLIC, unlike libccd's PRIVATE include above, because akgl/ui.h includes
|
||||
# <clay.h> in its public interface -- consumers write CLAY() blocks, so
|
||||
# hiding the header would hide the point. clay.h is installed beside
|
||||
# semver.h for the same reason.
|
||||
deps/clay/
|
||||
# akgl/version.h is generated by configure_file, so it lives in the build tree
|
||||
# rather than beside the headers it is included from.
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/
|
||||
@@ -882,11 +911,14 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/akgl.pc DESTINATION "lib/pkgconfig/")
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/akgl/version.h DESTINATION "include/akgl/")
|
||||
install(TARGETS akgl DESTINATION "lib/")
|
||||
install(FILES "deps/semver/semver.h" DESTINATION "include/")
|
||||
# libccd is compiled into libakgl.so, and its BSD-3 licence requires the notice
|
||||
# to travel with the binary form. Nothing else in deps/ is linked in statically
|
||||
# -- SDL, jansson, libakerror and libakstdlib are all separate shared objects
|
||||
# that ship their own -- so this is the only third-party notice we owe.
|
||||
install(FILES "deps/clay/clay.h" DESTINATION "include/")
|
||||
# libccd and clay are compiled into libakgl.so, and their licences (BSD-3 and
|
||||
# zlib respectively) ask that the notice travel with the binary form. Nothing
|
||||
# else in deps/ is linked in statically -- SDL, jansson, libakerror and
|
||||
# libakstdlib are all separate shared objects that ship their own -- so these
|
||||
# are the only third-party notices we owe.
|
||||
install(FILES "deps/libccd/BSD-LICENSE" DESTINATION "share/doc/akgl/" RENAME "BSD-LICENSE.libccd")
|
||||
install(FILES "deps/clay/LICENSE.md" DESTINATION "share/doc/akgl/" RENAME "LICENSE.clay")
|
||||
foreach(header IN LISTS AKGL_PUBLIC_HEADERS)
|
||||
install(FILES "include/akgl/${header}.h" DESTINATION "include/akgl/")
|
||||
endforeach()
|
||||
|
||||
Reference in New Issue
Block a user