Changeset f9798ad in rtems-libbsd
- Timestamp:
- 05/30/16 23:49:31 (7 years ago)
- Branches:
- 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
- Children:
- ab5cd63
- Parents:
- 70d52b8
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
builder.py
r70d52b8 rf9798ad 56 56 filesProcessedCount = 0 57 57 filesProcessed = [] 58 filesTotal = 0 59 filesTotalLines = 0 60 filesTotalInserts = 0 61 filesTotalDeletes = 0 62 diffDetails = { } 58 63 59 64 verboseInfo = 1 … … 65 70 return verboseLevel >= level 66 71 67 def changedFileSummary(): 72 def changedFileSummary(statsReport = False): 73 74 global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes 75 68 76 if isDiffMode == False: 69 print('%d file(s) were changed:' % (filesProcessedCount))70 77 if verbose(): 78 print('%d file(s) were changed:' % (filesProcessedCount)) 71 79 for f in sorted(filesProcessed): 72 80 print(' %s' % (f)) 81 else: 82 print('%d file(s) were changed.' % (filesProcessedCount)) 83 if statsReport: 84 print('Stats Report:') 85 transparent = filesTotal - len(diffDetails) 86 changes = filesTotalInserts + filesTotalDeletes 87 opacity = (float(changes) / (filesTotalLines + changes)) * 100.0 88 print(' Total File(s):%d Unchanged:%d (%.1f%%) Changed:%d' \ 89 ' Opacity:%5.1f%% Lines:%d Edits:%d (+):%d (-):%d' % \ 90 (filesTotal, transparent, (float(transparent) / filesTotal) * 100.0, len(diffDetails), \ 91 opacity, filesTotalLines, changes, filesTotalInserts, filesTotalDeletes)) 92 # 93 # Sort by opacity. 94 # 95 ordered_diffs = sorted(diffDetails.items(), key = lambda diff: diff[1].opacity, reverse = True) 96 for f in ordered_diffs: 97 print(' %s' % (diffDetails[f[0]].status())) 73 98 74 99 def readFile(name): … … 105 130 def __str__(self): 106 131 return self.msg 132 133 # 134 # Diff Record 135 # 136 class diffRecord: 137 def __init__(self, src, dst, orig, diff, inserts, deletes): 138 self.src = src 139 self.dst = dst 140 self.orig = orig 141 self.diff = diff 142 self.lines = len(orig) 143 self.inserts = inserts 144 self.deletes = deletes 145 self.changes = inserts + deletes 146 self.opacity = (float(self.changes) / (self.lines + self.changes)) * 100.0 147 148 def __repr__(self): 149 return self.src 150 151 def status(self): 152 return 'opacity:%5.1f%% edits:%4d (+):%-4d (-):%-4d %s' % \ 153 (self.opacity, self.changes, self.inserts, self.deletes, self.src) 107 154 108 155 # … … 222 269 sys.exit(2) 223 270 271 def diffSource(dstLines, srcLines, src, dst): 272 global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes 273 # 274 # Diff, note there is no line termination on each string. Expand the 275 # generator to list because the generator is not reusable. 276 # 277 diff = list(difflib.unified_diff(dstLines, 278 srcLines, 279 fromfile = src, 280 tofile = dst, 281 n = 5, 282 lineterm = '')) 283 inserts = 0 284 deletes = 0 285 if len(diff) > 0: 286 if src in diffDetails and \ 287 diffDetails[src].dst != dst and diffDetails[src].diff != diff: 288 raise error('repeated diff of file different: src:%s dst:%s' % (src, dst)) 289 for l in diff: 290 if l[0] == '-': 291 deletes += 1 292 elif l[0] == '+': 293 inserts += 1 294 diffDetails[src] = diffRecord(src, dst, srcLines, diff, inserts, deletes) 295 296 # 297 # Count the total files, lines and the level of changes. 298 # 299 filesTotal += 1 300 filesTotalLines += len(srcLines) 301 filesTotalInserts += inserts 302 filesTotalDeletes += deletes 303 304 return diff 305 224 306 # 225 307 # Converters provide a way to alter the various types of code. The conversion … … 277 359 278 360 # 279 # Diff, note there is no line termination on each string. Expand the 280 # generator to list because the generator is not reusable. 281 # 282 diff = list(difflib.unified_diff(dstLines, 283 srcLines, 284 fromfile = src, 285 tofile = dst, 286 n = 5, 287 lineterm = '')) 361 # Diff, note there is no line termination on each string. 362 # 363 diff = diffSource(dstLines, srcLines, src, dst) 288 364 289 365 # -
freebsd-to-rtems.py
r70d52b8 rf9798ad 49 49 isEarlyExit = False 50 50 isOnlyBuildScripts = False 51 statsReport = False 51 52 52 53 def usage(): … … 58 59 print(" -m|--makefile Warning: depreciated and will be removed ") 59 60 print(" -b|--buildscripts just generate the build scripts") 61 print(" -S|--stats Print a statistics report") 60 62 print(" -R|--reverse default FreeBSD -> RTEMS, reverse that") 61 63 print(" -r|--rtems RTEMS Libbsd directory (default: '.')") … … 65 67 # Parse the arguments 66 68 def parseArguments(): 67 global isForward, isEarlyExit 69 global isForward, isEarlyExit, statsReport 68 70 global isOnlyBuildScripts 69 71 try: 70 72 opts, args = getopt.getopt(sys.argv[1:], 71 "?hdDemb Rr:f:v",73 "?hdDembSRr:f:v", 72 74 [ "help", 73 75 "help", … … 78 80 "buildscripts" 79 81 "reverse" 82 "stats" 80 83 "rtems=" 81 84 "freebsd=" … … 100 103 elif o in ("-b", "--buildscripts") or o in ("-m", "--makefile"): 101 104 isOnlyBuildScripts = True 105 elif o in ("-S", "--stats"): 106 statsReport = True 102 107 elif o in ("-R", "--reverse"): 103 108 isForward = False … … 153 158 wafGen.processSource(isForward) 154 159 wafGen.generate(libbsd.rtems_version()) 155 builder.changedFileSummary( )160 builder.changedFileSummary(statsReport) 156 161 except IOError as ioe: 157 162 print('error: %s' % (str(ioe))) -
libbsd.txt
r70d52b8 rf9798ad 615 615 -m|--makefile Warning: depreciated and will be removed 616 616 -b|--buildscripts just generate the build scripts 617 -S|--stats Print a statistics report 617 618 -R|--reverse default FreeBSD -> RTEMS, reverse that 618 -r|--rtems RTEMS directory619 -f|--freebsd FreeBSD directory619 -r|--rtems RTEMS Libbsd directory (default: '.') 620 -f|--freebsd FreeBSD SVN directory (default: 'freebsd-org') 620 621 -v|--verbose enable verbose output mode 621 622 ---- … … 682 683 . Run `./create-kernel-namespace.sh` if you imported kernel space headers. Add only your new defines via `git add -p rtemsbsd/include/machine/rtems-bsd-kernel-namespace.h`. 683 684 . Create one commit from this. 685 686 The -S or --stats option generates reports the changes we have made to 687 FreeBSD. If the code has been reserved into the original FreeBSD tree it will 688 show nothing has changed. To see what we have change: 689 690 $ cd freebsd-org 691 $ git checkout -- . 692 $ cd .. 693 $ ./freebsd-to-rtems.py -R -S -d 694 695 The report lists the files change based on the opacity level. The opacity is a 696 measure on how much of a file differs from the original FreeBSD source. The 697 lower the value the more transparent the source file it. 684 698 685 699 == Initialization of the BSD Library
Note: See TracChangeset
for help on using the changeset viewer.