gettext-extract: fix race condition

Multiple gettext-extraction proc macro instances can run at the same
time due to Rust's compilation model. In the previous implementation,
where every instance appended to the same file, this has resulted in
corruption of the file. This was reported and discussed in
https://github.com/fish-shell/fish-shell/pull/11928#discussion_r2488047964
for the equivalent macro for Fluent message ID extraction. The
underlying problem is the same.

The best way we have found to avoid such race condition is to write each
entry to a new file, and concatenate them together before using them.
It's not a beautiful approach, but it should be fairly robust and
portable.

Closes #12125
This commit is contained in:
Daniel Rainer
2025-12-01 19:48:02 +01:00
committed by Johannes Altmanninger
parent c1db2744cf
commit 3e2336043a
8 changed files with 36 additions and 29 deletions

View File

@@ -3,7 +3,7 @@
# Compiling in this test is too expensive.
# We need the gettext template extracted from the Rust sources passed in via env var,
# in order to pass it on.
#REQUIRES: test -e "$FISH_GETTEXT_EXTRACTION_FILE"
#REQUIRES: test -e "$FISH_GETTEXT_EXTRACTION_DIR"
set -l dir (status dirname)
@@ -16,5 +16,5 @@ set -lxp PATH (path dirname $fish)
# The `--use-existing-template` argument allows using the pre-built version of the gettext template
# file.
$dir/../../build_tools/update_translations.fish --dry-run \
--use-existing-template=$FISH_GETTEXT_EXTRACTION_FILE
--use-existing-template=$FISH_GETTEXT_EXTRACTION_DIR
or exit 1