@@ -28,7 +28,6 @@ from SwiftBuildSupport import (
28
28
HOME ,
29
29
SWIFT_BUILD_ROOT ,
30
30
SWIFT_SOURCE_ROOT ,
31
- check_call ,
32
31
get_all_preset_names ,
33
32
get_preset_options ,
34
33
) # noqa (E402 module level import not at top of file)
@@ -51,6 +50,21 @@ from swift_build_support.workspace import Workspace # noqa(E402)
51
50
from swift_build_support .workspace import compute_build_subdir # noqa(E402)
52
51
53
52
53
+ def call_without_sleeping (command , dry_run = False ):
54
+ """
55
+ Execute a command during which system sleep is disabled.
56
+
57
+ By default, this ignores the state of the `shell.dry_run` flag.
58
+ """
59
+
60
+ # Disable system sleep, if possible.
61
+ if platform .system () == 'Darwin' :
62
+ # Don't mutate the caller's copy of the arguments.
63
+ command = ["caffeinate" ] + list (command )
64
+
65
+ shell .call (command , dry_run = dry_run , print_command = False )
66
+
67
+
54
68
# Main entry point for the preset mode.
55
69
def main_preset ():
56
70
parser = argparse .ArgumentParser (
@@ -124,7 +138,7 @@ def main_preset():
124
138
"using preset '" + args .preset + "', which expands to \n \n " +
125
139
shell .quote_command (build_script_args ) + "\n " )
126
140
127
- check_call (build_script_args , disable_sleep = True )
141
+ call_without_sleeping (build_script_args )
128
142
129
143
return 0
130
144
@@ -1429,8 +1443,7 @@ details of the setups of other systems or automated environments.""")
1429
1443
if args .dry_run :
1430
1444
build_script_impl_args += ["--dry-run" ]
1431
1445
1432
- check_call ([build_script_impl ] + build_script_impl_args ,
1433
- disable_sleep = True )
1446
+ call_without_sleeping ([build_script_impl ] + build_script_impl_args )
1434
1447
1435
1448
if args .symbols_package :
1436
1449
print ('--- Creating symbols package ---' )
0 commit comments