Skip to content

Commit 36b562d

Browse files
authored
Merge pull request #23803 from drodriguez/build-script-move-call-without-sleeping
2 parents d390ac7 + a92eff8 commit 36b562d

File tree

3 files changed

+21
-34
lines changed

3 files changed

+21
-34
lines changed

utils/build-parser-lib

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ from swift_build_support.swift_build_support.toolchain import host_toolchain
4242

4343
isMac = platform.system() == 'Darwin'
4444

45-
def call_without_sleeping(command, env=None, dry_run=False, echo=False):
46-
"""
47-
Execute a command during which system sleep is disabled.
48-
49-
By default, this ignores the state of the `shell.dry_run` flag.
50-
"""
51-
52-
# Disable system sleep, if possible.
53-
if platform.system() == 'Darwin':
54-
# Don't mutate the caller's copy of the arguments.
55-
command = ["caffeinate"] + list(command)
56-
57-
shell.call(command, env=env, dry_run=dry_run, echo=echo)
58-
5945
class Builder(object):
6046
def __init__(self, toolchain, args):
6147
self.toolchain = toolchain
@@ -76,7 +62,7 @@ class Builder(object):
7662

7763
def call(self, command, env=None, without_sleeping=False):
7864
if without_sleeping:
79-
call_without_sleeping(command, env=env, dry_run=self.dry_run, echo=self.verbose)
65+
shell.call_without_sleeping(command, env=env, dry_run=self.dry_run, echo=self.verbose)
8066
else:
8167
shell.call(command, env=env, dry_run=self.dry_run, echo=self.verbose)
8268

utils/build-script

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,6 @@ def exit_rejecting_arguments(message, parser=None):
5656
sys.exit(2) # 2 is the same as `argparse` error exit code.
5757

5858

59-
def call_without_sleeping(command, env=None, dry_run=False, echo=False):
60-
"""
61-
Execute a command during which system sleep is disabled.
62-
63-
By default, this ignores the state of the `shell.dry_run` flag.
64-
"""
65-
66-
# Disable system sleep, if possible.
67-
if platform.system() == 'Darwin':
68-
# Don't mutate the caller's copy of the arguments.
69-
command = ["caffeinate"] + list(command)
70-
71-
shell.call(command, env=env, dry_run=dry_run, echo=echo)
72-
73-
7459
class HostSpecificConfiguration(object):
7560

7661
"""Configuration information for an individual host."""
@@ -906,8 +891,8 @@ class BuildScriptInvocation(object):
906891
# `build-script-impl`.
907892
if self.args.legacy_impl:
908893
# Execute the underlying build script implementation.
909-
call_without_sleeping([build_script_impl] + impl_args,
910-
env=impl_env, echo=True)
894+
shell.call_without_sleeping([build_script_impl] + impl_args,
895+
env=impl_env, echo=True)
911896
return
912897

913898
# Otherwise, we compute and execute the individual actions ourselves.
@@ -924,7 +909,7 @@ class BuildScriptInvocation(object):
924909
assert name is not None, "invalid action"
925910
action_name = "{}-{}-{}".format(
926911
host.name, product_class.product_name(), name)
927-
call_without_sleeping(
912+
shell.call_without_sleeping(
928913
[build_script_impl] + impl_args + [
929914
"--only-execute", action_name],
930915
env=impl_env, echo=self.args.verbose_build)
@@ -1143,7 +1128,7 @@ def main_preset():
11431128
if args.expand_build_script_invocation:
11441129
return 0
11451130

1146-
call_without_sleeping(build_script_args)
1131+
shell.call_without_sleeping(build_script_args)
11471132
return 0
11481133

11491134

utils/swift_build_support/swift_build_support/shell.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import os
1919
import pipes
20+
import platform
2021
import shutil
2122
import subprocess
2223
import sys
@@ -93,6 +94,21 @@ def call(command, stderr=None, env=None, dry_run=None, echo=True):
9394
"': " + e.strerror)
9495

9596

97+
def call_without_sleeping(command, env=None, dry_run=False, echo=False):
98+
"""
99+
Execute a command during which system sleep is disabled.
100+
101+
By default, this ignores the state of the `shell.dry_run` flag.
102+
"""
103+
104+
# Disable system sleep, if possible.
105+
if platform.system() == 'Darwin':
106+
# Don't mutate the caller's copy of the arguments.
107+
command = ["caffeinate"] + list(command)
108+
109+
call(command, env=env, dry_run=dry_run, echo=echo)
110+
111+
96112
def capture(command, stderr=None, env=None, dry_run=None, echo=True,
97113
optional=False, allow_non_zero_exit=False):
98114
"""

0 commit comments

Comments
 (0)