Re: Flex, Bison and qmake
I have a quick solution for you. Tell qmake to treat your lex and bison files with a "custom compiler". Take a look at our wiki (the "undocumented qmake" article) and qmake docs to see how to tell qmake about a custom compiler. Then you'll be able to simply tell qmake what exact commands to execute.
A proper solution would be difficult to obtain as qmake assumes you might have more than one lex and yacc parser and modifies the symbols using yacc and lex interfaces to avoid name clashes, so if you don't use them the way qmake wants you to, it might be a bit difficult to adapt. Of course a semi-proper solution is to override some qmake variables which are responsible for all those modifications.
Re: Flex, Bison and qmake
I had a feeling it'll be something like that...
I've tried poking around a bit with it, but couldn't get it to work, It would appear in the makefile, but not under the "all" target...
I'll try it some more tomorrow, as I am not currently at work now :) If there's any other documentation on that feature it would be great to know.
Thanks.
Re: Flex, Bison and qmake
Try something like this (not tested):
Code:
FLEXINPUTS = parser.l
flex_c.output = lex.yy.c
flex_c.input = FLEXINPUTS # it has to be done using a variable
flex_c.commands = flex parser.l
Re: Flex, Bison and qmake
for some reason, that wasn't working too well yesterday when I tried poking at it, but works now...
For the interested, my full qmake project file, at least for this testing app is as follows
Code:
######################################################################
# Automatically generated by qmake (2.00a) Thu Sep 7 15:54:07 2006
######################################################################
TEMPLATE = app
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += parse.h parser.y.h parseTest.h
#LEXSOURCES += parser.l
#YACCSOURCES += parser.y
SOURCES += main.cpp parseTest.cpp
# Flex/bison specifics
#QMAKE_LEX = flex
#QMAKE_YACC = bison
#QMAKE_YACCFLAGS = -d -o y.tab.c
#QMAKE_YACC_HEADER =
#QMAKE_YACC_SOURCE =
FLEXSOURCES = parser.l
BISONSOURCES = parser.y
flex.commands = flex ${QMAKE_FILE_IN}
flex.input = FLEXSOURCES
flex.output = lex.yy.c
flex.variable_out = SOURCES
flex.depends = y.tab.h
flex.name = flex
QMAKE_EXTRA_COMPILERS += flex
bison.commands = bison -d -t -y ${QMAKE_FILE_IN} && mv y.tab.c y.tab.cpp
bison.input = BISONSOURCES
bison.output = y.tab.cpp
bison.variable_out = SOURCES
bison.name = bison
QMAKE_EXTRA_COMPILERS += bison
bisonheader.commands = @true
bisonheader.input = BISONSOURCES
bisonheader.output = y.tab.h
bisonheader.variable_out = HEADERS
bisonheader.name = bison header
bisonheader.depends = y.tab.cpp
QMAKE_EXTRA_COMPILERS += bisonheader
I'll have to add windows and linux-specific definitions for the move command in the bison.commands, but apart from that it works fairly nicely.
Still I'm not sure why it wasn't working yesterday..but's that's not important.
Re: Flex, Bison and qmake
Hi all,
I know it is a very old thread but I used it to implement my bison/flex parser with Qt, at least I tried.
I wrote a .pro file:
Code:
# Flex/bison specifics
FLEXSOURCES = VHDLParser.l
BISONSOURCES = VHDLParser.y
#flex definition
flex.name = Flex
flex.input = FLEXSOURCES
flex.output = ${QMAKE_FILE_BASE}.cpp
flex.commands = flex -i -o${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
#flex.CONFIG += target_predeps
flex.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += flex
#bison definition
bison.name = Bison
bison.input = BISONSOURCES
bison.output = ${QMAKE_FILE_BASE}.cpp
bison.commands = bison -d -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN}
bison.clean = position.hh stack.hh location.hh VHDLParser.hpp
bison.CONFIG += target_predeps
bison.variable_out = SOURCES
QMAKE_EXTRA_COMPILERS += bison
OTHER_FILES += \
$$BISONSOURCES \
$$FLEXSOURCES
But when I build my project, the flex compiler simply doesn't start. I can clearly see bison running in the console but not flex.
Of course, when comes the time to link every object files, it doesn't work beceause yylex() is missing ...
Please tell me what's wrong with this .pro.