Skip to content
Snippets Groups Projects
Commit cbd02f4b authored by Daniel Stonier's avatar Daniel Stonier
Browse files

enviroment hooks to generate a ros maven path.

parent c831c466
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ find_package(catkin REQUIRED)
catkin_package(CFG_EXTRAS rosjava.cmake)
catkin_python_setup()
catkin_add_env_hooks(15.rosjava SHELLS bash DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
##############################################################################
# Project Settings
......
#!/bin/bash
@[if DEVELSPACE]@
export ROS_MAVEN_PATH=`python @(CMAKE_CURRENT_SOURCE_DIR)/generate_ros_maven_path.py`
@[else]@
export ROS_MAVEN_PATH=`python @(CMAKE_INSTALL_PREFIX)/share/rosjava_tools/generate_ros_maven_path.py`
@[end if]@
#!/usr/bin/env python
import os
CATKIN_MARKER_FILE = '.catkin'
def get_workspaces(environ):
'''
Based on CMAKE_PREFIX_PATH return all catkin workspaces.
'''
# get all cmake prefix paths
env_name = 'CMAKE_PREFIX_PATH'
value = environ[env_name] if env_name in environ else ''
paths = [path for path in value.split(os.pathsep) if path]
# remove non-workspace paths
workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE)) or (include_fuerte and path.startswith('/opt/ros/fuerte'))]
return workspaces
if __name__ == '__main__':
workspaces = get_workspaces(dict(os.environ))
maven_repository_paths = [os.path.join(path, 'maven') for path in workspaces]
print os.pathsep.join(maven_repository_paths)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment