Commit 7736521 1 parent 08a82c0 commit 7736521 Copy full SHA for 7736521
File tree 2 files changed +25
-3
lines changed
2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change 28
28
# of these change. If inputs is empty, the step will run only when the
29
29
# binary itself changes.
30
30
#
31
+ # prefix_with_time_cmd (optional)
32
+ # [bool] If true, the command will be prefixed with "time" to measure the
33
+ # time, CPU and memory usage of the tool, i.e. "time <command>" with
34
+ # appropriate arguments for the current platform.
35
+ #
31
36
# visibility
32
37
# deps
33
38
# args (all optional)
@@ -127,9 +132,15 @@ template("compiled_action") {
127
132
depfile = invoker .depfile
128
133
}
129
134
135
+ args = []
136
+ if (defined (invoker .prefix_with_time_cmd ) && invoker .prefix_with_time_cmd ) {
137
+ args += [" --time" ]
138
+ }
139
+
130
140
# The script takes as arguments the binary to run, and then the arguments
131
141
# to pass it.
132
- args = [ rebase_path (host_executable , root_build_dir ) ] + invoker .args
142
+ args += [ rebase_path (host_executable , root_build_dir ) ]
143
+ args += invoker .args
133
144
}
134
145
}
135
146
Original file line number Diff line number Diff line change 8
8
python gn_run_binary.py <binary_name> [args ...]
9
9
"""
10
10
11
+ import platform
11
12
import sys
12
13
import subprocess
13
14
15
+
16
+ args = []
17
+ basearg = 1
18
+ if sys .argv [1 ] == "--time" :
19
+ basearg = 2
20
+ if (platform .system () == "Linux" ):
21
+ args += ["/usr/bin/time" , "-v" ]
22
+ elif (platform .system () == "Darwin" ):
23
+ args += ["/usr/bin/time" , "-l" ]
24
+
14
25
# This script is designed to run binaries produced by the current build. We
15
26
# always prefix it with "./" to avoid picking up system versions that might
16
27
# also be on the path.
17
- path = './' + sys .argv [1 ]
28
+ path = './' + sys .argv [basearg ]
18
29
19
30
# The rest of the arguements are passed directly to the executable.
20
- args = [path ] + sys .argv [2 :]
31
+ args + = [path ] + sys .argv [basearg + 1 :]
21
32
22
33
try :
23
34
subprocess .check_output (args , stderr = subprocess .STDOUT )
You can’t perform that action at this time.
0 commit comments