playground/devtools/kdevelop4-extra-plugins/python/parser
Andreas Pakulat
apaku at gmx.de
Tue Jul 10 11:20:46 CEST 2007
On 09.07.07 23:22:23, Alexander Neundorf wrote:
> On Monday 09 July 2007 14:22, Andreas Pakulat wrote:
> > python/parser/CMakeLists.txt with
> >
> > add_executable(python-parser ${foo_SRCS} )
> >
> >
> > Then cmake will complain that it doesn't know how to create the files in
> > foo_SRCS for the python-parser target.
> >
> > And always setting the foo_SRCS GENERATED in the subdirs is not really
> > usable either as they are only generated when you've got the generator
> > tool installed (which is not required). So I'd again need to have
> > if(FOO_FOUND) stuff everywhere.
>
> Can you put the rules for generating the files in the directories where the
> file are used, e.g. with some macros ?
Hmm, can you have a look at the attached file please? Calling the macro
doesn't execute the custom command and thus the files are not generated.
Andreas
--
You shall be rewarded for a dastardly deed.
-------------- next part --------------
#To properly find kdevelop-pg add -DKDEVPG_DATA_DIR=<kdevpg-install-path>/share to the
#cmake run if you installed it in a different directory than this plugin
#TODO: a cmake run is needed after changing one of the CMakeLists.txt, make will
#complain about the FindKDevelop-PG.cmake file not findable.
find_package(KDE4 REQUIRED)
exec_program(kde4-config ARGS --path data OUTPUT_VARIABLE _data_DIR)
file(TO_CMAKE_PATH "${_data_DIR}" _data_DIR)
foreach(dir ${_data_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${dir}/share/cmake/modules)
endforeach(dir)
find_package(KDevPlatform REQUIRED)
find_package(KDevelop-PG)
find_package(Flex)
INCLUDE_DIRECTORIES(
${KDEVPLATFORM_INCLUDE_DIR}/language/interfaces
${KDEVPLATFORM_INCLUDE_DIR}/interfaces
${KDEVPLATFORM_INCLUDE_DIR}/language
${KDEVPLATFORM_INCLUDE_DIR}/language/backgroundparser
${KDE4_INCLUDES}
${KDE4_INCLUDE_DIR}/threadweaver
${CMAKE_CURRENT_BINARY_DIR}
parser
)
set(parser_STAT_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/parser/decoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parser/python_io.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parser/pythondriver.cpp
)
set(parser_SRCS)
set(lexer_SRCS)
macro(GET_PARSER_SRCS _srcsList)
if(KDEVPG_FOUND AND FLEX_FOUND)
include_directories(${KDEVPG_INCLUDE_DIR})
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/python_ast.h"
"${CMAKE_CURRENT_BINARY_DIR}/python_parser.h"
"${CMAKE_CURRENT_BINARY_DIR}/python_parser.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/python_visitor.h"
"${CMAKE_CURRENT_BINARY_DIR}/python_visitor.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.h"
"${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.cpp"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g"
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python_lexer.h"
COMMAND ${KDEVPG_EXECUTABLE}
ARGS --output=python
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
add_custom_target( debuginfo
${KDEVPG_EXECUTABLE} --terminals
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g" ">terminals"
COMMAND ${KDEVPG_EXECUTABLE} --symbols
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g" ">symbols"
COMMAND ${KDEVPG_EXECUTABLE} --rules
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python.g" ">rules" "2>errors"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
set( _srcsList
"${CMAKE_CURRENT_BINARY_DIR}/python_parser.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/python_visitor.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.cpp")
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.cpp"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/parser/python_lexer.ll"
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python_lexer.h"
"${CMAKE_CURRENT_BINARY_DIR}/python_parser.h"
COMMAND ${FLEX_EXECUTABLE}
ARGS -o"${CMAKE_CURRENT_BINARY_DIR}/python_lexer.cpp"
-d
"${CMAKE_CURRENT_SOURCE_DIR}/parser/python_lexer.ll"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set(_srcsList ${_srcsList} ${CMAKE_CURRENT_BINARY_DIR}/python_lexer.cpp)
else(KDEVPG_FOUND AND FLEX_FOUND)
include_directories(${CMAKE_SOURCE_DIR}/parser/generated)
message(STATUS "Assuming existence of generated parser files")
set(_srcsList
${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_visitor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_default_visitor.cpp
)
message( STATUS "Assuming existence of generated lexer files")
set(_srcsList ${_srcsList}
${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_lexer.cpp )
endif(KDEVPG_FOUND AND FLEX_FOUND)
endmacro(GET_PARSER_SRCS _srcsList)
add_subdirectory(parser)
get_parser_srcs(parser_SRCS)
set(kdevpythonlanguagesupport_PART_SRCS
pythonlanguagesupport.cpp
pythonparsejob.cpp
parser/parsesession.cpp
${parser_SRCS} ${parser_STAT_SRCS}
)
kde4_automoc(${kdevpythonlanguagesupport_PART_SRCS})
kde4_add_plugin(kdevpythonlanguagesupport ${kdevpythonlanguagesupport_PART_SRCS})
target_link_libraries(kdevpythonlanguagesupport
${KDE4_KDEUI_LIBS}
${KDEVPLATFORM_INTERFACES_LIBRARY}
${KDEVPLATFORM_LANGUAGE_LIBRARY}
${KDE4_THREADWEAVER_LIBRARIES}
)
install(TARGETS kdevpythonlanguagesupport DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kdevpythonsupport.desktop DESTINATION ${SERVICES_INSTALL_DIR})
add_custom_target( copy-generated
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_parser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_parser.cpp"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_parser.h" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_parser.h"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_ast.h" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_ast.h"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_visitor.h" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_visitor.h"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_visitor.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_visitor.cpp"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.h" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_default_visitor.h"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_default_visitor.cpp"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/parser/generated/python_lexer.cpp"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_parser.cpp"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_parser.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_visitor.cpp"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_visitor.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.cpp"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_default_visitor.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_ast.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/python_lexer.cpp"
)
More information about the Kde-buildsystem
mailing list