diff --git a/CMakeLists.txt b/CMakeLists.txt index 06d8fb34..92ee8a8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,4 +16,4 @@ set(ROSPACK_MAKEDIST true) # variables. #list(APPEND CPACK_SOURCE_IGNORE_FILES /core/experimental) -rosbuild_make_distribution(1.1.16) +rosbuild_make_distribution(1.3.x-trunk) diff --git a/bin/rosversion b/bin/rosversion index 14d66e20..60148af2 100755 --- a/bin/rosversion +++ b/bin/rosversion @@ -28,14 +28,45 @@ # This tool is a place-holder for a future version inspection system. -USAGE = '''USAGE: rosversion - Available stacks: - ros''' +from __future__ import with_statement +USAGE = "Usage: rosversion " + +import os import sys +import re +import roslib.stacks -if len(sys.argv) == 2 and sys.argv[1] == 'ros': - print '1.1.16' +def get_source_version(text): + for l in text.split('\n'): + if l.strip().startswith('rosbuild_make_distribution'): + x_re = re.compile(r'[()]') + lsplit = x_re.split(l.strip()) + if len(lsplit) < 2: + raise Exception("couldn't find version number in CMakeLists.txt:\n\n%s"%l) + return lsplit[1] + raise Exception("could not locate version number in stack CMakeLists.txt") + +if len(sys.argv) == 2: + stack_name = sys.argv[1] + + try: + d = roslib.stacks.get_stack_dir(stack_name) + except Exception, e: + print >> sys.stderr, str(e) + sys.exit(1) + + cmake_p = os.path.join(d, 'CMakeLists.txt') + if not os.path.isfile(cmake_p): + print '' + else: + with open(cmake_p) as f: + text = f.read() + try: + print get_source_version(text) + except Exception, e: + print >> sys.stderr, str(e) + sys.exit(1) else: - print >> sys.stderr, USAGE - sys.exit(-1) + print >> sys.stderr, USAGE + sys.exit(-1)