@@ -203,8 +203,8 @@ def clean_swift_package(path, swiftc, sandbox_profile,
203
203
204
204
def build_swift_package (path , swiftc , configuration , sandbox_profile ,
205
205
stdout = sys .stdout , stderr = sys .stderr ,
206
- incremental = False ,
207
- stats_path = None ):
206
+ added_swift_flags = None ,
207
+ incremental = False ):
208
208
"""Build a Swift package manager project."""
209
209
swift = swiftc [:- 1 ]
210
210
if not incremental :
@@ -214,12 +214,12 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
214
214
env ['SWIFT_EXEC' ] = swiftc
215
215
command = [swift , 'build' , '-C' , path , '--verbose' ,
216
216
'--configuration' , configuration ]
217
- if stats_path is not None :
218
- command += ['-Xswiftc' , '-stats-output-dir' ,
219
- '-Xswiftc' , stats_path ]
220
217
if (swift_branch not in ['swift-3.0-branch' ,
221
218
'swift-3.1-branch' ]):
222
219
command .insert (2 , '--disable-sandbox' )
220
+ if added_swift_flags is not None :
221
+ for flag in added_swift_flags .split ():
222
+ command += ["-Xswiftc" , flag ]
223
223
return common .check_execute (command , timeout = 3600 ,
224
224
sandbox_profile = sandbox_profile ,
225
225
stdout = stdout , stderr = stderr ,
@@ -228,18 +228,18 @@ def build_swift_package(path, swiftc, configuration, sandbox_profile,
228
228
229
229
def test_swift_package (path , swiftc , sandbox_profile ,
230
230
stdout = sys .stdout , stderr = sys .stderr ,
231
- incremental = False ,
232
- stats_path = None ):
231
+ added_swift_flags = None ,
232
+ incremental = False ):
233
233
"""Test a Swift package manager project."""
234
234
swift = swiftc [:- 1 ]
235
235
if not incremental :
236
236
clean_swift_package (path , swiftc , sandbox_profile )
237
237
env = os .environ
238
238
env ['SWIFT_EXEC' ] = swiftc
239
239
command = [swift , 'test' , '-C' , path , '--verbose' ]
240
- if stats_path is not None :
241
- command += [ '-Xswiftc' , '-stats-output-dir' ,
242
- ' -Xswiftc' , stats_path ]
240
+ if added_swift_flags is not None :
241
+ for flag in added_swift_flags . split ():
242
+ command += [ " -Xswiftc" , flag ]
243
243
return common .check_execute (command , timeout = 3600 ,
244
244
sandbox_profile = sandbox_profile ,
245
245
stdout = stdout , stderr = stderr ,
@@ -274,31 +274,24 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
274
274
sandbox_profile_xcodebuild , sandbox_profile_package ,
275
275
added_swift_flags , should_strip_resource_phases = False ,
276
276
stdout = sys .stdout , stderr = sys .stderr ,
277
- incremental = False ,
278
- stats_path = None ):
277
+ incremental = False ):
279
278
"""Call functions corresponding to actions."""
280
279
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
-
287
280
if action ['action' ] == 'BuildSwiftPackage' :
288
281
return build_swift_package (os .path .join (root_path , repo ['path' ]),
289
282
swiftc ,
290
283
action ['configuration' ],
291
284
sandbox_profile_package ,
292
285
stdout = stdout , stderr = stderr ,
293
- incremental = incremental ,
294
- stats_path = stats_path )
286
+ added_swift_flags = added_swift_flags ,
287
+ incremental = incremental )
295
288
elif action ['action' ] == 'TestSwiftPackage' :
296
289
return test_swift_package (os .path .join (root_path , repo ['path' ]),
297
290
swiftc ,
298
291
sandbox_profile_package ,
299
292
stdout = stdout , stderr = stderr ,
300
- incremental = incremental ,
301
- stats_path = stats_path )
293
+ added_swift_flags = added_swift_flags ,
294
+ incremental = incremental )
302
295
elif re .match (r'^(Build|Test)Xcode(Workspace|Project)(Scheme|Target)$' ,
303
296
action ['action' ]):
304
297
match = re .match (
@@ -315,8 +308,6 @@ def dispatch(root_path, repo, action, swiftc, swift_version,
315
308
if swift_version :
316
309
other_swift_flags += ['-swift-version' , swift_version ]
317
310
build_settings ['SWIFT_VERSION' ] = swift_version
318
- if stats_path is not None :
319
- other_swift_flags += ['-stats-output-dir' , stats_path ]
320
311
if added_swift_flags :
321
312
other_swift_flags .append (added_swift_flags )
322
313
if other_swift_flags :
@@ -438,12 +429,6 @@ def add_arguments(parser):
438
429
parser .add_argument ("--test-incremental" ,
439
430
help = 'test incremental-mode over multiple commits' ,
440
431
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' )
447
432
parser .add_argument ("--add-swift-flags" ,
448
433
metavar = "FLAGS" ,
449
434
help = 'add flags to each Swift invocation' ,
@@ -1008,59 +993,13 @@ def have_same_trees(full, incr, d):
1008
993
ok = have_same_trees (full , incr , sub ) and ok
1009
994
return ok
1010
995
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 )
1055
996
1056
997
class IncrementalActionBuilder (ActionBuilder ):
1057
998
1058
999
def __init__ (self , swiftc , swift_version , swift_branch ,
1059
1000
sandbox_profile_xcodebuild ,
1060
1001
sandbox_profile_package ,
1061
1002
added_swift_flags ,
1062
- check_stats ,
1063
- show_stats ,
1064
1003
project , action ):
1065
1004
super (IncrementalActionBuilder ,
1066
1005
self ).__init__ (swiftc , swift_version , swift_branch ,
@@ -1070,15 +1009,8 @@ def __init__(self, swiftc, swift_version, swift_branch,
1070
1009
skip_clean = True ,
1071
1010
project = project ,
1072
1011
action = action )
1073
- self .check_stats = check_stats
1074
- self .show_stats = show_stats
1075
- self .stats_path = None
1076
- self .stats_summ = None
1077
1012
self .proj_path = os .path .join (self .root_path , self .project ['path' ])
1078
1013
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 ()
1082
1014
1083
1015
def curr_build_state_path (self ):
1084
1016
if self .action ['action' ] == 'BuildSwiftPackage' :
@@ -1111,10 +1043,6 @@ def saved_build_state_path(self, seq, flav, sha):
1111
1043
return os .path .join (self .incr_path , ("build-state-%03d-%s-%.7s" %
1112
1044
(seq , flav , sha )))
1113
1045
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
-
1118
1046
def restore_saved_build_state (self , seq , flav , sha , stdout = sys .stdout ):
1119
1047
src = self .saved_build_state_path (seq , flav , sha )
1120
1048
dst = self .curr_build_state_path ()
@@ -1125,7 +1053,7 @@ def restore_saved_build_state(self, seq, flav, sha, stdout=sys.stdout):
1125
1053
shutil .rmtree (dst )
1126
1054
shutil .copytree (src , dst , symlinks = True )
1127
1055
1128
- def save_build_state (self , seq , flav , sha , stats , stdout = sys .stdout ):
1056
+ def save_build_state (self , seq , flav , sha , stdout = sys .stdout ):
1129
1057
src = self .curr_build_state_path ()
1130
1058
dst = self .saved_build_state_path (seq , flav , sha )
1131
1059
proj = self .project ['path' ]
@@ -1134,17 +1062,6 @@ def save_build_state(self, seq, flav, sha, stats, stdout=sys.stdout):
1134
1062
if os .path .exists (dst ):
1135
1063
shutil .rmtree (dst )
1136
1064
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 )
1148
1065
1149
1066
def check_full_vs_incr (self , seq , sha , stdout = sys .stdout ):
1150
1067
full = self .saved_build_state_path (seq , 'full' , sha )
@@ -1182,9 +1099,6 @@ def build(self, stdout=sys.stdout):
1182
1099
stdout = stdout )
1183
1100
except EarlyExit as error :
1184
1101
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 )
1188
1102
return action_result
1189
1103
1190
1104
def dispatch (self , identifier , incremental , stdout = sys .stdout , stderr = sys .stderr ):
@@ -1197,8 +1111,7 @@ def dispatch(self, identifier, incremental, stdout=sys.stdout, stderr=sys.stderr
1197
1111
self .added_swift_flags ,
1198
1112
should_strip_resource_phases = False ,
1199
1113
stdout = stdout , stderr = stderr ,
1200
- incremental = incremental ,
1201
- stats_path = self .stats_path )
1114
+ incremental = incremental )
1202
1115
except common .ExecuteCommandFailure as error :
1203
1116
return self .failed (identifier , error )
1204
1117
else :
@@ -1222,12 +1135,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
1222
1135
prev = None
1223
1136
seq = 0
1224
1137
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 )
1138
+ for sha in commits :
1231
1139
proj = self .project ['path' ]
1232
1140
ident = "%s-%03d-%.7s" % (identifier , seq , sha )
1233
1141
if prev is None :
@@ -1244,7 +1152,7 @@ def build_incremental(self, identifier, commits, stdout=sys.stdout):
1244
1152
common .git_submodule_update (self .proj_path , stdout = stdout , stderr = stdout )
1245
1153
action_result = self .dispatch_or_raise (ident , incremental = True ,
1246
1154
stdout = stdout , stderr = stdout )
1247
- self .save_build_state (seq , 'incr' , sha , stats , stdout = stdout )
1155
+ self .save_build_state (seq , 'incr' , sha , stdout = stdout )
1248
1156
prev = sha
1249
1157
seq += 1
1250
1158
return action_result
0 commit comments