Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,15 @@ jobs:

format:
name: clang-format
# Pinned, not ubuntu-latest: the formatter's output is the check, and it moves with the
# point release - 26.04's clang-format-18 (18.1.8) lays out tables that 24.04's (18.1.3)
# accepts differently, so an image bump fails files nobody touched.
runs-on: ubuntu-24.04
# The formatter's output is the check, so it is pinned to the patch release in
# requirements-dev.txt and installed from PyPI by the Makefile - the same wheel a Mac formats
# with. apt's clang-format-18 moved with the runner image (24.04's 18.1.3 and 26.04's 18.1.8
# lay tables out differently), which is why this job used to pin the image instead.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install clang-format
run: sudo apt-get update && sudo apt-get install -y clang-format-18

# The generated glyph tables are excluded for the reason they are in their own directory:
# 42k lines nobody wrote and nobody reads, and reformatting them would bury every real
# change in a diff the size of the repository.
# Through the Makefile, so the file list - which excludes the generated glyph tables, 42k
# lines nobody wrote and nobody reads - lives in exactly one place.
- name: Check formatting
run: |
files=$(git ls-files '*.c' '*.h' | grep -v '^src/generated/')
clang-format-18 --dry-run --Werror $files
run: make format-check
4 changes: 3 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ scripts/kms-vm.py the KMS backend on QEMU's virtio-gpu, every frame

## Style

- clang-format 18, config in `.clang-format`. `make format` before pushing; CI checks it.
- clang-format, the exact version pinned in `requirements-dev.txt` (`make format` installs it into
`build/venv`; never format with whatever is on `PATH`), config in `.clang-format`. `make format`
before pushing; CI runs `make format-check`.
`src/generated/` is excluded on purpose: reflowing megabytes of glyph tables is an unreadable
diff.
- `inkcell_` on everything public, `INKCELL_` on macros and enum members. A symbol carries the
Expand Down
33 changes: 27 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@

BUILD ?= build

.PHONY: all test debug format clean gallery gallery-update
.PHONY: all venv test debug format format-check clean gallery gallery-update

all: debug

debug:
cmake -S . -B $(BUILD) -G Ninja -DCMAKE_BUILD_TYPE=Debug
# The host tools in requirements-dev.txt - the Python inkwell's Mbed TLS generates its sources
# with, and the pinned clang-format - in a venv of their own, remade when that file changes.
VENV = $(BUILD)/venv
VENV_STAMP = $(VENV)/.installed

venv: $(VENV_STAMP)
$(VENV_STAMP): requirements-dev.txt
python3 -m venv $(VENV)
$(VENV)/bin/pip install --quiet --disable-pip-version-check -r requirements-dev.txt
@touch $@

debug: $(VENV_STAMP)
cmake -S . -B $(BUILD) -G Ninja -DCMAKE_BUILD_TYPE=Debug \
-DPython3_EXECUTABLE=$(abspath $(VENV))/bin/python3
cmake --build $(BUILD)

# The verify step, and what CI runs: the unit suite plus the check that no renderer spells out
Expand Down Expand Up @@ -46,9 +58,18 @@ gallery-update: debug
# has ever run it over, is the one moment it did nothing. The CI check runs after the add and
# caught it there instead, which is a round trip for something the author could have been told
# locally. --others --exclude-standard is the untracked half, minus whatever .gitignore says.
format:
git ls-files --cached --others --exclude-standard '*.c' '*.h' \
| grep -v '^src/generated/' | xargs clang-format -i
#
# `format-check` is what CI runs: the same list, changing nothing, failing on the first file that
# differs. The formatter is the one requirements-dev.txt pins, never whatever is on PATH.
FORMAT_FILES = $$(git ls-files --cached --others --exclude-standard '*.c' '*.h' \
| grep -v '^src/generated/')
CLANG_FORMAT ?= $(VENV)/bin/clang-format

format: $(VENV_STAMP)
$(CLANG_FORMAT) -i $(FORMAT_FILES)

format-check: $(VENV_STAMP)
$(CLANG_FORMAT) --dry-run --Werror $(FORMAT_FILES)

clean:
rm -rf $(BUILD)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ forces the second on a machine that has the library.
make test # debug build + ctest: the unit suite, the no-prose check, the golden sheet
make debug # build only
make gallery # the pictures (see above)
make format # clang-format, skipping the generated glyph tables
make format # the pinned clang-format, skipping the generated glyph tables
```

Sanitizers: `cmake -S . -B build -DINKCELL_ENABLE_ASAN=ON -DINKCELL_ENABLE_UBSAN=ON`. CI runs
Expand Down
11 changes: 11 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Host tools for this repo, installed into build/venv by `make venv` (the targets that need them
# make it first). jinja2 and jsonschema are what Mbed TLS generates its sources with.
#
# clang-format is pinned to the patch release because its output *is* the format check: two
# "clang-format 18"s (Ubuntu 24.04's 18.1.3 and 26.04's 18.1.8) lay the same table out
# differently, and Homebrew's is whatever is newest. This wheel is the same formatter on macOS and
# Linux, so `make format` on a laptop and `make format-check` in CI agree by construction. Bumping
# it is one line here plus one `make format` commit.
jinja2
jsonschema
clang-format==23.1.5
4 changes: 2 additions & 2 deletions src/fb/fb_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ void inkcell_fb_draw_emoji_box(const struct inkcell_draw_state *state, int x, in
if (!inkcell_fb_clip_box(state, x, top + first, drawn, rows, &clip)) {
continue;
}
uint8_t(*pixels)[4] = band;
uint8_t (*pixels)[4] = band;
#if INKCELL_EMOJI_CACHE_SLOTS > 0
if (drawn <= INKCELL_EMOJI_BAND) {
pixels = inkcell_fb_emoji_cached(sprite, drawn);
Expand All @@ -2282,7 +2282,7 @@ void inkcell_fb_draw_emoji_box(const struct inkcell_draw_state *state, int x, in
state->surface.size) {
continue;
}
uint8_t(*from)[4] = &pixels[(size_t)row * (size_t)drawn + (size_t)span.dx];
uint8_t (*from)[4] = &pixels[(size_t)row * (size_t)drawn + (size_t)span.dx];
for (int i = 0; i < span.w; ++i, out += bpp) {
/* The margin is a good share of every emoji, and a pixel with no opacity has
nothing to add - premultiplied, it is all zero. */
Expand Down
2 changes: 1 addition & 1 deletion src/theme/emoji_raster.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static bool raster_path(struct raster *r, const uint8_t *at, const uint8_t *end,
static void raster_composite(struct raster *r, const uint8_t rgba[4], uint8_t (*out)[4]) {
for (int row = r->top_row; row <= r->bottom_row; ++row) {
int32_t *acc = g_acc[row];
uint8_t(*px)[4] = &out[(size_t)row * (size_t)r->width];
uint8_t (*px)[4] = &out[(size_t)row * (size_t)r->width];
int32_t sum = 0;
for (int x = 0; x < r->width; ++x) {
sum += acc[x];
Expand Down
36 changes: 17 additions & 19 deletions src/theme/theme.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
#include <stdlib.h>
#include <string.h>

#define RGB(rr, gg, bb) \
{ .r = (rr), .g = (gg), .b = (bb) }
#define RGB(rr, gg, bb) {.r = (rr), .g = (gg), .b = (bb)}

/*
* The metrics the Brick's panel was tuned for. A theme that wants a different look overrides
Expand Down Expand Up @@ -95,18 +94,19 @@
*/
#define INKCELL_SHADOWS_LIGHT \
{ \
[INKCELL_ELEVATION_FLAT] = {0U, 0U, 0U}, [INKCELL_ELEVATION_RAISED] = {1U, 3U, 16U}, \
[INKCELL_ELEVATION_FLOATING] = {2U, 5U, 22U}, [INKCELL_ELEVATION_MODAL] = {3U, 8U, 28U}, \
[INKCELL_ELEVATION_FLAT] = {0U, 0U, 0U}, \
[INKCELL_ELEVATION_RAISED] = {1U, 3U, 16U}, \
[INKCELL_ELEVATION_FLOATING] = {2U, 5U, 22U}, \
[INKCELL_ELEVATION_MODAL] = {3U, 8U, 28U}, \
}
#define INKCELL_SHADOWS_DARK \
{ \
[INKCELL_ELEVATION_FLAT] = {0U, 0U, 0U}, [INKCELL_ELEVATION_RAISED] = {1U, 3U, 40U}, \
[INKCELL_ELEVATION_FLOATING] = {2U, 5U, 50U}, [INKCELL_ELEVATION_MODAL] = {3U, 8U, 60U}, \
}
#define INKCELL_SHADOWS_NONE \
{ \
{ 0U, 0U, 0U } \
[INKCELL_ELEVATION_FLAT] = {0U, 0U, 0U}, \
[INKCELL_ELEVATION_RAISED] = {1U, 3U, 40U}, \
[INKCELL_ELEVATION_FLOATING] = {2U, 5U, 50U}, \
[INKCELL_ELEVATION_MODAL] = {3U, 8U, 60U}, \
}
#define INKCELL_SHADOWS_NONE {{0U, 0U, 0U}}

/*
* The scrim and the shadows are taken as parameters rather than restated in the table, so a
Expand Down Expand Up @@ -142,42 +142,40 @@
.tracking = INKCELL_SCALE(1) / 2, \
.line_pct = 100U, \
.tabular = true}, \
}, \
}, \
.space = \
{ \
[INKCELL_SPACE_NONE] = 0U, [INKCELL_SPACE_XS] = 1U, [INKCELL_SPACE_SM] = 2U, \
[INKCELL_SPACE_MD] = 4U, [INKCELL_SPACE_LG] = 6U, \
}, \
}, \
.field_label_cols = 20U, .narrow_cols = 40U, .card_pad = 2U, .meter_thickness = 1U, \
.motion_ms = \
{ \
[INKCELL_MOTION_SHORT] = 140U, \
[INKCELL_MOTION_MEDIUM] = 220U, \
[INKCELL_MOTION_LONG] = 320U, \
[INKCELL_MOTION_LOOP] = 1400U, \
}, \
}, \
.shape = \
{ \
[INKCELL_SHAPE_NONE] = 0U, \
[INKCELL_SHAPE_SM] = 2U, \
[INKCELL_SHAPE_MD] = 3U, \
[INKCELL_SHAPE_LG] = 4U, \
}, \
}, \
.opacity = \
{ \
[INKCELL_OPACITY_HOVER] = 8U, [INKCELL_OPACITY_FOCUS] = 12U, \
[INKCELL_OPACITY_PRESS] = 20U, [INKCELL_OPACITY_DISABLED] = 38U, \
[INKCELL_OPACITY_SCRIM] = (scrim), \
}, \
}, \
.shadow = shadows

/* The default metrics: Material's 32% scrim, which is the figure every platform has converged
on - enough that the eye stops reading the body, little enough that it can still see what the
question is about, and a palette that needs more says so. */
#define INKCELL_METRICS_DARK \
{ INKCELL_METRICS_FIELDS(32U, INKCELL_SHADOWS_DARK) }
#define INKCELL_METRICS_LIGHT \
{ INKCELL_METRICS_FIELDS(32U, INKCELL_SHADOWS_LIGHT) }
#define INKCELL_METRICS_DARK {INKCELL_METRICS_FIELDS(32U, INKCELL_SHADOWS_DARK)}
#define INKCELL_METRICS_LIGHT {INKCELL_METRICS_FIELDS(32U, INKCELL_SHADOWS_LIGHT)}

static const struct inkcell_theme
k_themes[] =
Expand Down
2 changes: 1 addition & 1 deletion tests/suites/ui_shapes.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ INKCELL_TEST_CASE(emoji_enlarged_stays_sharp, unit) {
const int rows = box < INKCELL_EMOJI_BAND ? box : INKCELL_EMOJI_BAND;
INKCELL_TEST_FAIL_IF(inkcell_emoji_render(sprite, box, first, rows, band) != 0,
"the grinning face should render");
uint8_t(*middle)[4] = &band[(size_t)(box / 2 - first) * (size_t)box];
uint8_t (*middle)[4] = &band[(size_t)(box / 2 - first) * (size_t)box];
int ramp = 0;
for (int x = 0; x < box / 2 && middle[x][3] < 255U; ++x) {
ramp += middle[x][3] > 0U;
Expand Down
2 changes: 1 addition & 1 deletion third_party/inkwell
Submodule inkwell updated 75 files
+8 −6 .github/workflows/ci.yml
+17 −6 AGENTS.md
+39 −3 CMakeLists.txt
+18 −6 Makefile
+20 −14 README.md
+75 −1 include/inkwell/base/fd.h
+23 −0 include/inkwell/base/random.h
+44 −0 include/inkwell/codec/deflate.h
+128 −0 include/inkwell/codec/fields.h
+74 −0 include/inkwell/codec/frame.h
+41 −0 include/inkwell/codec/kdf.h
+24 −0 include/inkwell/codec/png.h
+41 −0 include/inkwell/codec/signature.h
+98 −0 include/inkwell/io/uevent.h
+216 −0 include/inkwell/net/local.h
+7 −0 include/inkwell/net/reason.h
+31 −23 include/inkwell/net/resolve.h
+40 −0 include/inkwell/net/stream.h
+10 −0 include/inkwell/net/tls.h
+69 −0 include/inkwell/runtime/child.h
+10 −0 include/inkwell/runtime/crash.h
+6 −0 include/inkwell/runtime/loop.h
+11 −0 requirements-dev.txt
+241 −2 src/base/fd.c
+2 −0 src/base/platform.h
+15 −0 src/base/random.c
+195 −0 src/codec/deflate.c
+261 −0 src/codec/fields.c
+87 −0 src/codec/frame.c
+29 −1 src/codec/json.c
+88 −0 src/codec/kdf.c
+173 −0 src/codec/png_encode.c
+34 −0 src/codec/signature.c
+18 −0 src/codec/signature_unavailable.c
+92 −0 src/io/uevent.c
+167 −0 src/io/uevent_netlink.c
+25 −0 src/io/uevent_unavailable.c
+6 −3 src/net/fetch.c
+357 −0 src/net/local.c
+83 −0 src/net/local_unavailable.c
+2 −2 src/net/mqtt.c
+2 −0 src/net/reason.c
+505 −0 src/net/resolve_apple.c
+81 −9 src/net/stream.c
+15 −0 src/net/tls.c
+29 −0 src/runtime/base_posix.c
+19 −0 src/runtime/base_windows.c
+225 −0 src/runtime/child.c
+24 −0 src/runtime/child_unavailable.c
+52 −495 src/runtime/crash.c
+47 −0 src/runtime/crash_internal.h
+534 −0 src/runtime/crash_report.c
+289 −23 src/runtime/crash_windows.c
+1 −0 src/runtime/loop.c
+16 −1 tests/CMakeLists.txt
+107 −0 tests/suites/base_fd_pass.c
+27 −0 tests/suites/base_random.c
+113 −0 tests/suites/codec_deflate.c
+159 −0 tests/suites/codec_fields.c
+96 −0 tests/suites/codec_frame.c
+28 −0 tests/suites/codec_json.c
+77 −0 tests/suites/codec_kdf.c
+67 −0 tests/suites/codec_signature.c
+209 −0 tests/suites/io_uevent.c
+42 −0 tests/suites/net_fetch.c
+321 −0 tests/suites/net_local.c
+13 −3 tests/suites/net_mqtt.c
+40 −0 tests/suites/net_stream.c
+245 −0 tests/suites/runtime_child.c
+206 −0 tests/suites/runtime_crash_windows.c
+55 −0 tests/suites/runtime_loop.c
+14 −2 tests/support/https_fixture.c
+7 −0 tests/support/https_fixture.h
+23 −0 tests/support/tls_identity.c
+4 −0 tests/support/tls_identity.h
Loading