From 27ef04f95320d2205a9b6b3aa30fa206fb1ef438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=99=E5=B0=89=E6=81=92?= <174832469+hengweiyv@users.noreply.github.com> Date: Sat, 3 Oct 2026 22:02:05 +0800 Subject: [PATCH] Schedule shared Unicode data downloads before recursive makes --- Makefile | 17 ++++++++++++----- test/parallel_make.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 test/parallel_make.sh diff --git a/Makefile b/Makefile index 76a11e4..9bb2085 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ pkgincludedir=$(includedir:$(prefix)/%=%) # meta targets -.PHONY: all clean data update manifest install test_install_uninstall +.PHONY: all clean data update manifest install test_install_uninstall test_parallel_make all: libutf8proc.a libutf8proc.$(SHLIB_EXT) @@ -73,7 +73,7 @@ manifest: MANIFEST.new # real targets -data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.jl +data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.jl data/DerivedCoreProperties.txt $(MAKE) -C data utf8proc_data.c.new utf8proc.o: utf8proc.h utf8proc.c utf8proc_data.c @@ -141,10 +141,14 @@ data/NormalizationTest.txt: data/GraphemeBreakTest.txt: $(MAKE) -C data GraphemeBreakTest.txt -data/Lowercase.txt: +# These recursive makes share a download; schedule it only once at this level. +data/DerivedCoreProperties.txt: + $(MAKE) -C data DerivedCoreProperties.txt + +data/Lowercase.txt: data/DerivedCoreProperties.txt $(MAKE) -C data Lowercase.txt -data/Uppercase.txt: +data/Uppercase.txt: data/DerivedCoreProperties.txt $(MAKE) -C data Uppercase.txt test/tests.o: test/tests.c test/tests.h utf8proc.h @@ -186,6 +190,9 @@ test/maxdecomposition: test/maxdecomposition.c test/tests.o utf8proc.o utf8proc. test_install_uninstall: manifest ./test/install_uninstall.sh +test_parallel_make: + $(SHELL) test/parallel_make.sh + # make release tarball from master branch dist: git archive master --prefix=utf8proc-$(VERSION)/ -o utf8proc-$(VERSION).tar.gz @@ -201,7 +208,7 @@ distcheck: dist make -C utf8proc-$(VERSION) check rm -rf utf8proc-$(VERSION) -check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/maxdecomposition test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o test_install_uninstall +check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/maxdecomposition test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o test_install_uninstall test_parallel_make $(MAKE) -C bench test/normtest data/NormalizationTest.txt test/graphemetest data/GraphemeBreakTest.txt diff --git a/test/parallel_make.sh b/test/parallel_make.sh new file mode 100644 index 0000000..5c224c5 --- /dev/null +++ b/test/parallel_make.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# The casing test data share a downloaded prerequisite. Recursive makes must +# not download it twice when these targets are requested in parallel. +set -eu + +scratch=$(mktemp -d) +trap 'rm -rf "$scratch"' EXIT HUP INT TERM +mkdir "$scratch/data" +cp Makefile "$scratch/Makefile" +cp data/Makefile "$scratch/data/Makefile" + +cat > "$scratch/curl" <<'EOF' +#!/bin/sh +set -eu +while [ "$1" != '-o' ]; do shift; done +shift +printf '%s\n' "$1" >> ../downloads.log +sleep 0.1 +printf 'complete\n' > "$1" +EOF + +cat > "$scratch/julia" <<'EOF' +#!/bin/sh +set -eu +test "$(cat DerivedCoreProperties.txt)" = complete +printf 'generated\n' +EOF +chmod +x "$scratch/curl" "$scratch/julia" + +MAKEFLAGS= MFLAGS= ${MAKE:-make} -C "$scratch" -j8 data/Lowercase.txt data/Uppercase.txt \ + CURL="$scratch/curl" JULIA="$scratch/julia" + +downloads=$(wc -l < "$scratch/downloads.log") +test "$downloads" -eq 1 || { + echo "Expected one shared data download, got $downloads" >&2 + exit 1 +} +test "$(cat "$scratch/data/Lowercase.txt")" = generated +test "$(cat "$scratch/data/Uppercase.txt")" = generated