Move the impl of run_tool_with_logging into shell_utils.sh
- This lets other shell scripts use it without being a shell function - Simplifies run_tool_with_logging which is now in build/soong/bin Bug: 340648588 Test: atest run_tool_with_logging Change-Id: I1c1c5c1b115f155929c027c2ea82df5da8b190de
This commit is contained in:
parent
997c0b3b77
commit
1f6eddbc35
1 changed files with 23 additions and 0 deletions
|
@ -126,4 +126,27 @@ function _wrap_build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function log_tool_invocation()
|
||||||
|
{
|
||||||
|
if [[ -z $ANDROID_TOOL_LOGGER ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
LOG_TOOL_TAG=$1
|
||||||
|
LOG_START_TIME=$(date +%s.%N)
|
||||||
|
trap '
|
||||||
|
exit_code=$?;
|
||||||
|
# Remove the trap to prevent duplicate log.
|
||||||
|
trap - EXIT;
|
||||||
|
$ANDROID_TOOL_LOGGER \
|
||||||
|
--tool_tag="${LOG_TOOL_TAG}" \
|
||||||
|
--start_timestamp="${LOG_START_TIME}" \
|
||||||
|
--end_timestamp="$(date +%s.%N)" \
|
||||||
|
--tool_args="$*" \
|
||||||
|
--exit_code="${exit_code}" \
|
||||||
|
${ANDROID_TOOL_LOGGER_EXTRA_ARGS} \
|
||||||
|
> /dev/null 2>&1 &
|
||||||
|
exit ${exit_code}
|
||||||
|
' SIGINT SIGTERM SIGQUIT EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue