Skip to content

Commit

Permalink
Allow command execution under /usr/bin/time for stats collections (#…
Browse files Browse the repository at this point in the history
…909)

This should help further troubleshoot
flutter/flutter#154437
  • Loading branch information
aam authored Oct 9, 2024
1 parent 08a82c0 commit 7736521
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 12 additions & 1 deletion build/compiled_action.gni
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
# of these change. If inputs is empty, the step will run only when the
# binary itself changes.
#
# prefix_with_time_cmd (optional)
# [bool] If true, the command will be prefixed with "time" to measure the
# time, CPU and memory usage of the tool, i.e. "time <command>" with
# appropriate arguments for the current platform.
#
# visibility
# deps
# args (all optional)
Expand Down Expand Up @@ -127,9 +132,15 @@ template("compiled_action") {
depfile = invoker.depfile
}

args = []
if (defined(invoker.prefix_with_time_cmd) && invoker.prefix_with_time_cmd) {
args += ["--time"]
}

# The script takes as arguments the binary to run, and then the arguments
# to pass it.
args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args
args += [ rebase_path(host_executable, root_build_dir) ]
args += invoker.args
}
}

Expand Down
15 changes: 13 additions & 2 deletions build/gn_run_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@
python gn_run_binary.py <binary_name> [args ...]
"""

import platform
import sys
import subprocess


args = []
basearg = 1
if sys.argv[1] == "--time":
basearg = 2
if (platform.system() == "Linux"):
args += ["/usr/bin/time", "-v"]
elif (platform.system() == "Darwin"):
args += ["/usr/bin/time", "-l"]

# This script is designed to run binaries produced by the current build. We
# always prefix it with "./" to avoid picking up system versions that might
# also be on the path.
path = './' + sys.argv[1]
path = './' + sys.argv[basearg]

# The rest of the arguements are passed directly to the executable.
args = [path] + sys.argv[2:]
args += [path] + sys.argv[basearg + 1:]

try:
subprocess.check_output(args, stderr=subprocess.STDOUT)
Expand Down

0 comments on commit 7736521

Please sign in to comment.