Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
39 changes: 39 additions & 0 deletions test/parallel_make.sh
Original file line number Diff line number Diff line change
@@ -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
Loading