Package roswtf :: Module stacks
[frames] | no frames]

Source Code for Module roswtf.stacks

  1  # Software License Agreement (BSD License) 
  2  # 
  3  # Copyright (c) 2009, Willow Garage, Inc. 
  4  # All rights reserved. 
  5  # 
  6  # Redistribution and use in source and binary forms, with or without 
  7  # modification, are permitted provided that the following conditions 
  8  # are met: 
  9  # 
 10  #  * Redistributions of source code must retain the above copyright 
 11  #    notice, this list of conditions and the following disclaimer. 
 12  #  * Redistributions in binary form must reproduce the above 
 13  #    copyright notice, this list of conditions and the following 
 14  #    disclaimer in the documentation and/or other materials provided 
 15  #    with the distribution. 
 16  #  * Neither the name of Willow Garage, Inc. nor the names of its 
 17  #    contributors may be used to endorse or promote products derived 
 18  #    from this software without specific prior written permission. 
 19  # 
 20  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 21  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
 22  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
 23  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
 24  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
 25  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
 26  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
 27  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
 28  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 29  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
 30  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 31  # POSSIBILITY OF SUCH DAMAGE. 
 32  # 
 33  # Revision $Id: packages.py 6258 2009-09-22 22:08:20Z kwc $ 
 34   
 35  import os 
 36  import time 
 37   
 38  from roswtf.environment import paths, is_executable 
 39  from roswtf.rules import warning_rule, error_rule 
 40   
 41  import roslib.msgs 
 42  import roslib.packages 
 43  import roslib.rospack 
 44  import roslib.stacks 
 45  import roslib.stack_manifest 
 46   
 47  _packages_of_cache = {} 
48 -def _packages_of(d):
49 if d in _packages_of_cache: 50 return _packages_of_cache[d] 51 else: 52 _packages_of_cache[d] = pkgs = roslib.stacks.packages_of(d) 53 return pkgs
54
55 -def manifest_depends(ctx):
56 # This rule should probably be cache optimized 57 errors = [] 58 stack_list = roslib.stacks.list_stacks() 59 #print stack_list 60 for s in ctx.stacks: 61 try: 62 s_deps = [] 63 s_pkgs = _packages_of(s) 64 for p in s_pkgs: 65 s_deps.extend(roslib.rospack.rospack_depends_1(p)) 66 m_file = roslib.stack_manifest.stack_file(s, True) 67 m = roslib.stack_manifest.parse_file(m_file) 68 for d in m.depends: 69 if not d.stack in stack_list: 70 errors.append("%s (%s does not exist)"%(m_file, d)) 71 elif d.stack in ['ros', 'ros_comm']: 72 # ros dependency always exists. ros_comm 73 # dependency has implicit connections (msggen), so 74 # we ignore. 75 continue 76 else: 77 pkgs = _packages_of(d.stack) 78 if not [p for p in pkgs if p in s_deps]: 79 errors.append("%s (%s appears to be an unnecessary depend)"%(m_file, d)) 80 except roslib.stacks.InvalidROSStackException: 81 # report with a different rule 82 pass 83 return errors
84 85 warnings = [ 86 (manifest_depends, "The following stack.xml file list invalid dependencies:"), 87 88 ] 89 errors = [ 90 ] 91
92 -def wtf_check(ctx):
93 # no package in context to verify 94 if not ctx.stacks: 95 return 96 97 for r in warnings: 98 warning_rule(r, r[0](ctx), ctx) 99 for r in errors: 100 error_rule(r, r[0](ctx), ctx)
101