Skip to content

Commit

Permalink
Merge pull request #39 from asmodehn/include_seq
Browse files Browse the repository at this point in the history
preventing multiple includes, reviewing variable scope.
  • Loading branch information
asmodehn authored Aug 26, 2016
2 parents ddf7660 + 6d76ab9 commit 738e036
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ script:
- docker ps -a
- docker exec -ti ${CONTAINER_NAME} /bin/bash -c "source /opt/ros/$CI_ROS_DISTRO/setup.bash && rospack profile"
# Passing env vars here since passing in docker run currently breaks (2016-08-25)
- docker exec -ti ${CONTAINER_NAME} /bin/bash -c "export CI_ROS_DISTRO=$CI_ROS_DISTRO && export ROS_FLOW=$ROS_FLOW && /git_clone/travis_checks.sh"
- docker exec -ti ${CONTAINER_NAME} /bin/bash -c "export CI_ROS_DISTRO=$CI_ROS_DISTRO && export ROS_FLOW=$ROS_FLOW && /git_clone/travis_checks.bash"
- docker stop "${CONTAINER_ID}"

notifications:
Expand Down
16 changes: 11 additions & 5 deletions cmake/catkin-pip-env.cmake.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
message(STATUS "Loading catkin-pip-env.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

#
# Important : This script is included by multiple cmake scripts at configure and build time
# So it needs to be idempotent (no change if called multiple time with same settings/environment)
#

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_env_included)
return()
endif(catkin_pip_env_included)
set(catkin_pip_env_included true)

macro(catkin_pip_check_env config_prefix)
function(catkin_pip_check_env config_prefix)
# Make sure the catkin python package directory for the workspace is in python path
# This is only needed if the user didn't source the current workspace setup.bash.
# This happens the first time when using catkin_pip in workspace
Expand Down Expand Up @@ -46,6 +52,6 @@ macro(catkin_pip_check_env config_prefix)

# Note : this is obviously not changing anything in the shell environment where cmake was started from.
# Since this cmake extension depends on catkin we also do the same in an envhook for normal usage (source setup.bash).
endmacro()
endfunction()


19 changes: 13 additions & 6 deletions cmake/catkin-pip-prefix.cmake.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
message(STATUS "Loading catkin-pip-prefix.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

#
# Important : This script is included by multiple cmake scripts at configure and build time
# So it needs to be idempotent (no change if called multiple time with same settings/environment)
#

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_prefix_included)
return()
endif(catkin_pip_prefix_included)
set(catkin_pip_prefix_included true)


# protecting against missing cmake file
include ( "${CMAKE_CURRENT_LIST_DIR}/catkin-pip-env.cmake" RESULT_VARIABLE CATKIN_PIP_ENV_FOUND )
Expand All @@ -23,10 +30,10 @@ ENDIF ( NOT CATKIN_PIP_RUNCMD_FOUND )

if ( NOT CATKIN_PIP_REQUIREMENTS_PATH )
# Our current path is where all catkin-pip requirements should be
set (CATKIN_PIP_REQUIREMENTS_PATH ${CMAKE_CURRENT_LIST_DIR})
set (CATKIN_PIP_REQUIREMENTS_PATH ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "where all catkin-pip requirements should be")
endif()

macro(catkin_pip_setup_prefix ws_prefix)
function(catkin_pip_setup_prefix ws_prefix)

# Setting up our environment (for devel space only)
catkin_pip_check_env(${ws_prefix})
Expand Down Expand Up @@ -104,4 +111,4 @@ macro(catkin_pip_setup_prefix ws_prefix)
endif()

endif()
endmacro()
endfunction()
14 changes: 12 additions & 2 deletions cmake/catkin-pip-requirements.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
message(STATUS "Loading catkin-pip-requirements.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_requirements_included)
return()
endif(catkin_pip_requirements_included)
set(catkin_pip_requirements_included true)

# protecting against missing cmake file
include ( "${CMAKE_CURRENT_LIST_DIR}/catkin-pip-prefix.cmake" RESULT_VARIABLE CATKIN_PIP_PREFIX_FOUND )
IF ( NOT CATKIN_PIP_PREFIX_FOUND )
Expand All @@ -11,7 +21,7 @@ ENDIF ( NOT CATKIN_PIP_PREFIX_FOUND )
# This is used by any other project directly (at configure time).
# It will automatically setup a prefix with catkin-pip.
#
macro(catkin_pip_requirements requirements_txt)
function(catkin_pip_requirements requirements_txt)

# Setting up our environment (for devel space only)
# Needed in case user call this directly (configure time)
Expand All @@ -20,4 +30,4 @@ macro(catkin_pip_requirements requirements_txt)
# runnig the pip command (configure time)
catkin_pip_runcmd(${CATKIN_PIP} install ${ARGN} -r ${requirements_txt} --src ${CMAKE_SOURCE_DIR} --exists-action b --prefix "${CATKIN_DEVEL_PREFIX}")

endmacro()
endfunction()
17 changes: 12 additions & 5 deletions cmake/catkin-pip-runcmd.cmake.in
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
message(STATUS "Loading catkin-pip-runcmd from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

#
# Important : This script is included by multiple cmake scripts at configure and build time
# So it needs to be idempotent (no change if called multiple time with same settings/environment)
#

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_runcmd_included)
return()
endif(catkin_pip_runcmd_included)
set(catkin_pip_runcmd_included true)


macro(catkin_pip_runcmd)
function(catkin_pip_runcmd)

set(PIP_PACKAGE_INSTALL_COMMAND ${ARGN})

Expand All @@ -30,4 +37,4 @@ macro(catkin_pip_runcmd)
message(FATAL_ERROR "${PIP_ERROR}")
endif()

endmacro()
endfunction()
16 changes: 13 additions & 3 deletions cmake/catkin-pip-setup.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
message(STATUS "Loading catkin-pip-setup.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_setup_included)
return()
endif(catkin_pip_setup_included)
set(catkin_pip_setup_included true)

# protecting against missing cmake file
include ( "${CMAKE_CURRENT_LIST_DIR}/catkin-pip-env.cmake" RESULT_VARIABLE CATKIN_PIP_ENV_FOUND )
IF ( NOT CATKIN_PIP_ENV_FOUND )
Expand All @@ -22,7 +32,7 @@ ENDIF ( NOT CATKIN_PIP_PREFIX_FOUND )
# These are set on include time by catkin-pip and point to catkin-pip folders
if ( NOT CATKIN_PIP_TEMPLATES_PATH )
# templates should found relative to our current path
set (CATKIN_PIP_TEMPLATES_PATH ${CMAKE_CURRENT_LIST_DIR}/templates)
set (CATKIN_PIP_TEMPLATES_PATH ${CMAKE_CURRENT_LIST_DIR}/templates CACHE PATH "templates path")
endif()

# We are replacing catkin's python_setup functionality
Expand Down Expand Up @@ -67,7 +77,7 @@ function(catkin_pip_python_setup)

endfunction()

macro(catkin_pip_setup)
function(catkin_pip_setup)

set (extra_macro_args ${ARGN})

Expand Down Expand Up @@ -100,4 +110,4 @@ macro(catkin_pip_setup)
# Hijacking catkin scripts again
#set(_PACKAGE_XML_DIRECTORY ${package_path})

endmacro()
endfunction()
12 changes: 11 additions & 1 deletion cmake/catkin-pip.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
message(STATUS "Loading catkin-pip.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")

if ( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )
message ( FATAL_ERROR " CMAKE MINIMUM BACKWARD COMPATIBILITY REQUIRED : 2.8 !" )
endif( CMAKE_BACKWARDS_COMPATIBILITY LESS 2.8 )

# Setting required policies
# required to be able to do "if (True)"
# FOREACH(policy CMP0011 CMP0012 CMP0013 CMP0014)
Expand All @@ -8,6 +12,12 @@ message(STATUS "Loading catkin-pip.cmake from ${CMAKE_CURRENT_LIST_DIR}... ")
# ENDIF()
# ENDFOREACH()

# Enforcing one time include https://cmake.org/Wiki/CMake_Performance_Tips#Use_an_include_guard
if(catkin_pip_main_included)
return()
endif(catkin_pip_main_included)
set(catkin_pip_main_included true)

# protecting against missing cmake file dependency
include ( "${CMAKE_CURRENT_LIST_DIR}/catkin-pip-requirements.cmake" RESULT_VARIABLE CATKIN_PIP_REQUIREMENTS_FOUND )
IF ( NOT CATKIN_PIP_REQUIREMENTS_FOUND )
Expand All @@ -30,7 +40,7 @@ endif()
# to use latest versions python tools in both.
set(CATKIN_PIP_ENV ${CMAKE_BINARY_DIR}/catkin_pip_env CACHE PATH "The path containing the python environment for catkin_pip dependencies" )
set(CATKIN_PIP_NO_DEPS True CACHE BOOL "Whether we want to retrieve python dependencies and requirements for packages" )
set(CATKIN_PIP_PYTHON_INSTALL_DIR @CATKIN_PIP_GLOBAL_PYTHON_DESTINATION@)
set(CATKIN_PIP_PYTHON_INSTALL_DIR @CATKIN_PIP_GLOBAL_PYTHON_DESTINATION@ CACHE PATH "Where catkin pip install python packages")

# Since we need the envhook as soon as a package is using catkin-pip from source, but only in devel space.
catkin_add_env_hooks(42.site_packages SHELLS bash DIRECTORY ${CATKIN_PIP_ENV_HOOKS_PATH} SKIP_INSTALL)
Expand Down
10 changes: 5 additions & 5 deletions cmake/nosetests.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _generate_function_if_testing_is_disabled("catkin_add_nosetests")
function(catkin_add_nosetests path)
_warn_if_skip_testing("catkin_add_nosetests")

if(NOT PIP_NOSETESTS)
if(NOT CATKIN_PIP_NOSETESTS)
message(WARNING "skipping nosetests(${path}) in project '${PROJECT_NAME}'")
return()
endif()
Expand Down Expand Up @@ -79,13 +79,13 @@ function(catkin_add_nosetests path)
else()
set(tests "${_path_name}")
endif()
set(cmd ${cmd} "PYTHONPATH=$ENV{PYTHONPATH} ${PIP_NOSETESTS} -P --process-timeout=${_nose_TIMEOUT} ${tests} --with-xunit --xunit-file=${output_path}/nosetests-${output_file_name}.xml${_covarg}")
set(cmd ${cmd} "PYTHONPATH=$ENV{PYTHONPATH} ${CATKIN_PIP_NOSETESTS} -P --process-timeout=${_nose_TIMEOUT} ${tests} --with-xunit --xunit-file=${output_path}/nosetests-${output_file_name}.xml${_covarg}")
catkin_run_tests_target("nosetests" ${output_file_name} "nosetests-${output_file_name}.xml" COMMAND ${cmd} DEPENDENCIES ${_nose_DEPENDENCIES} WORKING_DIRECTORY ${_nose_WORKING_DIRECTORY})
endfunction()

# Providing another catkin nosetests usage...
# now we can finally use the simple "nosetests" entry_point (forcing cmake to find it)
find_program(PIP_NOSETESTS NAMES
find_program(CATKIN_PIP_NOSETESTS NAMES
"nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"nosetests${PYTHON_VERSION_MAJOR}"
Expand All @@ -95,8 +95,8 @@ find_program(PIP_NOSETESTS NAMES
${CATKIN_PIP_ENV}/@CATKIN_GLOBAL_BIN_DESTINATION@
NO_DEFAULT_PATH
)
if(PIP_NOSETESTS)
message(STATUS "Catkin_pip using Python nosetests: ${PIP_NOSETESTS}")
if(CATKIN_PIP_NOSETESTS)
message(STATUS "Catkin_pip using Python nosetests: ${CATKIN_PIP_NOSETESTS}")
else()
message(FATAL_ERROR "Catkin_pip nosetests not found in ${CATKIN_DEVEL_PREFIX}/@CATKIN_GLOBAL_BIN_DESTINATION@. Make sure you have installed the nose pip package on your ${CATKIN_DEVEL_PREFIX} workspace.")
endif()
Expand Down
10 changes: 5 additions & 5 deletions cmake/pytest.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ENDIF ( NOT CATKIN_PIP_NOSETESTS_FOUND )
function(catkin_add_pytests path)
_warn_if_skip_testing("catkin_add_pytests")

if(NOT PIP_PYTEST)
if(NOT CATKIN_PIP_PYTEST)
message(WARNING "skipping pytests(${path}) in project '${PROJECT_NAME}'")
return()
endif()
Expand Down Expand Up @@ -79,13 +79,13 @@ function(catkin_add_pytests path)
get_filename_component(output_path "${output_path}" ABSOLUTE)
set(cmd "${CMAKE_COMMAND} -E make_directory ${output_path}")
set(tests "${_path_name}")
set(cmd ${cmd} "PYTHONPATH=$ENV{PYTHONPATH} ${PIP_PYTEST} --timeout=${_pytest_TIMEOUT} ${tests} --junit-xml ${output_path}/pytests-${output_file_name}.xml ${_covarg}")
set(cmd ${cmd} "PYTHONPATH=$ENV{PYTHONPATH} ${CATKIN_PIP_PYTEST} --timeout=${_pytest_TIMEOUT} ${tests} --junit-xml ${output_path}/pytests-${output_file_name}.xml ${_covarg}")
catkin_run_tests_target("pytests" ${output_file_name} "pytests-${output_file_name}.xml" COMMAND ${cmd} DEPENDENCIES ${_pytest_DEPENDENCIES} WORKING_DIRECTORY ${_pytest_WORKING_DIRECTORY})
endfunction()

# Providing another catkin pytests usage...
# now we can finally use the simple "py.test" entry_point (forcing cmake to find it)
find_program(PIP_PYTEST NAMES
find_program(CATKIN_PIP_PYTEST NAMES
"py.test${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"py.test-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}"
"py.test${PYTHON_VERSION_MAJOR}"
Expand All @@ -95,8 +95,8 @@ find_program(PIP_PYTEST NAMES
${CATKIN_PIP_ENV}/@CATKIN_GLOBAL_BIN_DESTINATION@
NO_DEFAULT_PATH
)
if(PIP_PYTEST)
message(STATUS "Catkin_pip using Python py.test: ${PIP_PYTEST}")
if(CATKIN_PIP_PYTEST)
message(STATUS "Catkin_pip using Python py.test: ${CATKIN_PIP_PYTEST}")
else()
message(FATAL_ERROR "Catkin_pip py.test command not found in ${CATKIN_DEVEL_PREFIX}/@CATKIN_GLOBAL_BIN_DESTINATION@. Make sure you have installed the pytest pip package on your ${CATKIN_DEVEL_PREFIX} workspace.")
endif()
File renamed without changes.

0 comments on commit 738e036

Please sign in to comment.