playground/devtools/kdevelop4-extra-plugins/python/parser
Andreas Pakulat
apaku at gmx.de
Wed Jul 11 12:16:31 CEST 2007
On 10.07.07 22:01:30, Alexander Neundorf wrote:
> On Tuesday 10 July 2007 16:08, Andreas Pakulat wrote:
> ...
> > I think the macro I came up with causes a full rebuild of the project
> > using it when touching any of the CMakeLists.txt.
> >
> > An example is playground/devtools/kdevelop4-extra-plugins/ruby
> >
> > if I touch tests/CMakeLists.txt the whole project is rebuilt, the
> > generated and non-generated files are all recompiled.
> >
> > The macro I use looks like this:
> > macro(GET_GENERATED_SRCS _srcsList)
> > if(KDEVPG_FOUND AND FLEX_FOUND)
> > include_directories(${KDEVPG_INCLUDE_DIR})
> > kdevpg_generate(_kdevpgList ruby DEBUG_VISITOR
> > "${CMAKE_SOURCE_DIR}/parser/ruby.g"
> > "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.h")
> >
> > # Copy ruby_lexer.ll to the builddir, so that flex doesn't write
> > out # absolute paths in the generated file when we pass them as arguments.
> > # In short, I don't want stuff like
> > # '#line 2 "/home/kde/build/.../ruby_lexer.cpp" in SVN.
> > add_custom_command(
> > OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
> > MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.ll"
> > COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
> > "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.ll"
> > "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
> > )
> > # Add command to generate the lexer.
> > add_custom_command(
> > OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.cpp"
> > MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.ll"
> > DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/ruby_parser.h"
> > "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.h"
> > COMMAND ${FLEX_EXECUTABLE}
> > ARGS -o"ruby_lexer.cpp"
> > "ruby_lexer.ll"
> > WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> > )
> > set(${_srcsList} ${_kdevpgList}
> > "${CMAKE_CURRENT_BINARY_DIR}/ruby_lexer.cpp") else(KDEVPG_FOUND AND
> > FLEX_FOUND)
> > include_directories(${CMAKE_SOURCE_DIR}/parser/generated)
> > message(STATUS "Assuming existence of generated parser files")
> > message( STATUS "Assuming existence of generated lexer files")
> > set(${_srcsList}
> > ${CMAKE_SOURCE_DIR}/parser/generated/ruby_parser.cpp
> > ${CMAKE_SOURCE_DIR}/parser/generated/ruby_visitor.cpp
> > ${CMAKE_SOURCE_DIR}/parser/generated/ruby_default_visitor.cpp
> > ${CMAKE_SOURCE_DIR}/parser/generated/ruby_lexer.cpp )
> >
> > endif(KDEVPG_FOUND AND FLEX_FOUND)
> > endmacro(GET_GENERATED_SRCS)
>
> Ok, not sure what is causing this.
btw, I only need to run make, not even touching anything to make it do a
full rebuild.
> You should be able to merge the two add_custom_command()s into one as below:
>
> macro(GET_GENERATED_SRCS _srcsList)
> if(KDEVPG_FOUND AND FLEX_FOUND)
> include_directories(${KDEVPG_INCLUDE_DIR})
> kdevpg_generate(_kdevpgList ruby DEBUG_VISITOR
> "${CMAKE_SOURCE_DIR}/parser/ruby.g"
> "${CMAKE_SOURCE_DIR}/parser/ruby_lexer.h")
It turns out the problem is this macro: kdevpg_generate and it also
turns out that I'm too stupid to run make install/fast after fixing an
error. So the reason is the macro looks like this (in the install dir):
macro(KDEVPG_GENERATE _srcVar _language )
set(_depList ${ARGN})
list(GET _depList 0 _ns)
set(_namespace ${ARGV1})
if( ${_ns} STREQUAL "NAMESPACE" )
list(GET _depList 1 _namespace)
list(REMOVE_AT _depList 0 1)
endif( ${_ns} STREQUAL "NAMESPACE" )
list(GET _depList 0 _dbg)
set(_dbgVisit)
if( ${_dbg} STREQUAL "DEBUG_VISITOR" )
list(REMOVE_AT _depList 0)
set(_dbgVisit "--debug-visitor")
endif(${_dbg} STREQUAL "DEBUG_VISITOR" )
list(GET _depList 0 _grammarFile)
list(REMOVE_AT _depList 0)
if(NOT _grammarFile)
message(ERROR "No grammar file given to KDEVPG_GENERATE macro")
endif(NOT _grammarFile)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_language}_ast.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_parser.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_visitor.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_visitor.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_default_visitor.h"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_default_visitor.cpp"
MAIN-DEPENDENCY "${_grammarFile}"
!!!! #^^^ Note that this is not an underscore as it should be
DEPENDS ${_depList}
COMMAND ${KDEVPG_EXECUTABLE}
ARGS --output=${_language} --namespace=${_namespace}
${_dbgVisit} "${_grammarFile}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
set( ${_srcVar}
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_parser.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_visitor.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${_language}_default_visitor.cpp" )
endmacro(KDEVPG_GENERATE)
Which results in Makefile rules like this:
+/home/andreas/KDE-work/4.0/kdevelop4-extra-plugins/python/MAIN-DEPENDECY: python_ast.h
+
+/home/andreas/KDE-work/4.0/kdevelop4-extra-plugins/python/parser/python.g: python_ast.h
If you want I can send you the full diff of with and without - instead
of _
Andreas
--
You attempt things that you do not even plan because of your extreme stupidity.
More information about the Kde-buildsystem
mailing list