Files
Robin AveryandClaude Opus 5.5 d52f449432 dat: implement C deserialization codegen, improve coverage (#3632)
A C library, tools/dat-cli/native, that reads the archives into the game's own types on any platform, from tables `melee-dat native codegen` writes from the DWARF. It's a port of the walk that converts as it goes, so `melee-dat native expect` and the library's trace must agree: they do for all 7048 archives on 64-bit and 32-bit little-endian and 32-bit big-endian (under qemu), and every converted object reads back against its data. The dat preset builds it with the host's compiler and runs its tests in ctest.

- the walk lays queued objects out as they were reached, so typedef tags
  apply (the CPU attack lists' DAT_TERMINATED was ignored)
- CPU attack tables typed (ftCo_AttackList); stage param types moved into
  their headers; stage param fields typed as their data
- 47 dat_symbols.txt aliases that read stage data as material animations
  removed
- generated C casts only between different types; untyped data typed from
  the fields that point to it
- `samples report --incomplete`, why units aren't complete
- a `native` dev shell with the DWARF/dat tools, qemu and a ppc32 cross
  compiler; the default shell is what CI needs
- clang-tidy's checks stay on src/: tools/ and the generated tables opt out

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* dat: native schema as descriptors per type, a file per header, enum type indices

`melee-dat native codegen` writes a directory instead of one tables.c:
each type is a named `dat_type_*` descriptor with its members, in
types/<header>.c for the header that declares it, along with what refers
to it (pointers, arrays); roots are in roots/<module>.c; DAT_TYPE_* and
DAT_NAME_* are enums. Descriptors use designated initializers, refer to
types by name and keep expressions next to their members, with the
annotation as written in a comment where it isn't plain.

- dat/schema.h: the schema's types and the macros descriptors are written
  in; DAT_NONE is 0, so every field defaults to zero
- members, expressions, scripts, binds and roots are pointers, not ranges
  of shared tables; macros expand to a depth when evaluated
- the schema is generated when configuring, again when its inputs change
- codegen split into generator.rs (the rows) and emit.rs (the C)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-05 13:13:55 -04:00

15 lines
725 B
CMake

# 32-bit big-endian: the archives' own byte order and pointer size, as
# PowerPC Linux binaries run under qemu's user mode (the native dev shell
# has both), with the cross compiler's C library as qemu's sysroot.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc)
set(CMAKE_C_COMPILER powerpc-unknown-linux-gnu-gcc)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
find_program(QEMU_PPC qemu-ppc REQUIRED)
execute_process(
COMMAND "${CMAKE_C_COMPILER}" -print-file-name=libc.so.6
OUTPUT_VARIABLE _libc OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(_sysroot "${_libc}" DIRECTORY)
get_filename_component(_sysroot "${_sysroot}" DIRECTORY)
set(CMAKE_CROSSCOMPILING_EMULATOR "${QEMU_PPC};-L;${_sysroot}")