mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[build-script] Prevent sleeping while building.
I've only implemented this for OS X, which comes with the 'caffeinate' command. If anyone would like to implement something similar for Linux, feel free. (Although please make sure that it's signal-safe, i.e. if the build is interrupted the computer's sleep settings return to normal.)
This commit is contained in:
@@ -19,6 +19,7 @@ except ImportError:
|
||||
|
||||
import os
|
||||
import pipes
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -72,7 +73,13 @@ def quote_shell_command(args):
|
||||
return " ".join([pipes.quote(a) for a in args])
|
||||
|
||||
|
||||
def check_call(args, print_command=False, verbose=False):
|
||||
def check_call(args, print_command=False, verbose=False, disable_sleep=False):
|
||||
if disable_sleep:
|
||||
if platform.system() == 'Darwin':
|
||||
# Don't mutate the caller's copy of the arguments.
|
||||
args = list(args)
|
||||
args.insert(0, "caffeinate")
|
||||
|
||||
if print_command:
|
||||
print(os.getcwd() + "$ " + quote_shell_command(args))
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user