tools/gen-components
changeset 1063 ce6e2ed3767e
parent 1061 757624619bb3
child 1139 2fe2a52488cb
equal deleted inserted replaced
1062:3e8044c3a700 1063:ce6e2ed3767e
    34 debug = False
    34 debug = False
    35 
    35 
    36 # Hashtable of components with TPNOs keyed by component name.
    36 # Hashtable of components with TPNOs keyed by component name.
    37 comp_TPNOs = {}
    37 comp_TPNOs = {}
    38 
    38 
    39 # Hashtable of RE's / RM's keyed by component path.
    39 # Hashtable of RE's, RM's and Teams keyed by component path.
    40 owners = {}
    40 owners = {}
    41 
    41 
    42 # Initial HTML for the generated web page.
    42 # Initial HTML for the generated web page.
    43 preamble = """
    43 preamble = """
    44 <html>
    44 <html>
    87     <th>License(s)</th>
    87     <th>License(s)</th>
    88     <th>TPNO</th>
    88     <th>TPNO</th>
    89     <th>BugDB</th>
    89     <th>BugDB</th>
    90     <th>RE</th>
    90     <th>RE</th>
    91     <th>RM</th>
    91     <th>RM</th>
       
    92     <th>Team</th>
    92 </tr>
    93 </tr>
    93 </thead>
    94 </thead>
    94 <tbody>
    95 <tbody>
    95 """
    96 """
    96 
    97 
   101 </table>
   102 </table>
   102 </body>
   103 </body>
   103 </html>
   104 </html>
   104 """
   105 """
   105 
   106 
   106 # Return a hashtable of RE's / RM's keyed by component path.
   107 # Return a hashtable of RE's, RM's and Teams keyed by component path.
   107 def read_owners(owners_file):
   108 def read_owners(owners_file):
   108     if debug:
   109     if debug:
   109         print >> sys.stderr, "Reading %s" % owners_file
   110         print >> sys.stderr, "Reading %s" % owners_file
   110     try:
   111     try:
   111         fin = open(owners_file, 'r')
   112         fin = open(owners_file, 'r')
   116             print >> sys.stderr, "Unable to read owners file: %s" % owners_file
   117             print >> sys.stderr, "Unable to read owners file: %s" % owners_file
   117 
   118 
   118     owners = {}
   119     owners = {}
   119     for line in lines:
   120     for line in lines:
   120         line = line[:-1]
   121         line = line[:-1]
   121         component, re, rm = line.split("|")
   122         component, re, rm, team = line.split("|")
   122         owners[component] = [ re, rm ]
   123         owners[component] = [ re, rm, team ]
   123 
   124 
   124     return owners
   125     return owners
   125 
   126 
   126 # Return a hashtable of components with TPNOs keyed by component name.
   127 # Return a hashtable of components with TPNOs keyed by component name.
   127 def find_TPNOs(workspace):
   128 def find_TPNOs(workspace):
   163 
   164 
   164 # Write out the initial HTML for the components.html web page.
   165 # Write out the initial HTML for the components.html web page.
   165 def write_preamble():
   166 def write_preamble():
   166     print preamble
   167     print preamble
   167 
   168 
   168 # Return the RE / RM for this component.
   169 # Return the RE,  RM and Team for this component.
   169 def get_re_and_rm(p5m_dir):
   170 def get_owner(p5m_dir):
   170     re_and_rm = [ "Unknown", "Unknown" ]
   171     result = [ "Unknown", "Unknown", "Unknown" ]
   171     component_path = ""
   172     component_path = ""
   172     started = False
   173     started = False
   173     tokens = p5m_dir.split("/")
   174     tokens = p5m_dir.split("/")
   174     for token in tokens:
   175     for token in tokens:
   175         if started:
   176         if started:
   176             component_path += token + "/"
   177             component_path += token + "/"
   177         if token == "components":
   178         if token == "components":
   178             started = True
   179             started = True
   179     component_path = component_path[:-1]
   180     component_path = component_path[:-1]
   180     if component_path in owners:
   181     if component_path in owners:
   181         re_and_rm = owners[component_path]
   182         result = owners[component_path]
   182     if debug:
   183     if debug:
   183         print >> sys.stderr, "Component path: ", component_path,
   184         print >> sys.stderr, "Component path: ", component_path,
   184         print >> sys.stderr, "RE / RM: ", re_and_rm
   185         print >> sys.stderr, "RE, RM, Team: ", result
   185     
   186     
   186     return re_and_rm
   187     return result
   187 
   188 
   188 # Generate an HTML table entry for all the information for the component
   189 # Generate an HTML table entry for all the information for the component
   189 # in the given directory. This generates a file called 'component-report'
   190 # in the given directory. This generates a file called 'component-report'
   190 # under the components build directory.
   191 # under the components build directory.
   191 def gen_reports(workspace, component_dir):
   192 def gen_reports(workspace, component_dir):
   195     try:
   196     try:
   196         tpno = comp_TPNOs[component_dir]
   197         tpno = comp_TPNOs[component_dir]
   197     except:
   198     except:
   198         tpno = ""
   199         tpno = ""
   199 
   200 
   200     re, rm = get_re_and_rm(component_dir)
   201     re, rm, team = get_owner(component_dir)
   201     makefiles = "-f Makefile -f %s/make-rules/component-report" % workspace
   202     makefiles = "-f Makefile -f %s/make-rules/component-report" % workspace
   202     targets = "clean component-hook"
   203     targets = "clean component-hook"
   203     cmd = "cd %s; TPNO='%s' RESPONSIBLE_ENGINEER='%s' RESPONSIBLE_MANAGER='%s' gmake COMPONENT_HOOK='gmake %s component-report' %s" % \
   204     template = "cd %s; "
   204         (component_dir, tpno, re, rm, makefiles, targets)
   205     template += "TPNO='%s' "
       
   206     template += "RESPONSIBLE_ENGINEER='%s' "
       
   207     template += "RESPONSIBLE_MANAGER='%s' "
       
   208     template += "TEAM='%s' "
       
   209     template += "gmake COMPONENT_HOOK='gmake %s component-report' %s"
       
   210     cmd = template % (component_dir, tpno, re, rm, team, makefiles, targets)
   205 
   211 
   206     if debug:
   212     if debug:
   207         print >> sys.stderr, "gen_reports: command: `%s`" % cmd
   213         print >> sys.stderr, "gen_reports: command: `%s`" % cmd
   208     lines = os.popen(cmd).readlines()
   214     lines = os.popen(cmd).readlines()
   209 
   215