# Codecov.sh does not work for GN/NInja builds

**URL:** <https://community.codecov.com/t/codecov-sh-does-not-work-for-gn-ninja-builds/396>\
**Category:** Bug Fixes\
**Tags:** cpp\
**Created:** [July 28, 2019, 5:04pm UTC](https://community.codecov.com/t/codecov-sh-does-not-work-for-gn-ninja-builds/396 "2019-07-28T17:04:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiller-isp](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/amiller-isp/32/497_2.png) [@amiller-isp](https://community.codecov.com/u/amiller-isp)\
**Post date:** [July 28, 2019, 5:04pm UTC](https://community.codecov.com/t/codecov-sh-does-not-work-for-gn-ninja-builds/396/1 "2019-07-28T17:04:40Z")

</div>

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
```
