rosbuild2 taking shape

This commit is contained in:
Troy Straszheim 2011-03-16 22:49:09 +00:00
parent 9ba060e007
commit 6badbe1d8e
7 changed files with 129 additions and 13 deletions

View File

@ -25,6 +25,6 @@
<platform os="ubuntu" version="10.04"/>
<platform os="macports" version="macports"/>
<rosbuild2>
<note>Prototype rosbuild2 stuff goes here</note>
<include_dir>${roslib_PACKAGE_DIR}/include</include_dir>
</rosbuild2>
</package>

View File

@ -0,0 +1,10 @@
include(${CMAKE_CURRENT_BINARY_DIR}/package.cmake)
rosbuild_add_boost_directories()
rosbuild_add_library(roslib src/package.cpp)
rosbuild_link_boost(roslib thread)
if(NOT APPLE)
target_link_libraries(roslib rt)
endif(NOT APPLE)

View File

@ -66,7 +66,13 @@ def load_manifest(package_name, bootstrap_version="0.7"):
"""
if package_name in _bootstrapped:
return
sys.path = _generate_python_path(package_name, [], os.environ) + sys.path
prefix = []
if 'ROS_BUILD' in os.environ:
if os.environ['ROS_BUILD'] == os.environ['ROS_ROOT']:
return
prefix = [os.path.join(os.environ['ROS_BUILD'], 'gen', 'py'),
os.path.join(os.environ['ROS_BUILD'], '..', 'rosidl', 'src')]
sys.path = prefix + _generate_python_path(package_name, [], os.environ) + sys.path
def _append_package_paths(manifest_, paths, pkg_dir):
"""

View File

@ -56,6 +56,7 @@ import roslib.manifest
import roslib.names
import roslib.rosenv
import roslib.os_detect
import roslib.rospack
MSG_DIR = 'msg'
SRV_DIR = 'srv'
@ -184,6 +185,10 @@ def get_pkg_dir(package, required=True, ros_root=None, ros_package_path=None):
rospack = os.path.join(ros_root, 'bin', 'rospack')
else:
rospack = 'rospack'
if 'ROS_BUILD' in os.environ:
rospack = os.path.join(os.environ['ROS_BUILD'], 'bin', 'rospack')
if ros_package_path is not None:
ros_package_path = roslib.rosenv.resolve_paths(ros_package_path)
penv[ROS_PACKAGE_PATH] = ros_package_path
@ -476,6 +481,12 @@ def find_node(pkg, node_type, ros_root=None, ros_package_path=None):
@rtype: str
@raise roslib.packages.InvalidROSPkgException: If package does not exist
"""
if 'ROS_BUILD' in os.environ:
tst = os.path.join(os.environ['ROS_BUILD'], 'bin', node_type)
if os.path.isfile(tst):
return tst
dir = get_pkg_dir(pkg, required=True, \
ros_root=ros_root, ros_package_path=ros_package_path)
@ -502,8 +513,7 @@ def find_node(pkg, node_type, ros_root=None, ros_package_path=None):
if m in files:
test_path = os.path.join(p, node_type)
s = os.stat(test_path)
if (s.st_mode & (stat.S_IRUSR | stat.S_IXUSR) ==
(stat.S_IRUSR | stat.S_IXUSR)):
if (s.st_mode & stat.S_IRWXU == stat.S_IRWXU):
return test_path
if '.svn' in dirs:
dirs.remove('.svn')
@ -515,8 +525,7 @@ def find_node(pkg, node_type, ros_root=None, ros_package_path=None):
if node_type in files:
test_path = os.path.join(p, node_type)
s = os.stat(test_path)
if (s.st_mode & (stat.S_IRUSR | stat.S_IXUSR) ==
(stat.S_IRUSR | stat.S_IXUSR)):
if (s.st_mode & stat.S_IRWXU == stat.S_IRWXU):
return test_path
if '.svn' in dirs:
dirs.remove('.svn')
@ -680,10 +689,7 @@ class ROSPackages(object):
if package in self._depends_cache:
return self._depends_cache[package]
# assign key before recursive call to prevent infinite case
self._depends_cache[package] = s = set()
s = set()
manifests = self.manifests
# take the union of all dependencies
pkgs = [p.package for p in manifests[package].depends]
@ -750,9 +756,7 @@ class ROSPackages(object):
if package in self._rosdeps_cache:
return self._rosdeps_cache[package]
# set the key before recursive call to prevent infinite case
self._rosdeps_cache[package] = s = set()
s = set()
manifests = self.manifests
# take the union of all dependencies
pkgs = [p.package for p in manifests[package].depends]

View File

@ -1,3 +1,7 @@
if(ROSBUILD)
include(rosbuild.cmake)
return()
endif()
# We can't use rosbuild/rosbuild.cmake here, because rosbuild.cmake
# requires rospack, and we're in the process of building rospack.
cmake_minimum_required(VERSION 2.4.6)

View File

@ -25,4 +25,9 @@ rospack uses the TinyXML parser, a zLib-licensed library which is available here
<platform os="ubuntu" version="9.10"/>
<platform os="ubuntu" version="10.04"/>
<platform os="macports" version="macports"/>
<rosbuild2>
<export>
<include_dir>${rospack_SOURCE_DIR}/include</include_dir>
</export>
</rosbuild2>
</package>

View File

@ -0,0 +1,87 @@
include(${CMAKE_CURRENT_BINARY_DIR}/package.cmake)
# We can't use rosbuild/rosbuild.cmake here, because rosbuild.cmake
# requires rospack, and we're in the process of building rospack.
set(CMAKE_INSTALL_PREFIX /tmp/rospack)
#set(CMAKE_INSTALL_RPATH_USE_LINK_RPATH true)
#set(CMAKE_SKIP_BUILD_RPATH true)
set(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
include_directories(include ${PROJECT_SOURCE_DIR})
# Include the rosbuild's rosconfig.cmake, which includes logic for checking
# for $ROS_ROOT/rosconfig.cmake, where the user may have adjusted the build
# configuration. In particular, that's where static vs. shared is set.
add_definitions(-DTIXML_USE_STL)
set(rospack_sources rospack.cpp tinyxml-2.5.3/tinystr.cpp tinyxml-2.5.3/tinyxml.cpp tinyxml-2.5.3/tinyxmlparser.cpp tinyxml-2.5.3/tinyxmlerror.cpp)
set(rosstack_sources rosstack.cpp)
# Here we duplicate a bit of the logic in rosbuild/public.cmake.
if(NOT ROS_BUILD_STATIC_LIBS AND NOT ROS_BUILD_SHARED_LIBS)
message(FATAL_ERROR "Neithersharednorstaticlibrariesareenabled.PleaseseteitherROS_BUILD_STATIC_LIBSorROS_BUILD_SHARED_LIBStotrue.")
endif(NOT ROS_BUILD_STATIC_LIBS AND NOT ROS_BUILD_SHARED_LIBS)
if(ROS_BUILD_STATIC_EXES AND ROS_BUILD_SHARED_LIBS)
message(FATAL_ERROR "Staticexecutablesarerequested,butsoaresharedlibs.Thisconfigurationisunsupported.PleaseeithersetROS_BUILD_SHARED_LIBStofalseorsetROS_BUILD_STATIC_EXEStofalse.")
endif(ROS_BUILD_STATIC_EXES AND ROS_BUILD_SHARED_LIBS)
if(ROS_BUILD_SHARED_LIBS)
# If shared libs are being built, they get the default CMake target name
# No matter what, the libraries get the same name in the end.
add_library(rospack SHARED ${rospack_sources})
add_library(rosstack SHARED ${rosstack_sources})
# Prevent deletion of existing lib of same name
set_target_properties(rospack PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(rosstack PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif(ROS_BUILD_SHARED_LIBS)
if(ROS_BUILD_STATIC_LIBS)
add_definitions("-DROS_STATIC")
# If we're only building static libs, then they get the default CMake
# target name.
if(NOT ROS_BUILD_SHARED_LIBS)
set(static_rospack "rospack")
set(static_rosstack "rosstack")
else(NOT ROS_BUILD_SHARED_LIBS)
set(static_rospack "rospack-static")
set(static_rosstack "rosstack-static")
endif(NOT ROS_BUILD_SHARED_LIBS)
add_library(${static_rospack} STATIC ${rospack_sources})
add_library(${static_rosstack} STATIC ${rosstack_sources})
# Set output name to be the same as shared lib (may not work on Windows)
set_target_properties(${static_rospack} PROPERTIES OUTPUT_NAME "rospack")
set_target_properties(${static_rosstack} PROPERTIES OUTPUT_NAME "rosstack")
# Also add -fPIC, because CMake leaves it out when building static
# libs, even though it's necessary on 64-bit machines for linking this
# lib against shared libs downstream.
set_target_properties(${static_rospack} PROPERTIES COMPILE_FLAGS "-fPIC")
set_target_properties(${static_rosstack} PROPERTIES COMPILE_FLAGS "-fPIC")
# Prevent deletion of existing lib of same name
set_target_properties(${static_rospack} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(${static_rosstack} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif(ROS_BUILD_STATIC_LIBS)
add_executable(rospackexe main.cpp)
set_target_properties(rospackexe PROPERTIES OUTPUT_NAME rospack)
target_link_libraries(rosstack rospack)
add_executable(rosstackexe rosstack_main.cpp)
set_target_properties(rosstackexe PROPERTIES OUTPUT_NAME rosstack)
target_link_libraries(rospackexe rospack)
target_link_libraries(rosstackexe rosstack rospack)
if(ROS_BUILD_STATIC_EXES AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
# This will probably only work on Linux. The LINK_SEARCH_END_STATIC
# property should be sufficient, but it doesn't appear to work
# properly.
set_target_properties(rospackexe PROPERTIES LINK_FLAGS "-static-libgcc-Wl,-Bstatic")
set_target_properties(rosstackexe PROPERTIES LINK_FLAGS "-static-libgcc-Wl,-Bstatic")
endif(ROS_BUILD_STATIC_EXES AND ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
#install(TARGETS rospack rosstack rospackexe rosstackexe
# RUNTIME DESTINATION bin
# LIBRARY DESTINATION lib)
#install(FILES include/rospack/rospack.h
# DESTINATION include/rospack)
# Prevent warnings about duplicate definition of the targets mentioned
# below
if(COMMAND cmake_policy)
# Logical target names must be globally unique.
cmake_policy(SET CMP0002 OLD)
endif(COMMAND cmake_policy)
# These targets might be called by rosmakeall
add_custom_target(test)
add_custom_target(tests)
add_custom_target(test-results)
add_custom_target(test-future)
add_custom_target(gcoverage)