pchdelta.py (86f29464) | pchdelta.py (b0ad9294) |
---|---|
1#!/usr/bin/env python 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the --- 87 unchanged lines hidden (view full) --- 96 return 97 # Test if this slice passes the buildtest 98 writePch(pchname, header, footer, acceptedlines, lines) 99 if testSequenceBuild(dirlist): 100 return acceptedlines + lines 101 102 # Reject one liners 103 if linecount == 1: | 1#!/usr/bin/env python 2# ************************************************************* 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the --- 87 unchanged lines hidden (view full) --- 96 return 97 # Test if this slice passes the buildtest 98 writePch(pchname, header, footer, acceptedlines, lines) 99 if testSequenceBuild(dirlist): 100 return acceptedlines + lines 101 102 # Reject one liners 103 if linecount == 1: |
104 print indent + "Rejected: " + lines[0] | 104 print(indent + "Rejected: " + lines[0]) |
105 return acceptedlines 106 107 # Recurse with multiline slices 108 fanout = 4 109 splits = [] 110 for i in range(3): 111 splits.append(linecount * (i + 1) / fanout) 112 splits.append(linecount) 113 114 splitstart = 0 115 for splitend in splits: 116 # avoid splitting in case we have no resulting lines 117 if (splitend - splitstart) == 0: 118 continue 119 splitslice = lines[splitstart:splitend] | 105 return acceptedlines 106 107 # Recurse with multiline slices 108 fanout = 4 109 splits = [] 110 for i in range(3): 111 splits.append(linecount * (i + 1) / fanout) 112 splits.append(linecount) 113 114 splitstart = 0 115 for splitend in splits: 116 # avoid splitting in case we have no resulting lines 117 if (splitend - splitstart) == 0: 118 continue 119 splitslice = lines[splitstart:splitend] |
120 print indent + "[" + str(startpoint + splitstart) + ":" + str(startpoint + splitend) + "] (" + str(splitend - splitstart) + ")" | 120 print(indent + "[" + str(startpoint + splitstart) + ":" + str(startpoint + splitend) + "] (" + str(splitend - splitstart) + ")") |
121 acceptedlines = binaryTest(dirlist, splitslice, pchname, header, footer, acceptedlines, indent + " ", startpoint + splitstart) 122 splitstart = splitend 123 124 return acceptedlines 125 126# ------------------------------------------------------------------------------ 127# Main entry point 128 129if len(sys.argv) < 3: | 121 acceptedlines = binaryTest(dirlist, splitslice, pchname, header, footer, acceptedlines, indent + " ", startpoint + splitstart) 122 splitstart = splitend 123 124 return acceptedlines 125 126# ------------------------------------------------------------------------------ 127# Main entry point 128 129if len(sys.argv) < 3: |
130 print "Usage: " + sys.argv[0] + " <pch_target> <dir1> [<dir2> <dir3> ...]" | 130 print("Usage: " + sys.argv[0] + " <pch_target> <dir1> [<dir2> <dir3> ...]") |
131 sys.exit(1) 132 133pchname = os.path.abspath(sys.argv[1]) 134dirlist = sys.argv[2:] 135 136# remove old build log file 137if os.path.exists("buildlog.txt"): 138 os.remove("buildlog.txt") 139 140# test for corner case of everything working from the start 141if testSequenceBuild(dirlist): | 131 sys.exit(1) 132 133pchname = os.path.abspath(sys.argv[1]) 134dirlist = sys.argv[2:] 135 136# remove old build log file 137if os.path.exists("buildlog.txt"): 138 os.remove("buildlog.txt") 139 140# test for corner case of everything working from the start 141if testSequenceBuild(dirlist): |
142 print "pch working, nothing to do." | 142 print("pch working, nothing to do.") |
143 sys.exit(0) 144 145# Open the header file for reading 146inputfile = file(pchname, "r+") 147inputdata = inputfile.read() 148inputfile.close() 149 150segments = inputdata.split(MARKER) 151header = segments[0] 152footer = segments[2] 153lines = segments[1].split("\n") 154 155writePch(pchname + "_backup", header, footer, lines, []) 156 157# test for corner case of no convergence possible 158writePch(pchname, header, footer, [], []) 159if not testSequenceBuild(dirlist): 160 writePch(pchname, header, footer, lines, []) | 143 sys.exit(0) 144 145# Open the header file for reading 146inputfile = file(pchname, "r+") 147inputdata = inputfile.read() 148inputfile.close() 149 150segments = inputdata.split(MARKER) 151header = segments[0] 152footer = segments[2] 153lines = segments[1].split("\n") 154 155writePch(pchname + "_backup", header, footer, lines, []) 156 157# test for corner case of no convergence possible 158writePch(pchname, header, footer, [], []) 159if not testSequenceBuild(dirlist): 160 writePch(pchname, header, footer, lines, []) |
161 print "Building with no candidate lines failed. Convergence questionable, aborting." | 161 print("Building with no candidate lines failed. Convergence questionable, aborting.") |
162 sys.exit(0) 163 164# Starting pruning | 162 sys.exit(0) 163 164# Starting pruning |
165print "Starting evaluation of " + str(len(lines)) + " lines" | 165print("Starting evaluation of " + str(len(lines)) + " lines") |
166acceptedlines = binaryTest(dirlist, lines, pchname, header, footer, [], "", 0) 167writePch(pchname, header, footer, acceptedlines, []) | 166acceptedlines = binaryTest(dirlist, lines, pchname, header, footer, [], "", 0) 167writePch(pchname, header, footer, acceptedlines, []) |