Skip to content

Commit a4a081e

Browse files
committed
Log build-script calls to .build_script_log file to help understand the build
times for each command. (cherry picked from commit 0809796)
1 parent 2ca3c73 commit a4a081e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

utils/build-script

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,11 @@ def main_normal():
13781378
# Create build directory.
13791379
shell.makedirs(invocation.workspace.build_root)
13801380

1381+
# Create .build_script_log.
1382+
build_script_log = os.path.join(invocation.workspace.build_root,
1383+
".build_script_log")
1384+
open(build_script_log, 'w').close()
1385+
13811386
# Build ninja if required, which will update the toolchain.
13821387
if args.build_ninja:
13831388
invocation.build_ninja()

utils/build-script-impl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,16 @@ for component in ${components[@]} ; do
260260
)
261261
done
262262

263+
function log_event() {
264+
build_script_log_path=${BUILD_DIR}/.build_script_log
265+
event_type=$1
266+
event_command=$2
267+
evnet_duration=$3
268+
269+
build_event="{\"event\":\"${event_type}\", \"command\":\"${event_command}\", \"duration\":\"${evnet_duration}\"}"
270+
echo "${build_event}" >> ${build_script_log_path}
271+
}
272+
263273
# Centralized access point for traced command invocation.
264274
# Every operation that might mutates file system should be called via
265275
# these functions.
@@ -268,10 +278,14 @@ function call() {
268278
if [[ ${DRY_RUN} ]] || [[ "${VERBOSE_BUILD}" ]]; then
269279
echo "${PS4}"$(quoted_print "$@")
270280
fi
281+
282+
SECONDS=0
271283
if [[ ! ${DRY_RUN} ]]; then
284+
log_event "start" "$(quoted_print "$@")" "${SECONDS}"
272285
{ set -x; } 2>/dev/null
273286
"$@"
274287
{ set +x; } 2>/dev/null
288+
log_event "finish" "$(quoted_print "$@")" "${SECONDS}"
275289
fi
276290
}
277291

0 commit comments

Comments
 (0)