rosmake: get rid of call to rospack, more efficient use of rospkg
This commit is contained in:
parent
d65c89e901
commit
b92eccabc5
|
@ -36,6 +36,7 @@ import sys
|
|||
import subprocess
|
||||
import threading
|
||||
|
||||
import rospkg
|
||||
import rosmake
|
||||
|
||||
## make sure that rospack is built, it is a requirement for rosmake
|
||||
|
@ -44,14 +45,17 @@ def assert_rospack_built():
|
|||
output = p.communicate()
|
||||
if p.returncode != 0:
|
||||
print("rospack not available.\nPlease install rospack before using rosmake and make sure it is available on your path. %s %s"%(output[0], output[1]), file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
sys.exit(1)
|
||||
|
||||
result = 1
|
||||
with rosmake.Printer():
|
||||
rma = rosmake.RosMakeAll()
|
||||
|
||||
if rma.main():
|
||||
result = 0
|
||||
try:
|
||||
if rma.main():
|
||||
result = 0
|
||||
except rospkg.ResourceNotFound as e:
|
||||
print("cannot find required resource: %s"%(str(e)))
|
||||
|
||||
#make sure the thread is done
|
||||
rosmake.Printer().join()
|
||||
|
|
|
@ -277,10 +277,14 @@ class Printer:
|
|||
class RosMakeAll:
|
||||
def __init__(self):
|
||||
self._result_lock = threading.Lock()
|
||||
|
||||
self.rospack = rospkg.RosPack()
|
||||
self.rosstack = rospkg.RosStack()
|
||||
|
||||
self.printer = Printer()
|
||||
self.result = {}
|
||||
self.paths = {}
|
||||
self.dependency_tracker = parallel_build.DependencyTracker()
|
||||
self.dependency_tracker = parallel_build.DependencyTracker(rospack=self.rospack)
|
||||
self.flag_tracker = package_stats.PackageFlagTracker(self.dependency_tracker)
|
||||
self.output = {}
|
||||
self.profile = {}
|
||||
|
@ -629,16 +633,10 @@ class RosMakeAll:
|
|||
|
||||
|
||||
options, args = parser.parse_args()
|
||||
self.printer.print_all('rosmake starting...')
|
||||
|
||||
# TODO: retest whther this logic is necessary now that we are using rospkg
|
||||
# force a rebuild of the package cache at the top
|
||||
cmd = ["rospack", "profile"]
|
||||
command_line = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
(pstd_out, pstd_err) = command_line.communicate() # pstd_err should be None due to pipe above
|
||||
# above is necessary for "roscreate-pkg foo && rosmake foo" to work
|
||||
|
||||
self.rospack = rospack = rospkg.RosPack()
|
||||
self.rosstack = rosstack = rospkg.RosStack()
|
||||
rospack = self.rospack
|
||||
rosstack = self.rosstack
|
||||
|
||||
testing = False
|
||||
building = True
|
||||
|
@ -708,7 +706,6 @@ class RosMakeAll:
|
|||
|
||||
self.printer.print_all( "Packages requested are: %s"%packages)
|
||||
|
||||
|
||||
# Setup logging
|
||||
if self.logging_enabled:
|
||||
date_time_stamp = "rosmake_output-" + time.strftime("%Y%m%d-%H%M%S")
|
||||
|
@ -778,13 +775,13 @@ class RosMakeAll:
|
|||
for pkg in self.build_list:
|
||||
if pkg in self.specified_packages:
|
||||
new_list.append(pkg)
|
||||
self.dependency_tracker = parallel_build.DependencyTracker(self.specified_packages) # this will make the tracker only respond to packages in the list
|
||||
self.dependency_tracker = parallel_build.DependencyTracker(self.specified_packages, rospack=self.rospack) # this will make the tracker only respond to packages in the list
|
||||
|
||||
self.printer.print_all("specified-only option was used, only building packages %s"%new_list)
|
||||
self.build_list = new_list
|
||||
|
||||
if options.pre_clean:
|
||||
build_queue = parallel_build.BuildQueue(self.build_list, parallel_build.DependencyTracker([]), robust_build = True)
|
||||
build_queue = parallel_build.BuildQueue(self.build_list, parallel_build.DependencyTracker([], rospack=self.rospack), robust_build = True)
|
||||
self.parallel_build_pkgs(build_queue, "clean", threads = options.threads)
|
||||
|
||||
build_passed = True
|
||||
|
@ -800,7 +797,7 @@ class RosMakeAll:
|
|||
tests_passed = True
|
||||
if build_passed and testing:
|
||||
self.printer.print_verbose ("Testing packages %s"% packages)
|
||||
build_queue = parallel_build.BuildQueue(self.specified_packages, parallel_build.DependencyTracker(self.specified_packages), robust_build = True)
|
||||
build_queue = parallel_build.BuildQueue(self.specified_packages, parallel_build.DependencyTracker(self.specified_packages, rospack=self.rospack), robust_build = True)
|
||||
tests_passed = self.parallel_build_pkgs(build_queue, "test", threads = 1)
|
||||
|
||||
|
||||
|
|
|
@ -79,11 +79,14 @@ class DependencyTracker:
|
|||
range of packages over which to track dependencies. This is useful
|
||||
if you are only building a subset of the tree. For example with the
|
||||
--specified-only option. """
|
||||
def __init__(self, valid_packages=None):
|
||||
def __init__(self, valid_packages=None, rospack=None):
|
||||
"""
|
||||
@param valid_packages: defaults to rospack list
|
||||
"""
|
||||
self.rospack = rospkg.RosPack()
|
||||
if rospack is None:
|
||||
self.rospack = rospkg.RosPack()
|
||||
else:
|
||||
self.rospack = rospack
|
||||
if valid_packages is None:
|
||||
valid_packages = self.rospack.list()
|
||||
self.valid_packages = valid_packages
|
||||
|
|
Loading…
Reference in New Issue