So I spent a lot of time trying to get codecov.sh to work for my gn/ninja build and was eventually forced to change the script. Ninja runs compilation steps from the output directory. gcov needs to run in the same directory as compilation so find
with -execdir
is not the right thing to do.
The following works for GN/Ninja builds. It has the added advantage of printing out each directory gcov is running on so it’s much easier to understand where errors are occurring.
codecov.sh:978
# Gcov Coverage
if [ "$ft_gcov" = "1" ];
then
say "${e}==>${x} Running gcov in $proj_root ${e}(disable via -X gcov)${x}"
# The original script uses find -execdir to run gcov in each directory containing .gcno files. This does not
# work in our case as the paths do not resolve correctly. gcov should be run from the same directory as the original
# build ran in. This script runs gcov in the project directory and passes the relative paths to each directory
# container .gcno files.
# Original code:
# bash -c "find $proj_root -type f -name '*.gcno' $gcov_include $gcov_ignore -execdir $gcov_exe -pb $gcov_arg {} +" || true
# Start of corrected code:
pushd $proj_root
dirs=$(find . -type f -name '*.gcno' $gcov_include $gcov_ignore | sed -r 's|/[^/]+$||' | sort | uniq)
for d in ${dirs}
do
echo "Running gcov on ${d}:"
$gcov_exe -pb $gcov_arg ${d}/*.gcno
done
popd
# End of corrected code
else
say "${e}==>${x} gcov disabled"
fi