From 2dc98de474bf473c25ba57d13abc0eb30a70dec8 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 7 Mar 2013 22:09:22 +0100 Subject: introduce qlalr feature this makes it possible to compile grammars at build time. Change-Id: Ia74383c4f29873ee7324bd5f14d72ef14faef460 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- mkspecs/features/qlalr.prf | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 mkspecs/features/qlalr.prf (limited to 'mkspecs') diff --git a/mkspecs/features/qlalr.prf b/mkspecs/features/qlalr.prf new file mode 100644 index 0000000000..e5e4b87802 --- /dev/null +++ b/mkspecs/features/qlalr.prf @@ -0,0 +1,49 @@ +qtPrepareTool(QMAKE_QLALR, qlalr) + +isEmpty(QLALR_DIR): QLALR_DIR = . + +!isEmpty(QLALRSOURCES) { + INCLUDEPATH += $$absolute_path($$QLALR_DIR, $$OUT_PWD) +} + +for (s, QLALRSOURCES) { + sf = $$absolute_path($$s, $$_PRO_FILE_PWD_) + QMAKE_INTERNAL_INCLUDED_FILES += $$sf + sfl = $$cat($$sf, lines) + parser = $$lower($$member($$list($$find(sfl, "^%parser\\s")), 1)) + isEmpty(parser): error("Could not extract %parser from $$sf") + decl = $$member($$list($$find(sfl, "^%decl\\s")), 1) + isEmpty(decl): error("Could not extract %decl from $$sf") + impl = $$member($$list($$find(sfl, "^%impl\\s")), 1) + isEmpty(impl): error("Could not extract %impl from $$sf") + base = qlalr_$$replace(sf, ^.*/([^./]+)[^/]*$, \\1) + + invar = $$upper($$base)_SOURCES + $$invar = $$sf + $${base}.input = $$invar + $${base}.output = $$QLALR_DIR/$${parser}.cpp + $${base}.variable_out = GENERATED_SOURCES + $${base}.commands = $$QMAKE_QLALR $$QMAKE_QLALRFLAGS ${QMAKE_FILE_IN} + silent: $${base}.commands = @echo qlalr ${QMAKE_FILE_IN} && $${base}.commands + $${base}.name = QLALR ${QMAKE_FILE_IN} + + $${base}_h.input = $$invar + $${base}_h.output = $$QLALR_DIR/$${parser}_p.h + $${base}_h.CONFIG = no_link + $${base}_h.depends = $$QLALR_DIR/$${parser}.cpp + $${base}_h.commands = $$escape_expand(\\n) # force creation of rule + + $${base}_decl.input = $$invar + $${base}_decl.output = $$QLALR_DIR/$${decl} + $${base}_decl.CONFIG = no_link + $${base}_decl.depends = $$QLALR_DIR/$${parser}.cpp + $${base}_decl.commands = $$escape_expand(\\n) # force creation of rule + + $${base}_impl.input = $$invar + $${base}_impl.output = $$QLALR_DIR/$${impl} + $${base}_impl.variable_out = GENERATED_SOURCES + $${base}_impl.depends = $$QLALR_DIR/$${parser}.cpp + $${base}_impl.commands = $$escape_expand(\\n) # force creation of rule + + QMAKE_EXTRA_COMPILERS += $$base $${base}_h $${base}_decl $${base}_impl +} -- cgit v1.2.3