Validate the protocol xml during scanning

Embed the wayland.dtd protocol data into the scanner binary so we can validate
external protocol files without requiring makefile changes. Hat-tip to Pekka
Paalanen for the embedding trick.
The embedding trick doesn't work well if the to-be-embedded file is in a
different location than the source file, so copy/link it during configure and
then build it in from the local directory.

The current expat parser is not a validating parser, moving scanner.c to
another parser has the risk of breaking compatibility. This patch adds libxml2
as extra (optional) dependency, but that also requires parsing the input
twice.

If the protocol fails validation a warning is printed but no error is returned
otherwise.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Peter Hutterer 2015-11-10 09:53:08 +10:00 committed by Pekka Paalanen
parent e65aed4616
commit f66e2d53dd
4 changed files with 132 additions and 3 deletions

View file

@ -23,11 +23,16 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA =
bin_PROGRAMS = wayland-scanner
wayland_scanner_SOURCES = src/scanner.c
wayland_scanner_CFLAGS = $(EXPAT_CFLAGS) $(AM_CFLAGS)
wayland_scanner_LDADD = $(EXPAT_LIBS) libwayland-util.la
wayland_scanner_SOURCES = src/scanner.c src/dtddata.S
wayland_scanner_CFLAGS = $(EXPAT_CFLAGS) $(LIBXML_CFLAGS) $(AM_CFLAGS)
wayland_scanner_LDADD = $(EXPAT_LIBS) $(LIBXML_LIBS) libwayland-util.la
pkgconfig_DATA += src/wayland-scanner.pc
src/dtddata.o: protocol/wayland.dtd
%.o: %.S
$(AM_V_GEN)$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_MACH) -c -o $@ $<
if USE_HOST_SCANNER
wayland_scanner = wayland-scanner
else