[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:
Jordan Rose
2016-04-15 17:57:50 -07:00
parent e1a5bcfdfd
commit a178d0faa2
2 changed files with 11 additions and 3 deletions

View File

@@ -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: