Skip to content

Commit

Permalink
meh
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy D. Straszheim committed Dec 4, 2011
1 parent 035bfc7 commit 797f3a8
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
._*
*.pyc
18 changes: 4 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
cmake_minimum_required(VERSION 2.8)
project(genpy_boost)
project(genpybindings)

find_package(catkin)

#find_package(Boost COMPONENTS python)
#include_directories(${Boost_INCLUDE_DIRS})

#FIND_PACKAGE(PythonLibs)
#INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})

#add_library(std_msgs SHARED src/string.cpp)
#SET_TARGET_PROPERTIES(std_msgs PROPERTIES PREFIX "")
#target_link_libraries(std_msgs ${Boost_LIBRARIES})

install_cmake_infrastructure(genpy_boost
install_cmake_infrastructure(genpybindings
VERSION 0.0.0
CFG_EXTRAS genpy_boost-extras.cmake
CFG_EXTRAS genpybindings-extras.cmake
)

catkin_package(genpy_boost)
catkin_package(genpybindings)
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ include_directories(${PYTHON_INCLUDE_PATH})
include_directories(${CMAKE_BINARY_DIR}/gen/cpp)

if(@PACKAGE_NAME@_SOURCE_DIR)
find_program_required(GENPY_BOOST_BIN gen_py_boost.py PATHS ${@PACKAGE_NAME@_SOURCE_DIR}/scripts)
set(GENPY_BOOST_TEMPLATE_DIR ${@PACKAGE_NAME@_SOURCE_DIR}/scripts)
find_program_required(GENPYBINDINGS_BIN gen_pybindings.py PATHS ${@PACKAGE_NAME@_SOURCE_DIR}/scripts)
set(GENPYBINDINGS_TEMPLATE_DIR ${@PACKAGE_NAME@_SOURCE_DIR}/scripts)
else()
find_program_required(GENPY_BOOST_BIN gen_py_boost.py)
set(GENPY_BOOST_TEMPLATE_DIR ${CMAKE_INSTALL_PREFIX}/share/genpy_boost)
find_program_required(GENPYBINDINGS_BIN gen_pybindings.py)
set(GENPYBINDINGS_TEMPLATE_DIR ${CMAKE_INSTALL_PREFIX}/share/genpybindings)
endif()

# Generate .cpp
# The generated .h files should be added ALL_GEN_OUTPUT_FILES_cpp
macro(_generate_msg_py_boost ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
macro(_generate_msg_pybindings ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)

#Create input and output filenames
get_filename_component(MSG_NAME ${ARG_MSG} NAME)
Expand All @@ -29,23 +29,23 @@ macro(_generate_msg_py_boost ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUT

assert(CATKIN_ENV)
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
DEPENDS ${GENPY_BOOST_BIN} ${MSG_INPUT_FILE} ${ARG_MSG_DEPS}
${GENPY_BOOST_TEMPLATE_DIR}/msg.cpp.template
${GENPY_BOOST_TEMPLATE_DIR}/srv.cpp.template
COMMAND ${CATKIN_ENV} ${GENPY_BOOST_BIN} ${MSG_INPUT_FILE}
DEPENDS ${GENPYBINDINGS_BIN} ${MSG_INPUT_FILE} ${ARG_MSG_DEPS}
${GENPYBINDINGS_TEMPLATE_DIR}/msg.cpp.template
${GENPYBINDINGS_TEMPLATE_DIR}/srv.cpp.template
COMMAND ${CATKIN_ENV} ${GENPYBINDINGS_BIN} ${MSG_INPUT_FILE}
${ARG_IFLAGS}
-p ${ARG_PKG}
-o ${ARG_GEN_OUTPUT_DIR}
-e ${GENPY_BOOST_TEMPLATE_DIR}
-e ${GENPYBINDINGS_TEMPLATE_DIR}
COMMENT "Generating boost::python code from ${ARG_PKG}/${MSG_NAME}"
)

list(APPEND ALL_GEN_OUTPUT_FILES_py_boost ${GEN_OUTPUT_FILE})
list(APPEND ALL_GEN_OUTPUT_FILES_pybindings ${GEN_OUTPUT_FILE})
endmacro()

# Generate .cpp
# The generated .h files should be added ALL_GEN_OUTPUT_FILES_cpp
macro(_generate_srv_py_boost ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
macro(_generate_srv_pybindings ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)

#Create input and output filenames
get_filename_component(MSG_NAME ${ARG_MSG} NAME)
Expand All @@ -59,23 +59,23 @@ macro(_generate_srv_py_boost ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUT

assert(CATKIN_ENV)
add_custom_command(OUTPUT ${GEN_OUTPUT_FILES}
DEPENDS ${GENPY_BOOST_BIN} ${MSG_INPUT_FILE} ${ARG_MSG_DEPS}
${GENPY_BOOST_TEMPLATE_DIR}/msg.cpp.template
${GENPY_BOOST_TEMPLATE_DIR}/srv.cpp.template
COMMAND ${CATKIN_ENV} ${GENPY_BOOST_BIN} ${MSG_INPUT_FILE}
DEPENDS ${GENPYBINDINGS_BIN} ${MSG_INPUT_FILE} ${ARG_MSG_DEPS}
${GENPYBINDINGS_TEMPLATE_DIR}/msg.cpp.template
${GENPYBINDINGS_TEMPLATE_DIR}/srv.cpp.template
COMMAND ${CATKIN_ENV} ${GENPYBINDINGS_BIN} ${MSG_INPUT_FILE}
${ARG_IFLAGS}
-p ${ARG_PKG}
-o ${ARG_GEN_OUTPUT_DIR}
-e ${GENPY_BOOST_TEMPLATE_DIR}
-e ${GENPYBINDINGS_TEMPLATE_DIR}
COMMENT "Generating boost::python code from ${ARG_PKG}/${MSG_NAME}"
)

list(APPEND ALL_GEN_OUTPUT_FILES_py_boost ${GEN_OUTPUT_FILES})
list(APPEND ALL_GEN_OUTPUT_FILES_pybindings ${GEN_OUTPUT_FILES})
endmacro()

macro(_generate_module_py_boost ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)
macro(_generate_module_pybindings ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)

# create a main.cpp file here
# create a module.cpp file here
# calling all the export_MSG functions
# BOOST_PYTHON_MODULE(std_msgs)
# {
Expand All @@ -88,22 +88,22 @@ macro(_generate_module_py_boost ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)

include_directories(${ROS_INCLUDE_DIRS})

set(GEN_OUTPUT_FILE ${ARG_GEN_OUTPUT_DIR}/main.cpp)
set(GEN_OUTPUT_FILE ${ARG_GEN_OUTPUT_DIR}/module.cpp)

assert(CATKIN_ENV)
add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
DEPENDS ${GENPY_BOOST_BIN} ${ARG_GENERATED_FILES} ${ARG_MSG_DEPS}
${GENPY_BOOST_TEMPLATE_DIR}/main.cpp.template
COMMAND ${CATKIN_ENV} ${GENPY_BOOST_BIN}
DEPENDS ${GENPYBINDINGS_BIN} ${ARG_GENERATED_FILES} ${ARG_MSG_DEPS}
${GENPYBINDINGS_TEMPLATE_DIR}/module.cpp.template
COMMAND ${CATKIN_ENV} ${GENPYBINDINGS_BIN}
-m
-p ${ARG_PKG}
-o ${ARG_GEN_OUTPUT_DIR}
-e ${GENPY_BOOST_TEMPLATE_DIR}
-e ${GENPYBINDINGS_TEMPLATE_DIR}
COMMENT "Generating boost::python module for ${ARG_PKG}"
)

# rule to put __init__.py into build dir
file(COPY ${GENPY_BOOST_TEMPLATE_DIR}/__init__.py
file(COPY ${GENPYBINDINGS_TEMPLATE_DIR}/__init__.py
DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ARG_PKG}
)

Expand All @@ -120,4 +120,4 @@ macro(_generate_module_py_boost ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)

endmacro()

set(genpy_boost_INSTALL_DIR lib/py_boost)
set(genpybindings_INSTALL_DIR lib/pybindings)
2 changes: 1 addition & 1 deletion scripts/gen_py_boost.py → scripts/gen_pybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

msg_template_map = { 'msg.cpp.template':'@NAME@.cpp' }
srv_template_map = { 'srv.cpp.template':'@NAME@.cpp' }
mod_template_map = { 'main.cpp.template':'main.cpp' }
mod_template_map = { 'module.cpp.template':'module.cpp' }

if __name__ == "__main__":
genmsg.template_tools.generate_from_command_line_options(sys.argv, msg_template_map, srv_template_map, mod_template_map)
4 changes: 2 additions & 2 deletions scripts/main.cpp.template → scripts/module.cpp.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@#
@# ROS message source code generation for C++
@#
@# EmPy template for generating the main.cpp file
@# EmPy template for generating the module.cpp file
@#
@###############################################
@# Start of Template
Expand All @@ -14,7 +14,7 @@

using namespace boost::python;

@{msg_list = set([f[0:-4] for f in files if f.endswith('.cpp') and f != 'main.cpp'])}@
@{msg_list = set([f[0:-4] for f in files if f.endswith('.cpp') and f != 'module.cpp'])}@

@[for m in msg_list]@
void export_@(m)();
Expand Down
6 changes: 3 additions & 3 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: genpy-boost
Package: genpybindings
Version: 0.0.0
Section: misc
Priority: extra
Expand All @@ -11,8 +11,8 @@ Author: Troy Straszheim <straszheim@willowgarage.com>, Morten Kjaergaard
Maintainer: Troy Straszheim <straszheim@willowgarage.com>
Homepage: http://www.ros.org

Catkin-ProjectName: genpy_boost
Catkin-ProjectName: genpybindings
Catkin-CopyrightType: willowgarage
Catkin-Depends: catkin, genmsg, roscpp_core
Catkin-ROS-Message-Generator: py_boost
Catkin-ROS-Message-Generator: pybindings
Catkin-DebRulesType: python_distutils

0 comments on commit 797f3a8

Please sign in to comment.