mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Prepend caffeinate to build commands on macOS
When building on macOS, it's better to avoid sleeping with caffeinate by default. This CL prepends `caffeinate` to the build commands, which can be opted out with `--no-caffeinate`. Change-Id: Iacb72acb6523576305b38fe45bfef12f87121a93 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6596109 Reviewed-by: Yiwei Zhang <yiwzhang@google.com> Commit-Queue: Junji Watanabe <jwata@google.com> Reviewed-by: Fumitoshi Ukai <ukai@google.com>
This commit is contained in:
4
OWNERS
4
OWNERS
@@ -29,7 +29,6 @@ per-file gn*=dpranke@google.com
|
||||
per-file gn*=file://BUILD_OWNERS
|
||||
|
||||
# Siso
|
||||
per-file autosiso*=file://BUILD_OWNERS
|
||||
per-file siso*=file://BUILD_OWNERS
|
||||
|
||||
# reclient
|
||||
@@ -39,6 +38,9 @@ per-file reclient*=file://RECLIENT_OWNERS
|
||||
# Build telemetry
|
||||
per-file build_telemetry*=file://BUILD_OWNERS
|
||||
|
||||
# Build util
|
||||
per-file caffeinate.py=file://BUILD_OWNERS
|
||||
|
||||
# Bazel
|
||||
per-file bazel*=file://CROS_OWNERS
|
||||
per-file bazel*=file://BUILD_OWNERS
|
||||
|
||||
21
caffeinate.py
Normal file
21
caffeinate.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2025 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
_NO_CAFFEINATE_FLAG = '--no-caffeinate'
|
||||
|
||||
|
||||
def run(cmd, env=None):
|
||||
"""Runs a command with `caffeinate` if it's on macOS."""
|
||||
if sys.platform == 'darwin':
|
||||
if _NO_CAFFEINATE_FLAG in cmd:
|
||||
cmd.remove(_NO_CAFFEINATE_FLAG)
|
||||
else:
|
||||
cmd = ['caffeinate'] + cmd
|
||||
print(
|
||||
f"\033[33mBuilding with `caffeinate`. Use {_NO_CAFFEINATE_FLAG} to disable it.\033[0m"
|
||||
)
|
||||
return subprocess.call(cmd, env=env)
|
||||
6
ninja.py
6
ninja.py
@@ -8,9 +8,9 @@ binary when run inside a gclient source tree, so users can just type
|
||||
"ninja" on the command line."""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import caffeinate
|
||||
import gclient_paths
|
||||
import gn_helper
|
||||
|
||||
@@ -73,7 +73,7 @@ def fallback(ninja_args):
|
||||
ninja_path = find_ninja_in_path()
|
||||
if ninja_path:
|
||||
check_out_dir(ninja_args)
|
||||
return subprocess.call([ninja_path] + ninja_args)
|
||||
return caffeinate.run([ninja_path] + ninja_args)
|
||||
|
||||
print(
|
||||
"depot_tools/ninja.py: Could not find Ninja in the third_party of "
|
||||
@@ -124,7 +124,7 @@ def main(args):
|
||||
)
|
||||
if os.path.isfile(ninja_path):
|
||||
check_out_dir(args[1:])
|
||||
return subprocess.call([ninja_path] + args[1:])
|
||||
return caffeinate.run([ninja_path] + args[1:])
|
||||
|
||||
return fallback(args[1:])
|
||||
|
||||
|
||||
6
siso.py
6
siso.py
@@ -10,9 +10,9 @@ binary when run inside a gclient source tree, so users can just type
|
||||
import os
|
||||
import signal
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import caffeinate
|
||||
import gclient_paths
|
||||
|
||||
|
||||
@@ -151,14 +151,14 @@ def main(args):
|
||||
for siso_path in siso_paths:
|
||||
if siso_path and os.path.isfile(siso_path):
|
||||
checkOutdir(args[1:])
|
||||
return subprocess.call([siso_path] + args[1:], env=env)
|
||||
return caffeinate.run([siso_path] + args[1:], env=env)
|
||||
print(
|
||||
'depot_tools/siso.py: Could not find siso in third_party/siso '
|
||||
'of the current project. Did you run gclient sync?',
|
||||
file=sys.stderr)
|
||||
return 1
|
||||
if siso_override_path:
|
||||
return subprocess.call([siso_override_path] + args[1:])
|
||||
return caffeinate.run([siso_override_path] + args[1:])
|
||||
|
||||
print(
|
||||
'depot_tools/siso.py: Could not find .sisoenv under build/config/siso '
|
||||
|
||||
Reference in New Issue
Block a user