Extended prettyasserts.py to support prefixed memcmp/strcmp

The move to lfs_memcmp/lfs_strcmp highlighted an interesting hole in
prettyasserts.py: the lack of support for custom memcmp/strcmp symbols.

Rather than just adding more flags for an increasing number of symbols,
I've added -p/--prefix and -P/--prefix-insensitive to generate relevant
symbols based on a prefix. In littlefs's case, we use -Plfs_, which
matches both lfs_memcmp and LFS_ASSERT (and LFS_MEMCMP and lfs_assert
but ignore those):

  $ ./scripts/prettyasserts.py -Plfs_ lfs.t.c -o lfs.t.a.c

Don't worry, you can still provide explicit symbols, but only via
long-form flags. This gets a bit noisy:

  $ ./scripts/prettyasserts.py \
      --assert=LFS_ASSERT \
      --unreachable=LFS_UNREACHABLE \
      --memcmp=lfs_memcmp \
      --strcmp=lfs_strcmp \
      lfs.t.c -o lfs.t.a.c

This commit also finally gives the prettyasserts.py's symbols actual
word boundaries, instead of the big error-prone hack of sorting by size.
This commit is contained in:
Christopher Haster
2024-05-20 20:35:54 -05:00
parent 6874a56dcb
commit 4208aa21e2
2 changed files with 59 additions and 19 deletions
+2 -2
View File
@@ -523,10 +523,10 @@ $(BUILDDIR)/%.s: %.c
$(CC) -S $(CFLAGS) $< -o $@
$(BUILDDIR)/%.a.c: %.c
$(PRETTYASSERTS) -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@
$(PRETTYASSERTS) -Plfs_ $< -o $@
$(BUILDDIR)/%.a.c: $(BUILDDIR)/%.c
$(PRETTYASSERTS) -a LFS_ASSERT -u LFS_UNREACHABLE $< -o $@
$(PRETTYASSERTS) -Plfs_ $< -o $@
$(BUILDDIR)/%.t.c: %.toml
./scripts/test.py -c $< $(TESTCFLAGS) -o $@