@@ -203,8 +203,7 @@ def clean_swift_package(path, swiftc, sandbox_profile,
203203
204204def build_swift_package (path , swiftc , configuration , sandbox_profile ,
205205 stdout = sys .stdout , stderr = sys .stderr ,
206- incremental = False ,
207- stats_path = None ):
206+ incremental = False ):
208207 """Build a Swift package manager project."""
209208 swift = swiftc [:- 1 ]
210209 if not incremental :
@@ -214,9 +213,6 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
214213 env ['SWIFT_EXEC' ] = swiftc
215214 command = [swift , 'build' , '-C' , path , '--verbose' ,
216215 '--configuration' , configuration ]
217- if stats_path is not None :
218- command += ['-Xswiftc' , '-stats-output-dir' ,
219- '-Xswiftc' , stats_path ]
220216 if (swift_branch not in ['swift-3.0-branch' ,
221217 'swift-3.1-branch' ]):
222218 command .insert (2 , '--disable-sandbox' )
@@ -228,18 +224,14 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
228224
229225def test_swift_package (path , swiftc , sandbox_profile ,
230226 stdout = sys .stdout , stderr = sys .stderr ,
231- incremental = False ,
232- stats_path = None ):
227+ incremental = False ):
233228 """Test a Swift package manager project."""
234229 swift = swiftc [:- 1 ]
235230 if not incremental :
236231 clean_swift_package (path , swiftc , sandbox_profile )
237232 env = os .environ
238233 env ['SWIFT_EXEC' ] = swiftc
239234 command = [swift , 'test' , '-C' , path , '--verbose' ]
240- if stats_path is not None :
241- command += ['-Xswiftc' , '-stats-output-dir' ,
242- '-Xswiftc' , stats_path ]
243235 return common .check_execute (command , timeout = 3600 ,
244236 sandbox_profile = sandbox_profile ,
245237 stdout = stdout , stderr = stderr ,
@@ -274,31 +266,22 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
274266 sandbox_profile_xcodebuild , sandbox_profile_package ,
275267 added_swift_flags , should_strip_resource_phases = False ,
276268 stdout = sys .stdout , stderr = sys .stderr ,
277- incremental = False ,
278- stats_path = None ):
269+ incremental = False ):
279270 """Call functions corresponding to actions."""
280271
281- if stats_path is not None :
282- if os .path .exists (stats_path ):
283- shutil .rmtree (stats_path )
284- common .check_execute (['mkdir' , '-p' , stats_path ],
285- stdout = stdout , stderr = stderr )
286-
287272 if action ['action' ] == 'BuildSwiftPackage' :
288273 return build_swift_package (os .path .join (root_path , repo ['path' ]),
289274 swiftc ,
290275 action ['configuration' ],
291276 sandbox_profile_package ,
292277 stdout = stdout , stderr = stderr ,
293- incremental = incremental ,
294- stats_path = stats_path )
278+ incremental = incremental )
295279 elif action ['action' ] == 'TestSwiftPackage' :
296280 return test_swift_package (os .path .join (root_path , repo ['path' ]),
297281 swiftc ,
298282 sandbox_profile_package ,
299283 stdout = stdout , stderr = stderr ,
300- incremental = incremental ,
301- stats_path = stats_path )
284+ incremental = incremental )
302285 elif re .match (r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$' ,
303286 action ['action' ]):
304287 match = re .match (
@@ -315,8 +298,6 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
315298 if swift_version :
316299 other_swift_flags += ['-swift-version' , swift_version ]
317300 build_settings ['SWIFT_VERSION' ] = swift_version
318- if stats_path is not None :
319- other_swift_flags += ['-stats-output-dir' , stats_path ]
320301 if added_swift_flags :
321302 other_swift_flags .append (added_swift_flags )
322303 if other_swift_flags :
@@ -438,12 +419,6 @@ def add_arguments(parser):
438419 parser .add_argument ("--test-incremental" ,
439420 help = 'test incremental-mode over multiple commits' ,
440421 action = 'store_true' )
441- parser .add_argument ("--check-stats" ,
442- help = 'collect stats and compare to expectations' ,
443- action = 'store_true' )
444- parser .add_argument ("--show-stats" ,
445- metavar = 'PATTERN' ,
446- help = 'report stats matching PATTERN' )
447422 parser .add_argument ("--add-swift-flags" ,
448423 metavar = "FLAGS" ,
449424 help = 'add flags to each Swift invocation' ,
@@ -1008,59 +983,13 @@ def have_same_trees(full, incr, d):
1008983 ok = have_same_trees (full , incr , sub ) and ok
1009984 return ok
1010985
1011- class StatsSummary :
1012-
1013- def __init__ (self ):
1014- self .commits = {}
1015-
1016- def add_stats_from_json (self , seq , sha , j ):
1017- key = (seq , sha )
1018- if key not in self .commits :
1019- self .commits [key ] = {}
1020- for (k , v ) in j .items ():
1021- if k .startswith ("time." ):
1022- continue
1023- e = self .commits [key ].get (k , 0 )
1024- self .commits [key ][k ] = int (v ) + e
1025-
1026- def check_against_expected (self , seq , sha , expected ):
1027- key = (seq , sha )
1028- if key in self .commits :
1029- for (k , ev ) in expected .items ():
1030- if k in self .commits [key ]:
1031- gv = self .commits [key ][k ]
1032- if ev < gv :
1033- message = ("Expected %s of %s, got %s" %
1034- (k , str (ev ), str (gv )) )
1035- raise EarlyExit (ActionResult (Result .FAIL , message ))
1036-
1037- def add_stats_from_file (self , seq , sha , f ):
1038- with open (f ) as fp :
1039- self .add_stats_from_json (seq , sha , json .load (fp ))
1040-
1041- def add_stats_from_dir (self , seq , sha , path ):
1042- for root , dirs , files in os .walk (path ):
1043- for f in files :
1044- if not f .endswith (".json" ):
1045- continue
1046- self .add_stats_from_file (seq , sha , os .path .join (root , f ))
1047-
1048- def dump (self , pattern ):
1049- return json .dumps ([ {"commit" : sha ,
1050- "stats" : { k : v for (k , v ) in self .commits [(seq , sha )].items ()
1051- if re .match (pattern , k ) } }
1052- for (seq , sha ) in sorted (self .commits .keys ()) ],
1053- sort_keys = False ,
1054- indent = 2 )
1055986
1056987class IncrementalActionBuilder (ActionBuilder ):
1057988
1058989 def __init__ (self , swiftc , swift_version , swift_branch ,
1059990 sandbox_profile_xcodebuild ,
1060991 sandbox_profile_package ,
1061992 added_swift_flags ,
1062- check_stats ,
1063- show_stats ,
1064993 project , action ):
1065994 super (IncrementalActionBuilder ,
1066995 self ).__init__ (swiftc , swift_version , swift_branch ,
@@ -1070,15 +999,8 @@ def __init__(self, swiftc, swift_version, swift_branch,
1070999 skip_clean = True ,
10711000 project = project ,
10721001 action = action )
1073- self .check_stats = check_stats
1074- self .show_stats = show_stats
1075- self .stats_path = None
1076- self .stats_summ = None
10771002 self .proj_path = os .path .join (self .root_path , self .project ['path' ])
10781003 self .incr_path = self .proj_path + "-incr"
1079- if self .check_stats or (self .show_stats is not None ):
1080- self .stats_path = os .path .join (self .proj_path , "swift-stats" )
1081- self .stats_summ = StatsSummary ()
10821004
10831005 def curr_build_state_path (self ):
10841006 if self .action ['action' ] == 'BuildSwiftPackage' :
@@ -1111,10 +1033,6 @@ def saved_build_state_path(self, seq, flav, sha):
11111033 return os .path .join (self .incr_path , ("build-state-%03d-%s-%.7s" %
11121034 (seq , flav , sha )))
11131035
1114- def saved_build_stats_path (self , seq , flav , sha ):
1115- return os .path .join (self .incr_path , ("build-stats-%03d-%s-%.7s" %
1116- (seq , flav , sha )))
1117-
11181036 def restore_saved_build_state (self , seq , flav , sha , stdout = sys .stdout ):
11191037 src = self .saved_build_state_path (seq , flav , sha )
11201038 dst = self .curr_build_state_path ()
@@ -1125,7 +1043,7 @@ def restore_saved_build_state(self, seq, flav, sha, stdout=sys.stdout):
11251043 shutil .rmtree (dst )
11261044 shutil .copytree (src , dst , symlinks = True )
11271045
1128- def save_build_state (self , seq , flav , sha , stats , stdout = sys .stdout ):
1046+ def save_build_state (self , seq , flav , sha , stdout = sys .stdout ):
11291047 src = self .curr_build_state_path ()
11301048 dst = self .saved_build_state_path (seq , flav , sha )
11311049 proj = self .project ['path' ]
@@ -1134,17 +1052,6 @@ def save_build_state(self, seq, flav, sha, stats, stdout=sys.stdout):
11341052 if os .path .exists (dst ):
11351053 shutil .rmtree (dst )
11361054 shutil .copytree (src , dst , symlinks = True )
1137- if self .stats_summ is not None :
1138- self .stats_summ .add_stats_from_dir (seq , sha , self .stats_path )
1139- src = self .stats_path
1140- dst = self .saved_build_stats_path (seq , flav , sha )
1141- common .debug_print ("Saving %s stats #%d of %s to %s" %
1142- (flav , seq , proj , dst ), stderr = stdout )
1143- if os .path .exists (dst ):
1144- shutil .rmtree (dst )
1145- shutil .copytree (src , dst , symlinks = True )
1146- if stats is not None and self .check_stats :
1147- self .stats_summ .check_against_expected (seq , sha , stats )
11481055
11491056 def check_full_vs_incr (self , seq , sha , stdout = sys .stdout ):
11501057 full = self .saved_build_state_path (seq , 'full' , sha )
@@ -1182,9 +1089,6 @@ def build(self, stdout=sys.stdout):
11821089 stdout = stdout )
11831090 except EarlyExit as error :
11841091 action_result = error .value
1185- if self .show_stats is not None :
1186- common .debug_print ("Stats summary:" , stderr = stdout )
1187- common .debug_print (self .stats_summ .dump (self .show_stats ), stderr = stdout )
11881092 return action_result
11891093
11901094 def dispatch (self , identifier , incremental , stdout = sys .stdout , stderr = sys .stderr ):
@@ -1197,8 +1101,7 @@ def dispatch(self, identifier, incremental, stdout=sys.stdout, stderr=sys.stderr
11971101 self .added_swift_flags ,
11981102 should_strip_resource_phases = False ,
11991103 stdout = stdout , stderr = stderr ,
1200- incremental = incremental ,
1201- stats_path = self .stats_path )
1104+ incremental = incremental )
12021105 except common .ExecuteCommandFailure as error :
12031106 return self .failed (identifier , error )
12041107 else :
@@ -1222,12 +1125,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
12221125 prev = None
12231126 seq = 0
12241127 action_result = ActionResult (Result .PASS , "" )
1225- for commit in commits :
1226- sha = commit
1227- stats = None
1228- if type (commit ) is dict :
1229- sha = commit ['commit' ]
1230- stats = commit .get ('stats' , None )
1128+ for sha in commits :
12311129 proj = self .project ['path' ]
12321130 ident = "%s-%03d-%.7s" % (identifier , seq , sha )
12331131 if prev is None :
@@ -1244,7 +1142,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
12441142 common .git_submodule_update (self .proj_path , stdout = stdout , stderr = stdout )
12451143 action_result = self .dispatch_or_raise (ident , incremental = True ,
12461144 stdout = stdout , stderr = stdout )
1247- self .save_build_state (seq , 'incr' , sha , stats , stdout = stdout )
1145+ self .save_build_state (seq , 'incr' , sha , stdout = stdout )
12481146 prev = sha
12491147 seq += 1
12501148 return action_result
0 commit comments