Skip to content

Commit 0809796

Browse files
committed
Log build-script calls to .build_script_log file to help understand the build
times for each command.
1 parent 794afba commit 0809796

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
@@ -1351,6 +1351,11 @@ def main_normal():
13511351
# Create build directory.
13521352
shell.makedirs(invocation.workspace.build_root)
13531353

1354+
# Create .build_script_log.
1355+
build_script_log = os.path.join(invocation.workspace.build_root,
1356+
".build_script_log")
1357+
open(build_script_log, 'w').close()
1358+
13541359
# Build ninja if required, which will update the toolchain.
13551360
if args.build_ninja:
13561361
invocation.build_ninja()

utils/build-script-impl

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

260+
function log_event() {
261+
build_script_log_path=${BUILD_DIR}/.build_script_log
262+
event_type=$1
263+
event_command=$2
264+
evnet_duration=$3
265+
266+
build_event="{\"event\":\"${event_type}\", \"command\":\"${event_command}\", \"duration\":\"${evnet_duration}\"}"
267+
echo "${build_event}" >> ${build_script_log_path}
268+
}
269+
260270
# Centralized access point for traced command invocation.
261271
# Every operation that might mutates file system should be called via
262272
# these functions.
@@ -265,10 +275,14 @@ function call() {
265275
if [[ ${DRY_RUN} ]] || [[ "${VERBOSE_BUILD}" ]]; then
266276
echo "${PS4}"$(quoted_print "$@")
267277
fi
278+
279+
SECONDS=0
268280
if [[ ! ${DRY_RUN} ]]; then
281+
log_event "start" "$(quoted_print "$@")" "${SECONDS}"
269282
{ set -x; } 2>/dev/null
270283
"$@"
271284
{ set +x; } 2>/dev/null
285+
log_event "finish" "$(quoted_print "$@")" "${SECONDS}"
272286
fi
273287
}
274288

0 commit comments

Comments
 (0)