diff options
Diffstat (limited to 'binary_search_tool/android/generate_cmd.sh')
-rwxr-xr-x | binary_search_tool/android/generate_cmd.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/binary_search_tool/android/generate_cmd.sh b/binary_search_tool/android/generate_cmd.sh new file mode 100755 index 00000000..eaae738b --- /dev/null +++ b/binary_search_tool/android/generate_cmd.sh @@ -0,0 +1,41 @@ +#!/bin/bash -u + +# Copyright 2018 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This script extracts command line options to build bad item. +# The generated script will be used by pass level bisection. +# + +source android/common.sh + +abs_path=$1 + +# The item will be `-o relative-path-to-object `, which will be used +# for seeking command in populate log. +# We care about the `-o` at the beginning and ` ` at the end are necessary, +# so that we can get build command for exact this object file. +# Example: prebuilt/../clang++ -O3 -MF obj1.o.d -o obj.o obj.cpp +# We should count this command as one to build obj.o, not obj1.o.d. +real_path=$(realpath --relative-to="${BISECT_WORK_BUILD}" "${abs_path}") +item="-o $real_path " + +populate_log=${BISECT_BAD_BUILD}/_POPULATE_LOG + +output='#!/bin/bash -u\n' +output+='source android/common.sh\n' + +result=$(egrep -m 1 -- "${item}" ${populate_log}) + +# Remove `:` after cd command +result=$(sed 's/cd\:/cd/g' <<< ${result}) + +# Add environment variable which helps pass level bisection +result=$(sed 's/ \-o / $LIMIT_FLAGS \-o /g' <<< ${result}) + +output+=${result} + +echo -e "${output}" > android/cmd_script.sh + +echo 'Script created as android/cmd_script.sh' |