22
22
import sys
23
23
import json
24
24
import time
25
+ import argparse
25
26
26
27
import common
27
28
@@ -371,8 +372,19 @@ def is_xfailed(xfail_args, compatible_version, platform, swift_branch):
371
372
return None
372
373
373
374
375
+ def str2bool (s ):
376
+ """Convert an argument string into a boolean."""
377
+ if s .lower () == 'true' :
378
+ return True
379
+ elif s .lower () == 'false' :
380
+ return False
381
+ else :
382
+ raise argparse .ArgumentTypeError ('true/false boolean value expected.' )
383
+
384
+
374
385
def add_arguments (parser ):
375
386
"""Add common arguments to parser."""
387
+ parser .register ('type' , 'bool' , str2bool )
376
388
parser .add_argument ('--verbose' ,
377
389
action = 'store_true' )
378
390
# TODO: remove Linux sandbox hack
@@ -456,6 +468,14 @@ def add_arguments(parser):
456
468
dest = 'build_config' ,
457
469
help = 'specify "debug" or "release" to override '
458
470
'the build configuration in the projects.json file' )
471
+ parser .add_argument ("--strip-resource-phases" ,
472
+ help = 'strip all resource phases from project file '
473
+ 'before building (default: true)' ,
474
+ metavar = 'BOOL' ,
475
+ type = 'bool' ,
476
+ nargs = '?' ,
477
+ const = True ,
478
+ default = True )
459
479
460
480
def add_minimal_arguments (parser ):
461
481
"""Add common arguments to parser."""
@@ -766,6 +786,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
766
786
sandbox_profile_package ,
767
787
added_swift_flags ,
768
788
skip_clean , build_config ,
789
+ strip_resource_phases ,
769
790
project , action ):
770
791
self .swiftc = swiftc
771
792
self .swift_version = swift_version
@@ -780,6 +801,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
780
801
self .added_swift_flags = added_swift_flags
781
802
self .skip_clean = skip_clean
782
803
self .build_config = build_config
804
+ self .strip_resource_phases = strip_resource_phases
783
805
self .init ()
784
806
785
807
def init (self ):
@@ -875,7 +897,7 @@ def dispatch(self, identifier, stdout=sys.stdout, stderr=sys.stderr):
875
897
self .added_swift_flags ,
876
898
self .build_config ,
877
899
incremental = self .skip_clean ,
878
- should_strip_resource_phases = True ,
900
+ should_strip_resource_phases = self . strip_resource_phases ,
879
901
stdout = stdout , stderr = stderr )
880
902
except common .ExecuteCommandFailure as error :
881
903
return self .failed (identifier , error )
@@ -1024,6 +1046,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
1024
1046
sandbox_profile_xcodebuild ,
1025
1047
sandbox_profile_package ,
1026
1048
added_swift_flags , build_config ,
1049
+ strip_resource_phases ,
1027
1050
project , action ):
1028
1051
super (IncrementalActionBuilder ,
1029
1052
self ).__init__ (swiftc , swift_version , swift_branch ,
@@ -1032,6 +1055,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
1032
1055
added_swift_flags ,
1033
1056
skip_clean = True ,
1034
1057
build_config = build_config ,
1058
+ strip_resource_phases = strip_resource_phases ,
1035
1059
project = project ,
1036
1060
action = action )
1037
1061
self .proj_path = os .path .join (self .root_path , self .project ['path' ])
0 commit comments