ソースを参照

Add debug option for library checking to get some output of what paths
the script checks. Also add keys for each check to eventually use for
filtering.

Rene Rivera 10 年 前
コミット
14aebbd376
1 ファイル変更52 行追加30 行削除
  1. 52 30
      status/boost_check_library.py

+ 52 - 30
status/boost_check_library.py

@@ -34,13 +34,15 @@ class check_library():
                 The library needs to provide a Boost Build project that the user,
                 and the top level Boost project, can use to build the library if it
                 has sources to build.
-                ''')
+                ''',
+                'org-build-ok')
         if os.path.isdir(os.path.join(self.library_dir, 'src')):
             self.assert_dir_exists(os.path.join(self.library_dir,'build'),
                 '''
                 Missing [project-root]/build directory. The [project-root]/build directory
                 is required for libraries that have a [project-root]/src directory.
-                ''')
+                ''',
+                'org-build-src')
     
     def check_organization_doc(self):
         self.assert_file_exists(self.library_dir, ['index.html'],
@@ -48,7 +50,8 @@ class check_library():
             Did not find [project-root]/index.html file.
             
             The file is required for all libraries. Redirection to HTML documentation.
-            ''')
+            ''',
+            'org-doc-redir')
         self.assert_dir_exists(os.path.join(self.library_dir,'doc'),
             '''
             Missing [project-root]/doc directory. The [project-root]/doc directory
@@ -57,7 +60,8 @@ class check_library():
             Sources to build with and built documentation for the library. If the
             library needs to build documentation from non-HTML files this location
             must be buildable with Boost Build.
-            ''')
+            ''',
+            'org-doc-dir')
     
     def check_organization_include(self):
         if os.path.isdir(os.path.join(self.library_dir,'include','boost',self.library_name)):
@@ -65,6 +69,7 @@ class check_library():
                 '''
                 Found extra files in [project-root]/include/boost directory.
                 ''',
+                'org-inc-extra',
                 negate = True,
                 globs_to_exclude = ['%s.h*'%(self.library_name)])
         else:
@@ -74,14 +79,16 @@ class check_library():
                 
                 A single header for the library is suggested at [project-root]/include/boost/[library].h*
                 if the library does not have a header directory at [project-root]/include/boost/[library].
-                ''')
+                ''',
+                'org-inc-one')
     
     def check_organization_meta(self):
         if self.assert_dir_exists(os.path.join(self.library_dir,'meta'),
             '''
             Missing [project-root]/meta directory. The [project-root]/meta directory
             is required for all libraries.
-            '''):
+            ''',
+            'org-meta-dir'):
             self.assert_file_exists(os.path.join(self.library_dir, 'meta'), ['libraries.json'],
                 '''
                 Did not find [project-root]/meta/libraries.json file.
@@ -89,7 +96,8 @@ class check_library():
                 The file is required for all libraries. And contains information about
                 the library used to generate website and documentation for the
                 Boost C++ Libraries collection.
-                ''')
+                ''',
+                'org-meta-libs')
     
     def check_organization_test(self):
         if self.assert_dir_exists(os.path.join(self.library_dir,'test'),
@@ -101,11 +109,13 @@ class check_library():
             considered for automated testing. If you have additional locations that
             need to be part of automated testing it is required that this location
             refer to the additional test locations.
-            '''):
+            ''',
+            'org-test-dir'):
             self.assert_file_exists(os.path.join(self.library_dir, 'test'), self.jamfile,
                 '''
                 Did not find a Boost Build file in the [project-root]/test directory.
-                ''')
+                ''',
+                'org-test-ok')
 
     def main(self):
         commands = [];
@@ -120,9 +130,11 @@ class check_library():
         opt.add_option('--boost-root')
         opt.add_option('--library')
         opt.add_option('--jamfile')
+        opt.add_option('--debug', action='store_true')
         self.boost_root = None
         self.library = None
         self.jamfile = None
+        self.debug = False
         ( _opt_, self.actions ) = opt.parse_args(None,self)
         
         self.library_dir = os.path.join(self.boost_root, self.library)
@@ -130,11 +142,12 @@ class check_library():
         self.jamfile = self.jamfile.split(';')
         self.library_name = os.path.basename(self.library)
 
-        #print ">>> cwd: %s"%(os.getcwd())
-        #print ">>> actions: %s"%(self.actions)
-        #print ">>> boost_root: %s"%(self.boost_root)
-        #print ">>> library: %s"%(self.library)
-        #print ">>> jamfile: %s"%(self.jamfile)
+        if self.debug:
+            print ">>> cwd: %s"%(os.getcwd())
+            print ">>> actions: %s"%(self.actions)
+            print ">>> boost_root: %s"%(self.boost_root)
+            print ">>> library: %s"%(self.library)
+            print ">>> jamfile: %s"%(self.jamfile)
 
         for action in self.actions:
             action_m = "check_"+action.replace('-','_')
@@ -146,67 +159,75 @@ class check_library():
             if method[0].startswith(action_base):
                 getattr(self,method[0])(*args, **kargs)
     
-    def error(self, reason, message):
+    def error(self, reason, message, key):
         self.error_count += 1
-        print("%s: error: %s; %s"%(
+        print("%s: error: %s; %s <<%s>>"%(
             self.library,
             self.clean_message(reason),
             self.clean_message(message),
+            key,
             ))
     
-    def warn(self, reason, message):
-        print("%s: warning: %s; %s"%(
+    def warn(self, reason, message, key):
+        print("%s: warning: %s; %s <<%s>>"%(
             self.library,
             self.clean_message(reason),
             self.clean_message(message),
+            key,
             ))
     
+    def info(self, message):
+        if self.debug:
+            print("%s: info: %s"%(self.library, self.clean_message(message)))
+    
     def clean_message(self, message):
         return " ".join(message.strip().split())
     
-    def assert_dir_exists(self, dir, message, negate = False):
+    def assert_dir_exists(self, dir, message, key, negate = False):
+        self.info("check directory '%s', negate = %s"%(dir,negate))
         if os.path.isdir(dir):
             if negate:
-                self.error("directory found", message)
+                self.error("directory found", message, key)
                 return False
         else:
             if not negate:
-                self.error("directory not found", message)
+                self.error("directory not found", message, key)
                 return False
         return True
     
-    def warn_dir_exists(self, dir, message, negate = False):
+    def warn_dir_exists(self, dir, message, key, negate = False):
+        self.info("check directory '%s', negate = %s"%(dir,negate))
         if os.path.isdir(dir):
             if negate:
-                self.warn("directory found", message)
+                self.warn("directory found", message, key)
                 return False
         else:
             if not negate:
-                self.warn("directory not found", message)
+                self.warn("directory not found", message, key)
                 return False
         return True
     
-    def assert_file_exists(self, dir, globs_to_include, message, negate = False, globs_to_exclude = []):
+    def assert_file_exists(self, dir, globs_to_include, message, key, negate = False, globs_to_exclude = []):
         found = self.test_file_exists(dir, globs_to_include = globs_to_include, globs_to_exclude = globs_to_exclude)
         if negate:
             if found:
-                self.error("file found", message)
+                self.error("file found", message, key)
                 return False
         else:
             if not found:
-                self.error("file not found", message)
+                self.error("file not found", message, key)
                 return False
         return True
     
-    def warn_file_exists(self, dir, globs_to_include, message, negate = False, globs_to_exclude = []):
+    def warn_file_exists(self, dir, globs_to_include, message, key, negate = False, globs_to_exclude = []):
         found = self.test_file_exists(dir, globs_to_include = globs_to_include, globs_to_exclude = globs_to_exclude)
         if negate:
             if found:
-                self.warn("file found", message)
+                self.warn("file found", message, key)
                 return False
         else:
             if not found:
-                self.warn("file not found", message)
+                self.warn("file not found", message, key)
                 return False
         return True
     
@@ -214,6 +235,7 @@ class check_library():
         return os.path.isdir(dir)
     
     def test_file_exists(self, dir, globs_to_include, globs_to_exclude = []):
+        self.info("test file(s) in dir '%s', include = '%s', exclude = %s"%(dir,globs_to_include,globs_to_exclude))
         found = False
         if os.path.isdir(dir):
             for g in globs_to_include:

粤ICP备19079148号