Add the collation partition to the build

Includes a small linux-only bash script to generate locale partitions
custom
jacqueline 12 months ago
parent a231fd1c8a
commit 964da15a0b
  1. 7
      CMakeLists.txt
  2. BIN
      tools/collate/Generic.LC_COLLATE
  3. 24
      tools/collate/README.md
  4. 16
      tools/collate/mkcollator.sh

@ -16,10 +16,15 @@ list(APPEND EXTRA_COMPONENT_DIRS "$ENV{PROJ_PATH}/src")
project(tangara)
# 'collate' partition on internal flash. Contains collation data for sorting
# strings across languages (defaults to a generic dataset based on ISO14651).
get_filename_component(collate_full_path "tools/collate/Generic.LC_COLLATE" ABSOLUTE)
esptool_py_flash_to_partition(flash "collate" ${collate_full_path})
# /lua partition on internal flash, for storing the lua application
spiffs_create_partition_image(lua lua FLASH_IN_PROJECT)
# /repl partition on internal flash, for storing the developer repl and its deps.
# /repl partition on internal flash, for storing the developer repl and its deps
file(COPY lib/lua-repl/repl DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/repl)
file(COPY lib/lua-term/term DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/repl)
spiffs_create_partition_image(repl ${CMAKE_CURRENT_BINARY_DIR}/repl FLASH_IN_PROJECT)

Binary file not shown.

@ -0,0 +1,24 @@
This tool, which only works on Linux, uses your system's locale data to
generate a collator partition for Tangara. This partition is uses to sort
database information (album names, etc.) in a way that makes sense to humans.
Because this script isn't portable, `Generic.LC_COLLATE` is included as a
pregenerated collator partition that should work well for most people's
music libraries.
## Partition format
The collator partition has 3MiB reserved for it in the partition table, which
is enough to hold the compiled collation data for ISO14651 character sorting,
plus a small amount of free space.
The first 8 bytes of the partition are reserved for a partition name; usually
the name of the locale that the collation data was compiled for, or 'Generic'
for ISO14651 data.
Following the 8 byte name, is a complete LC_COLLATE file, as generate by GNU
libc's `localedef` utility. Debian's version 2.37 of this utility is known to
work.
FIXME: We should vendor this version of the tool, so that our format remains
stable across glibc changes.

@ -0,0 +1,16 @@
#!/bin/bash
set -eu
if [ -z "${2:-}" ]; then
name="Generic"
locale="iso14651_t1"
else
name="$1"
locale="$2"
fi
working_dir=$(mktemp -d)
echo -n "$name" | dd iflag=fullblock bs=8 count=1 conv=sync of="$working_dir/name"
localedef -f UTF-8 -i "$locale" --no-archive "$working_dir" || true
cat "$working_dir/name" "$working_dir/LC_COLLATE" > "$name.LC_COLLATE"
Loading…
Cancel
Save