2222import sys
2323import json
2424import time
25+ import argparse
2526
2627import common
2728
@@ -371,8 +372,19 @@ def is_xfailed(xfail_args, compatible_version, platform, swift_branch):
371372 return None
372373
373374
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+
374385def add_arguments (parser ):
375386 """Add common arguments to parser."""
387+ parser .register ('type' , 'bool' , str2bool )
376388 parser .add_argument ('--verbose' ,
377389 action = 'store_true' )
378390 # TODO: remove Linux sandbox hack
@@ -456,6 +468,14 @@ def add_arguments(parser):
456468 dest = 'build_config' ,
457469 help = 'specify "debug" or "release" to override '
458470 '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 )
459479
460480def add_minimal_arguments (parser ):
461481 """Add common arguments to parser."""
@@ -766,6 +786,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
766786 sandbox_profile_package ,
767787 added_swift_flags ,
768788 skip_clean , build_config ,
789+ strip_resource_phases ,
769790 project , action ):
770791 self .swiftc = swiftc
771792 self .swift_version = swift_version
@@ -780,6 +801,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
780801 self .added_swift_flags = added_swift_flags
781802 self .skip_clean = skip_clean
782803 self .build_config = build_config
804+ self .strip_resource_phases = strip_resource_phases
783805 self .init ()
784806
785807 def init (self ):
@@ -875,7 +897,7 @@ def dispatch(self, identifier, stdout=sys.stdout, stderr=sys.stderr):
875897 self .added_swift_flags ,
876898 self .build_config ,
877899 incremental = self .skip_clean ,
878- should_strip_resource_phases = True ,
900+ should_strip_resource_phases = self . strip_resource_phases ,
879901 stdout = stdout , stderr = stderr )
880902 except common .ExecuteCommandFailure as error :
881903 return self .failed (identifier , error )
@@ -1024,6 +1046,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
10241046 sandbox_profile_xcodebuild ,
10251047 sandbox_profile_package ,
10261048 added_swift_flags , build_config ,
1049+ strip_resource_phases ,
10271050 project , action ):
10281051 super (IncrementalActionBuilder ,
10291052 self ).__init__ (swiftc , swift_version , swift_branch ,
@@ -1032,6 +1055,7 @@ def __init__(self, swiftc, swift_version, swift_branch,
10321055 added_swift_flags ,
10331056 skip_clean = True ,
10341057 build_config = build_config ,
1058+ strip_resource_phases = strip_resource_phases ,
10351059 project = project ,
10361060 action = action )
10371061 self .proj_path = os .path .join (self .root_path , self .project ['path' ])
0 commit comments