Skip to content

Commit

Permalink
various vpath and distcheck fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flammie committed Apr 3, 2023
1 parent fe5a74b commit ee63ec8
Show file tree
Hide file tree
Showing 26 changed files with 424 additions and 87 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ dnl ===========================
dnl Create the files from .in's
dnl ===========================

AC_CONFIG_LINKS([src/errors.dtd:src/errors.dtd])
AC_CONFIG_LINKS([src/pipespec.dtd:src/pipespec.dtd])

AC_CONFIG_FILES([src/divvun-gen-xmlschemas], [chmod +x src/divvun-gen-xmlschemas])
AC_CONFIG_FILES([src/divvun-validate-suggest], [chmod +x src/divvun-validate-suggest])
AC_CONFIG_FILES([src/divvun-validate-pipespec], [chmod +x src/divvun-validate-pipespec])
Expand Down
15 changes: 8 additions & 7 deletions python/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
SWIG_INTERFACE = libdivvun.i
SWIG_INTERFACE=libdivvun.i

EXTRA_DIST = libdivvun.i std_unique_ptr.i setup.py
EXTRA_DIST=libdivvun.i std_unique_ptr.i setup.py mac-libreoffice-workaround
noinst_SCRIPTS=mac-libreoffice-workaround

BUILT_SOURCES = libdivvun_wrap.cpp libdivvun.py
CLEANFILES = $(BUILT_SOURCES)
BUILT_SOURCES=libdivvun_wrap.cpp libdivvun.py
CLEANFILES=$(BUILT_SOURCES)

all-local: $(BUILT_SOURCES)
@./mac-libreoffice-workaround
@$(srcdir)/mac-libreoffice-workaround

%_wrap.cpp %.py: %.i setup.py std_unique_ptr.i ../src/libdivvun.la
$(SWIG) -c++ -python -I$(top_srcdir)/src/lib -o $*_wrap.cpp -outdir . $(srcdir)/$*.i
Expand All @@ -21,8 +22,8 @@ uninstall-local:
rm -f $(DESTDIR)$(libdir)/python*/site-packages/_libdivvun.*.so
rm -f $(DESTDIR)$(libdir)/python*/site-packages/libdivvun.py
rm -f $(DESTDIR)$(libdir)/python*/site-packages/__pycache__/libdivvun.*.pyc
rm -f $(DESTDIR)$(libdir)/python*/site-packages/python_$(PACKAGE)-*.egg-info
rm -rf $(DESTDIR)$(libdir)/python*/site-packages/python_*.egg-info

clean-local:
rm -rf build __pycache__
rm -rf build __pycache__ dist python_*.egg-info

15 changes: 10 additions & 5 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
datadir = $(prefix)/share/divvun-gramcheck
AM_CPPFLAGS = -DPREFIX="\"$(prefix)\""

noinst_HEADERS=util.hpp hfst_util.hpp json.hpp \
utf8.h utf8/checked.h utf8/core.h utf8/unchecked.h \
mapbox/variant.hpp mapbox/recursive_wrapper.hpp \
mapbox/variant_visitor.hpp \
cxxopts.hpp
# divvun-suggest binary:
divvun_suggest_SOURCES = main_suggest.cpp suggest.cpp
divvun_suggest_SOURCES = main_suggest.cpp suggest.cpp suggest.hpp
divvun_suggest_LDADD = $(HFST_LIBS) $(PUGIXML_LIBS)
divvun_suggest_CXXFLAGS = $(HFST_CFLAGS) $(PUGIXML_CFLAGS)
bin_PROGRAMS = divvun-suggest
dist_man_MANS = divvun-suggest.1

if HAVE_LIBPUGIXML
# divvun-gen-sh binary
divvun_gen_sh_SOURCES = main_gen_sh.cpp pipespec.cpp
divvun_gen_sh_SOURCES = main_gen_sh.cpp pipespec.cpp pipespec.hpp
divvun_gen_sh_LDADD = $(PUGIXML_LIBS) $(LIBARCHIVE_LIBS)
divvun_gen_sh_CXXFLAGS = $(PUGIXML_CFLAGS) $(LIBARCHIVE_CFLAGS)
bin_PROGRAMS += divvun-gen-sh
Expand All @@ -26,15 +31,15 @@ EXTRA_DIST = errors.dtd errors.rnc pipespec.dtd pipespec.rnc
# We make pipespec-stuff even if --disable-checker; it doesn't add to dependencies

# divvun-blanktag binary:
divvun_blanktag_SOURCES = main_blanktag.cpp blanktag.cpp
divvun_blanktag_SOURCES = main_blanktag.cpp blanktag.cpp blanktag.hpp
divvun_blanktag_LDADD = $(HFST_LIBS)
divvun_blanktag_CXXFLAGS = $(HFST_CFLAGS)
bin_PROGRAMS += divvun-blanktag
dist_man_MANS += divvun-blanktag.1

if HAVE_CGSPELL
# divvun-cgspell binary:
divvun_cgspell_SOURCES = main_cgspell.cpp cgspell.cpp
divvun_cgspell_SOURCES = main_cgspell.cpp cgspell.cpp cgspell.hpp
divvun_cgspell_LDADD = $(HFSTOSPELL_LIBS)
divvun_cgspell_CXXFLAGS = $(HFSTOSPELL_CFLAGS)
bin_PROGRAMS += divvun-cgspell
Expand All @@ -61,7 +66,7 @@ bin_PROGRAMS += divvun-checker
dist_man_MANS += divvun-checker.1

# divvun-checker binary:
divvun_checker_SOURCES = main_checker.cpp
divvun_checker_SOURCES = main_checker.cpp pipeline.hpp normaliser.hpp phon.hpp
divvun_checker_LDADD = libdivvun.la $(libdivvun_la_LIBADD)
divvun_checker_CXXFLAGS = $(libdivvun_la_CXXFLAGS)
divvun_checkerdir = $(datadir)
Expand Down
8 changes: 4 additions & 4 deletions src/divvun-validate-pipespec.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ fi
# dir as this script; otherwise assume we're installed:
d=$(dirname "$0")
if [ "$0" != "@prefix@/bin/divvun-validate-pipespec" ] && [ -e "$d"/pipespec.dtd ]; then
dir="$d"
else
dir=@prefix@/share/divvun-gramcheck
dtd="$d"/pipespec.dtd
elif [ -e "@prefix@/share/divvun-gramcheck/pipespec.dtd" ] ; then
dtd=@prefix@/share/divvun-gramcheck/pipespec.dtd
fi

/usr/bin/xmllint --dtdvalid "${dir}"/pipespec.dtd --noout "${file}"
/usr/bin/xmllint --dtdvalid "${dtd}" --noout "${file}"

if default=$(/usr/bin/xmllint --xpath "/pipespec/@default-pipe" "${file}" 2>/dev/null); then
defaultval="${default##*=}"
Expand Down
9 changes: 6 additions & 3 deletions src/divvun-validate-suggest.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ fi
# dir as this script; otherwise assume we're installed:
d=$(dirname "$0")
if [ "$0" != "@prefix@/bin/divvun-validate-suggest" ] && [ -e "$d"/errors.dtd ]; then
dir="$d"
dtd="$d"/errors.dtd
elif [ -e @prefix@/share/divvun-gramcheck/errors.dtd ] ; then
dtd=@prefix@/share/divvun-gramcheck/errors.dtd
else
dir=@prefix@/share/divvun-gramcheck
echo "cannot find errors.dtd in $d or @prefix@/share/divvun-gramcheck"
exit 1
fi

/usr/bin/xmllint --dtdvalid "${dir}"/errors.dtd --noout "${file}"
/usr/bin/xmllint --dtdvalid "${dtd}" --noout "${file}"
13 changes: 10 additions & 3 deletions test/blanktag/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
hfst-fst2fst -O -i $@.tmp -o $@
rm $@.tmp

check_DATA = blanktagger.hfst
TESTS = ./run
EXTRA_DIST=run \
blanktagger.xfst \
expected.cg \
expected.ends.cg \
input.cg \
input.ends.cg
check_DATA=blanktagger.hfst
TESTS=run

CLEANFILES = $(check_DATA)
CLEANFILES=blanktagger.hfst \
output.cg output.ends.cg

test: check
14 changes: 9 additions & 5 deletions test/blanktag/run
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo "run this from make check or set srcdir=."
exit 1
fi
set -e -u

cd "$(dirname "$0")"
#cd "$(dirname "$0")"

../../src/divvun-blanktag blanktagger.hfst < input.cg > output.cg
../../src/divvun-blanktag blanktagger.hfst < "$srcdir"/input.cg > output.cg

diff expected.cg output.cg
diff "$srcdir"/expected.cg output.cg

../../src/divvun-blanktag blanktagger.hfst < input.ends.cg > output.ends.cg
../../src/divvun-blanktag blanktagger.hfst < "$srcdir"/input.ends.cg > output.ends.cg

diff expected.ends.cg output.ends.cg
diff "$srcdir"/expected.ends.cg output.ends.cg
22 changes: 18 additions & 4 deletions test/cgspell/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@
%.hfst: %.invhfst
hfst-invert -i $< -o $@

check_DATA = analyser.hfstol
TESTS = ./run.default ./run.X ./run.n2 ./run.skip ./run.flush
EXTRA_DIST=run.default run.X run.n2 run.skip run.flush run \
analyser.lexc \
errmodel.hfst \
expected.default \
expected.flush \
expected.n2 \
expected.skip \
expected.X \
input.default \
input.flush \
input.n2 \
input.skip \
input.X
check_DATA=analyser.hfstol errmodel.hfst
TESTS=run.default run.X run.n2 run.skip run.flush

CLEANFILES = $(check_DATA) analyser.hfst analyser.invhfst
CLEANFILES=analyser.hfst analyser.hfstol analyser.invhfst \
output.n2 output.X output.default output.flush output.skip

test: check
est: check
14 changes: 10 additions & 4 deletions test/cgspell/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi

set -e
if [[ ${BASH_VERSINFO[0]} -gt 4
|| ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4 ]]; then
Expand All @@ -9,19 +14,20 @@ if [[ ${BASH_VERSINFO[0]} -gt 4
# throw an unbound variable error; so don't -u there
fi

cd "$(dirname "$0")"/../..
#cd "$(dirname "$0")"/../.

check () {
local -r n="$1"
shift
local -ra args=( "$@" )

(
cd test/cgspell
#cd test/cgspell
set -x
../../src/divvun-cgspell -l analyser.hfstol -m errmodel.hfst "${args[@]}" < input."$n" > output."$n"
../../src/divvun-cgspell -l analyser.hfstol -m "$srcdir"/errmodel.hfst \
"${args[@]}" < "$srcdir"/input."$n" > output."$n"
)
if ! diff test/cgspell/output."$n" test/cgspell/expected."$n"; then
if ! diff output."$n" "$srcdir"/expected."$n"; then
echo diff test/cgspell/output."$n" test/cgspell/expected."$n"
exit 1
fi
Expand Down
7 changes: 6 additions & 1 deletion test/cgspell/run.X
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi

set -e -u

./run X -X
"$srcdir"/run X -X
6 changes: 5 additions & 1 deletion test/cgspell/run.default
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi
set -e -u

./run default
"$srcdir"/run default
6 changes: 5 additions & 1 deletion test/cgspell/run.flush
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi
set -e -u

./run flush
"$srcdir"/run flush
7 changes: 6 additions & 1 deletion test/cgspell/run.n2
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi

set -e -u

./run n2 -n 2
"$srcdir"/run n2 -n 2
7 changes: 6 additions & 1 deletion test/cgspell/run.skip
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo call this from make check or set srcdir=.
exit 1
fi

set -e -u

./run skip
"$srcdir"/run skip
34 changes: 26 additions & 8 deletions test/checker/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
sme.zcheck: pipespec.xml tokeniser.pmhfst valency.cg3 mwe-dis.cg3 disambiguator.cg3 grammarchecker.cg3 generator.hfstol errors.xml acceptor.hfstol errmodel.hfst blanktagger.hfst

EXTRA_DIST=run.xml run.archive run.spell run.workingdir run-lib run \
pipespec.xml tokeniser.pmscript analyser.lexc \
blanktagger.xfst \
valency.cg3 mwe-dis.cg3 disambiguator.cg3 grammarchecker.cg3 \
test-python-bindings.py \
input.xml.txt input.archive.txt input.spell.txt \
expected.xml.json expected.archive.json expected.spell.json

sme.zcheck: pipespec.xml tokeniser.pmhfst valency.cg3 mwe-dis.cg3 \
disambiguator.cg3 grammarchecker.cg3 generator.hfstol \
errors.xml acceptor.hfstol errmodel.hfst blanktagger.hfst
rm -f $@
zip $@ $^
zip -j $@ $^
-cp $^ .

tokeniser.pmhfst: tokeniser.pmscript analyser.hfst
hfst-pmatch2fst <$< >$@.tmp
Expand Down Expand Up @@ -28,20 +40,26 @@ blanktagger.hfst: blanktagger.xfst
hfst-fst2fst -O -i $@.tmp -o $@
rm $@.tmp

check_DATA = sme.zcheck tokeniser.pmhfst generator.hfstol errors.xml blanktagger.hfst
check_DATA=sme.zcheck tokeniser.pmhfst generator.hfstol errors.xml blanktagger.hfst

if HAVE_CGSPELL
TESTS = ./run.xml ./run.archive ./run.spell ./run.workingdir
TESTS=run.xml run.archive run.spell run.workingdir
if HAVE_PYTHON_BINDINGS
TESTS += ./run-python-bindings
TESTS+=run-python-bindings
endif # HAVE_PYTHON_BINDINGS
# Keep the slowest one last:
TESTS += ./run-lib
TESTS+=run-lib
else
TESTS = ./run.nospell-xml ./run.nospell-archive
TESTS=run.nospell-xml run.nospell-archive
endif # HAVE_CGSPELL

CLEANFILES = $(check_DATA) analyser.hfst generator.hfstol errors.xml acceptor.hfstol errmodel.hfst
CLEANFILES=sme.zcheck tokeniser.pmhfst generator.hfstol errors.xml \
blanktagger.hfst analyser.hfst generator.hfstol \
acceptor.hfstol errmodel.hfst \
grammarchecker.cg3 valency.cg3 mwe-dis.cg3 disambiguator.cg3 \
pipespec.xml \
output.spell.json output.archive.json output.xml.json \
output.workingdir.json
clean-local:
rm -rf python-build

Expand Down
15 changes: 10 additions & 5 deletions test/checker/run
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" -o -z "$builddir" ; then
echo run from make check or set srcdir=. builddir=.
exit 1
fi

set -e
if [[ ${BASH_VERSINFO[0]} -gt 4
|| ${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4 ]]; then
Expand All @@ -9,19 +14,19 @@ if [[ ${BASH_VERSINFO[0]} -gt 4
# throw an unbound variable error; so don't -u there
fi

cd "$(dirname "$0")"/../..
#cd "$(dirname "$0")"/../..

check () {
local -r n="$1"
shift
local -ra args=( "$@" )
src/divvun-validate-pipespec test/checker/pipespec.xml
../../src/divvun-validate-pipespec "$srcdir"/pipespec.xml
(
cd test/checker
#cd test/checker
set -x
../../src/divvun-checker "${args[@]}" < input."$n".txt > output."$n".json
../../src/divvun-checker "${args[@]}" < "$srcdir"/input."$n".txt > "$builddir"/output."$n".json
)
if ! diff test/checker/output."$n".json test/checker/expected."$n".json; then
if ! diff "$builddir"/output."$n".json "$srcdir"/expected."$n".json; then
echo diff test/checker/output."$n".json test/checker/expected."$n".json
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion test/checker/run-python-bindings.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ if [[ $TRAVIS_OS_NAME = osx || "$(uname)" = Darwin ]]; then
)
fi

"@PYTHON@" test-python-bindings.py
"@PYTHON@" "$srcdir"/test-python-bindings.py
7 changes: 6 additions & 1 deletion test/checker/run.archive
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash

if test -z "$srcdir" ; then
echo run this from make check or set srcdir=.
exit 1
fi

set -e -u

./run archive -a sme.zcheck -n smegram
builddir=$(pwd) "$srcdir"/run archive -a sme.zcheck -n smegram
Loading

0 comments on commit ee63ec8

Please sign in to comment.