User:Bugman/subsystems: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(→‎All subsystems: Added an example for hunting down subsystem dependencies.)
(→‎Script: Newest version of the script.)
Line 127: Line 127:
             ctor = "\<%s\>::\<%s\>[ \(]" % (subsystem.name, subsystem.name)
             ctor = "\<%s\>::\<%s\>[ \(]" % (subsystem.name, subsystem.name)
             dtor = "\<%s\>::\~\<%s\>[ \(]" % (subsystem.name, subsystem.name)
             dtor = "\<%s\>::\~\<%s\>[ \(]" % (subsystem.name, subsystem.name)
             grep_ctor = 'grep -rI "%s\{{!}}%s"' % (ctor, dtor)
             grep_ctor = 'grep -rI "%s\|%s"' % (ctor, dtor)


             # The grep command for any function implementation.
             # The grep command for any function implementation.
Line 136: Line 136:
                 # The probable implementation file name.
                 # The probable implementation file name.
                 file_name = subsystem.declaration_file[:-3] + "cxx"
                 file_name = subsystem.declaration_file[:-3] + "cxx"
                full_path = file_name
                 if not subsystem.root_path:
                 if not subsystem.root_path:
                     file_name = path + sep + file_name
                     full_path = path + sep + file_name
                 if access(file_name, F_OK):
                 if access(full_path, F_OK):
                     # The Unix grep commands to run.
                     # The Unix grep commands to run.
                     cmds = [
                     cmds = [
                         '%s %s' % (grep_ctor, file_name),
                         '%s %s' % (grep_ctor, full_path),
                         '%s %s {{!}} grep -v "return"' % (grep_any, file_name)
                         '%s %s | grep -v "return"' % (grep_any, full_path)
                     ]
                     ]


Line 150: Line 151:
                         lines = pipe.stdout.readlines()
                         lines = pipe.stdout.readlines()
                         if len(lines):
                         if len(lines):
                             subsystem.add_implementation_file(file_name)
                             if self.output_full_path:
                                subsystem.add_implementation_file(full_path)
                            else:
                                subsystem.add_implementation_file(file_name)
                             break
                             break


Line 158: Line 162:
                 cmds = [
                 cmds = [
                     'cd %s; %s' % (path, grep_ctor),
                     'cd %s; %s' % (path, grep_ctor),
                     'cd %s; %s {{!}} grep -v "return"' % (path, grep_any)
                     'cd %s; %s | grep -v "return"' % (path, grep_any)
                 ]
                 ]


Line 307: Line 311:


         # The Unix grep command to run.
         # The Unix grep command to run.
         cmd = 'cd %s; grep -rI %s "public \<%s\>" {{!}} grep -v "%s::"' % (path, self.grep_exclude_dir, base_name, base_name)
         cmd = 'cd %s; grep -rI %s "public \<%s\>" | grep -v "%s::"' % (path, self.grep_exclude_dir, base_name, base_name)
         pipe = Popen(cmd, shell=True, stdout=PIPE)
         pipe = Popen(cmd, shell=True, stdout=PIPE)


Line 671: Line 675:
         """Set up the object.
         """Set up the object.


         @keyword implementation_file:  The absolute path of the file containing the subsystem implementation.
         @keyword implementation_file:  The path of the file containing the subsystem implementation.
         @type implementation_file:      str or None
         @type implementation_file:      str or None
         """
         """

Revision as of 19:02, 24 April 2018

Tracking down subsystems

Script

The following script is for finding all FlightGear dependencies:

All subsystems

The result is:

Refactoring

To check that all subsystems on a branch have been updated or refactored: