diff --git a/mkspecs/features/exclusive_builds.prf b/mkspecs/features/exclusive_builds.prf index b4788e1c2f..b28e74146a 100644 --- a/mkspecs/features/exclusive_builds.prf +++ b/mkspecs/features/exclusive_builds.prf @@ -38,5 +38,5 @@ defineTest(addExclusiveBuilds) { } # Default directories to process -QMAKE_DIR_REPLACE_SANE += QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR +QMAKE_DIR_REPLACE_SANE += QGLTF_DIR TRACEGEN_DIR QMLCACHE_DIR LRELEASE_DIR LEX_DIR YACC_DIR QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR DESTDIR $$QMAKE_DIR_REPLACE_SANE diff --git a/mkspecs/features/lex.prf b/mkspecs/features/lex.prf index 7d8325bedb..ee06215103 100644 --- a/mkspecs/features/lex.prf +++ b/mkspecs/features/lex.prf @@ -2,6 +2,38 @@ # Lex extra-compiler for handling files specified in the LEXSOURCES variable # +isEmpty(LEX_DIR): LEX_DIR = . + +defineReplace(lexCommands) { + input = $$relative_path($$absolute_path($$1, $$OUT_PWD), $$OUT_PWD/$$LEX_DIR) + output = $$basename(2) + input_base = $$basename(1) + input_base ~= s/\.[^.]*$// + + isEmpty(QMAKE_LEXFLAGS_MANGLE): QMAKE_LEXFLAGS_MANGLE = -P$${input_base} + QMAKE_LEXEXTRAFLAGS = $$QMAKE_LEXFLAGS + !yacc_no_name_mangle: QMAKE_LEXEXTRAFLAGS += $$QMAKE_LEXFLAGS_MANGLE + + contains(QMAKE_LEX, .*flex) { + # GNU flex, we can use -o outfile + commands = $$QMAKE_LEX $$QMAKE_LEXEXTRAFLAGS --nounistd -o $$output $$input + } else { + # stupid POSIX lex, it only generates a file called lex.yy.c + # or lex.prefix.c if the -P option is active + intermediate_file = lex.yy.c + QMAKE_LEXEXTRAFLAGS = $$QMAKE_LEXFLAGS $$QMAKE_LEXFLAGS_MANGLE + + commands = \ + -$(DEL_FILE) $${output}$$escape_expand(\\n\\t) \ + $$QMAKE_LEX $$QMAKE_LEXEXTRAFLAGS $${input}$$escape_expand(\\n\\t) \ + $(MOVE) $$intermediate_file $$output $$escape_expand(\\n\\t) + } + !equals(LEX_DIR, .): \ + commands = cd $$LEX_DIR && $$commands + silent: commands = @echo Lex $$1 && $$commands + return($$commands) +} + { lex.name = Lex ${QMAKE_FILE_IN} lex.input = LEXSOURCES @@ -12,27 +44,7 @@ lex.variable_out = GENERATED_SOURCES } - isEmpty(QMAKE_LEXFLAGS_MANGLE):QMAKE_LEXFLAGS_MANGLE = -P${QMAKE_FILE_BASE} - QMAKE_LEXEXTRAFLAGS = $$QMAKE_LEXFLAGS - !yacc_no_name_mangle:QMAKE_LEXEXTRAFLAGS += $$QMAKE_LEXFLAGS_MANGLE - - contains(QMAKE_LEX, .*flex) { - # GNU flex, we can use -o outfile - lex.commands = $$QMAKE_LEX $$QMAKE_LEXEXTRAFLAGS --nounistd -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} - } else { - # stupid POSIX lex, it only generates a file called lex.yy.c - # or lex.prefix.c if the -P option is active - intermediate_file = lex.yy.c - QMAKE_LEXEXTRAFLAGS = $$QMAKE_LEXFLAGS $$QMAKE_LEXFLAGS_MANGLE - - lex.commands = \ - -$(DEL_FILE) ${QMAKE_FILE_OUT}$$escape_expand(\\n\\t) \ - $$QMAKE_LEX $$QMAKE_LEXEXTRAFLAGS ${QMAKE_FILE_IN}$$escape_expand(\\n\\t) \ - $(MOVE) $$intermediate_file ${QMAKE_FILE_OUT} $$escape_expand(\\n\\t) - unset(intermediate_file) - } - lex.output = $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_LEX}$${first(QMAKE_EXT_CPP)} - - silent:lex.commands = @echo Lex ${QMAKE_FILE_IN} && $$lex.commands + lex.commands = ${QMAKE_FUNC_lexCommands} + lex.output = $$LEX_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_LEX}$${first(QMAKE_EXT_CPP)} QMAKE_EXTRA_COMPILERS += lex } diff --git a/mkspecs/features/yacc.prf b/mkspecs/features/yacc.prf index 618f0668c2..0c7ff7321e 100644 --- a/mkspecs/features/yacc.prf +++ b/mkspecs/features/yacc.prf @@ -2,32 +2,49 @@ # Yacc extra-compiler for handling files specified in the YACCSOURCES variable # +isEmpty(YACC_DIR): YACC_DIR = . + +defineReplace(yaccCommands) { + input = $$relative_path($$absolute_path($$1, $$OUT_PWD), $$OUT_PWD/$$YACC_DIR) + input_base = $$basename(1) + input_base ~= s/\.[^.]*$// + hpp_output = $$2 + cpp_output = $$hpp_output + cpp_output ~= s/$$re_escape($$first(QMAKE_EXT_H))$/$$first(QMAKE_EXT_CPP)/ + + isEmpty(QMAKE_YACCFLAGS_MANGLE) { + QMAKE_YACCFLAGS_MANGLE = -p $${input_base} -b $${input_base} + QMAKE_YACC_HEADER = $${input_base}.tab.h + QMAKE_YACC_SOURCE = $${input_base}.tab.c + } else { + QMAKE_YACCFLAGS_MANGLE ~= s/\\$base/$${input_base}/g #backwards compat + QMAKE_YACC_HEADER ~= s/\\$base/$${input_base}/g + QMAKE_YACC_SOURCE ~= s/\\$base/$${input_base}/g + } + QMAKE_YACCDECLFLAGS = $$QMAKE_YACCFLAGS + !yacc_no_name_mangle: QMAKE_YACCDECLFLAGS += $$QMAKE_YACCFLAGS_MANGLE + + !equals(YACC_DIR, .): yacc_call = cd $$YACC_DIR && + yacc_call += $$QMAKE_YACC $$QMAKE_YACCDECLFLAGS $${input} + + commands = \ + -$(DEL_FILE) $${hpp_output} $${cpp_output}$$escape_expand(\\n\\t) \ + $${yacc_call}$$escape_expand(\\n\\t) \ + $(MOVE) $${YACC_DIR}/$${QMAKE_YACC_HEADER} $${hpp_output}$$escape_expand(\\n\\t) \ + $(MOVE) $${YACC_DIR}/$${QMAKE_YACC_SOURCE} $${cpp_output}$$escape_expand(\\n\\t) + + silent: commands = @echo Yacc $$1 && $$commands + return($$commands) +} + +yacc_output_base = $${YACC_DIR}/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC} + { yacc_decl.name = Yacc header yacc_decl.input = YACCSOURCES yacc_decl.variable_out = GENERATED_FILES - - - isEmpty(QMAKE_YACCFLAGS_MANGLE) { - QMAKE_YACCFLAGS_MANGLE = -p ${QMAKE_FILE_BASE} -b ${QMAKE_FILE_BASE} - QMAKE_YACC_HEADER = ${QMAKE_FILE_BASE}.tab.h - QMAKE_YACC_SOURCE = ${QMAKE_FILE_BASE}.tab.c - } else { - QMAKE_YACCFLAGS_MANGLE ~= s/\\$base/${QMAKE_FILE_BASE}/g #backwards compat - QMAKE_YACC_HEADER ~= s/\\$base/${QMAKE_FILE_BASE}/g - QMAKE_YACC_SOURCE ~= s/\\$base/${QMAKE_FILE_BASE}/g - } - QMAKE_YACCDECLFLAGS = $$QMAKE_YACCFLAGS - !yacc_no_name_mangle:QMAKE_YACCDECLFLAGS += $$QMAKE_YACCFLAGS_MANGLE - - yacc_decl.commands = \ - -$(DEL_FILE) $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_H)} $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_CPP)}$$escape_expand(\\n\\t) \ - $$QMAKE_YACC $$QMAKE_YACCDECLFLAGS ${QMAKE_FILE_IN}$$escape_expand(\\n\\t) \ - $(MOVE) $${QMAKE_YACC_HEADER} $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_H)}$$escape_expand(\\n\\t) \ - $(MOVE) $${QMAKE_YACC_SOURCE} $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_CPP)}$$escape_expand(\\n\\t) - yacc_decl.output = $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_H)} - - silent:yacc_decl.commands = @echo Yacc ${QMAKE_FILE_IN} && $$yacc_decl.commands + yacc_decl.commands = ${QMAKE_FUNC_yaccCommands} + yacc_decl.output = $${yacc_output_base}$$first(QMAKE_EXT_H) QMAKE_EXTRA_COMPILERS += yacc_decl } @@ -37,7 +54,9 @@ yacc_impl.variable_out = GENERATED_SOURCES yacc_impl.dependency_type = TYPE_C yacc_impl.commands = $$escape_expand(\\n) # We don't want any commands where, but if command is empty no rules are created - yacc_impl.depends += $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_H)} # Make sure we depend on the step above - yacc_impl.output = $${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_MOD_YACC}$${first(QMAKE_EXT_CPP)} # Faked output from this step, output really created in step above + yacc_impl.depends += $${yacc_output_base}$$first(QMAKE_EXT_H) # Make sure we depend on the step above + yacc_impl.output = $${yacc_output_base}$$first(QMAKE_EXT_CPP) # Faked output from this step, output really created in step above QMAKE_EXTRA_COMPILERS += yacc_impl } + +unset(yacc_output_base)