tools/gen-components
branchs11-update
changeset 3662 d2e09f75ea27
parent 2551 0391c5c3b137
child 3979 46744fa00de4
equal deleted inserted replaced
3661:47545fb8aed4 3662:d2e09f75ea27
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    17 # fields enclosed by brackets "[]" replaced with your own identifying
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    18 # information: Portions Copyright [yyyy] [name of copyright owner]
    19 #
    19 #
    20 # CDDL HEADER END
    20 # CDDL HEADER END
    21 #
    21 #
    22 # Copyright (c) 2012, 2013, Oracle and/or it's affiliates.  All rights reserved.
    22 # Copyright (c) 2012, 2015, Oracle and/or it's affiliates.  All rights reserved.
    23 #
    23 #
    24 #
    24 #
    25 # gen_components
    25 # gen_components
    26 # A simple script to generate (on stdout), the component.html web page 
    26 # A simple script to generate (on stdout), the component.html web page
    27 # found at: http://userland.us.oracle.com/components.html
    27 # found at: http://userland.us.oracle.com/component-lists/s11-update.html
    28 #
    28 #
    29 
    29 
    30 import getopt
    30 import getopt
    31 import os
    31 import os
    32 import sys
    32 import sys
    33 
    33 
    34 debug = False
    34 debug = False
    35 
       
    36 # TPNO string to search for in each .p5m file.
       
    37 TPNO_str = "com.oracle.info.tpno"
       
    38 
       
    39 # Hashtable of components with TPNOs keyed by component name.
       
    40 comp_TPNOs = {}
       
    41 
    35 
    42 # Hashtable of RE's, RM's and Teams keyed by component path.
    36 # Hashtable of RE's, RM's and Teams keyed by component path.
    43 owners = {}
    37 owners = {}
    44 
    38 
    45 # Initial HTML for the generated web page.
    39 # Initial HTML for the generated web page.
   125         component, re, rm, team = line.split("|")
   119         component, re, rm, team = line.split("|")
   126         owners[component] = [ re, rm, team ]
   120         owners[component] = [ re, rm, team ]
   127 
   121 
   128     return owners
   122     return owners
   129 
   123 
   130 # Return a hashtable of components with TPNOs keyed by component name.
       
   131 def find_TPNOs(workspace):
       
   132     comp_TPNOs = {}
       
   133     for directory, _, files in os.walk(workspace + "/components"):
       
   134         for filename in files:
       
   135             if filename.endswith(".p5m"):
       
   136                 pathname = os.path.join(directory, filename)
       
   137                 fin = open(pathname, 'r')
       
   138                 lines = fin.readlines()
       
   139                 fin.close()
       
   140 
       
   141                 for line in lines:
       
   142                     line = line.replace("\n", "")
       
   143                     n = line.find(TPNO_str)
       
   144                     if n != -1:
       
   145                         tpno_str = line[n:].split("=")[1]
       
   146                         try:
       
   147                             # Check that the TPNO is a valid number.
       
   148                             tpno = int(tpno_str)
       
   149                             if debug:
       
   150                                 print >> sys.stderr, "TPNO: %s: %s" % \
       
   151                                     (directory, tpno_str)
       
   152                             comp_TPNOs[directory] = tpno_str
       
   153                         except:
       
   154                             # Check to see if line end in a "\" character in
       
   155                             # which case, it's an attribute rather than an
       
   156                             # set name action, so extract it a different way.
       
   157                             try:
       
   158                                 n += len(TPNO_str)+1
       
   159                                 tpno_str = line[n:].split()[0]
       
   160                                 # Check that the TPNO is a valid number.
       
   161                                 tpno = int(tpno_str)
       
   162                                 if debug:
       
   163                                     print >> sys.stderr, "TPNO: %s: %s" % \
       
   164                                         (directory, tpno_str)
       
   165 
       
   166                                 # If it's an attribute, there might be more
       
   167                                 # than one TPNO for this component.
       
   168                                 if directory in comp_TPNOs:
       
   169                                     entry = comp_TPNOs[directory]
       
   170                                     tpno_str = "%s,%s" % (entry, tpno_str)
       
   171 
       
   172                                 comp_TPNOs[directory] = tpno_str
       
   173                             except:
       
   174                                 print >> sys.stderr, \
       
   175                                     "Unable to read TPNO: %s" % pathname
       
   176 
       
   177     return(comp_TPNOs)
       
   178 
       
   179 # Return a sorted list of the directories containing one or more .p5m files.
   124 # Return a sorted list of the directories containing one or more .p5m files.
   180 def find_p5m_dirs(workspace):
   125 def find_p5m_dirs(workspace):
   181     p5m_dirs = []
   126     p5m_dirs = []
   182     for dir, _, files in os.walk(workspace + "/components"):
   127     for dir, _, files in os.walk(workspace + "/components"):
   183         for file in files:
   128         for file in files:
       
   129             if dir.endswith("meta-packages/history"):
       
   130                 continue;
   184             if file.endswith(".p5m"):
   131             if file.endswith(".p5m"):
   185                 p5m_dirs.append(dir)
   132                 p5m_dirs.append(dir)
   186 
   133 
   187     return sorted(list(set(p5m_dirs)))
   134     return sorted(list(set(p5m_dirs)))
   188 
   135 
   215 # under the components build directory.
   162 # under the components build directory.
   216 def gen_reports(workspace, component_dir):
   163 def gen_reports(workspace, component_dir):
   217     if debug:
   164     if debug:
   218         print >> sys.stderr, "Processing %s" % component_dir
   165         print >> sys.stderr, "Processing %s" % component_dir
   219 
   166 
   220     try:
       
   221         tpno = comp_TPNOs[component_dir]
       
   222     except:
       
   223         tpno = ""
       
   224 
       
   225     re, rm, team = get_owner(component_dir)
   167     re, rm, team = get_owner(component_dir)
   226     makefiles = "-f Makefile -f %s/make-rules/component-report" % workspace
   168     makefiles = "-f Makefile -f %s/make-rules/component-report" % workspace
   227     targets = "clean component-hook"
   169     targets = "clean component-hook"
   228     template = "cd %s; "
   170     template = "cd %s; "
   229     template += "TPNO='%s' "
       
   230     template += "RESPONSIBLE_ENGINEER='%s' "
   171     template += "RESPONSIBLE_ENGINEER='%s' "
   231     template += "RESPONSIBLE_MANAGER='%s' "
   172     template += "RESPONSIBLE_MANAGER='%s' "
   232     template += "TEAM='%s' "
   173     template += "TEAM='%s' "
   233     template += "gmake COMPONENT_HOOK='gmake %s component-report' %s"
   174     template += "gmake COMPONENT_HOOK='gmake %s component-report' %s"
   234     cmd = template % (component_dir, tpno, re, rm, team, makefiles, targets)
   175     cmd = template % (component_dir, re, rm, team, makefiles, targets)
   235 
   176 
   236     if debug:
   177     if debug:
   237         print >> sys.stderr, "gen_reports: command: `%s`" % cmd
   178         print >> sys.stderr, "gen_reports: command: `%s`" % cmd
   238     lines = os.popen(cmd).readlines()
   179     lines = os.popen(cmd).readlines()
   239 
   180 
   297         else:
   238         else:
   298             assert False, "unknown option"
   239             assert False, "unknown option"
   299  
   240  
   300     owners = read_owners(owners_file)
   241     owners = read_owners(owners_file)
   301     write_preamble()
   242     write_preamble()
   302     comp_TPNOs = find_TPNOs(workspace)
       
   303     p5m_dirs = find_p5m_dirs(workspace)
   243     p5m_dirs = find_p5m_dirs(workspace)
   304     for p5m_dir in p5m_dirs:
   244     for p5m_dir in p5m_dirs:
   305         gen_reports(workspace, p5m_dir)
   245         gen_reports(workspace, p5m_dir)
   306     write_reports(p5m_dirs, owners_file)
   246     write_reports(p5m_dirs, owners_file)
   307     write_postamble()
   247     write_postamble()