Skip to content

Cannot open source file #150

@lc-soft

Description

@lc-soft

travis-ci log: https://travis-ci.org/lc-soft/LCUI/jobs/644692385

image

Related code:

if not os.path.isabs(source_file_path):
if args.build_root:
source_file_path = os.path.join(
args.build_root, source_file_path)
elif root_is_libtool_dir:
source_file_path = os.path.abspath(
libtool_source_file_path(
root, source_file_path))
else:
if not source_file_path.startswith(os.path.pardir + os.path.sep) and \
os.path.dirname(source_file_path):
the_root = abs_root
else:
the_root = root
source_file_path = os.path.abspath(
os.path.join(the_root, source_file_path))

The value of source_file_path should be "/home/travis/build/lc-soft/LCUI/src/gui/widget/canvas.c", not "/home/travis/build/lc-soft/LCUI/widget/canvas.c".

The gcov file content looks like this:

$ cat src/gui/widget/canvas.gcno\#\#widget\#canvas.c.gcov 
        -:    0:Source:widget/canvas.c
        -:    0:Graph:/home/lc/projects/LCUI/src/gui/widget/.libs/canvas.gcno
        -:    0:Data:/home/lc/projects/LCUI/src/gui/widget/.libs/canvas.gcda
...

The path of the source file recorded in the gcov file is relative to the Makefile, maybe you need to modify the file path generation rules, like this pseudo code:

- source_file_path = os.path.join(current_dir_path, source_file_path)
+ source_file_path = os.path.join(makefile_dir_path, source_file_path) 

I tried using the gcov command manually, The file list now looks like this:

./Makefile
./src/Makefile
./src/thread/Makefile
./src/thread/pthread/thread.c
./src/thread/pthread/.libs/thread.gcda
./src/thread/pthread/.libs/thread.gcno

Using the following command will successfully create the ./src/thread/pthread.c.gcov file,

$ cd src/thread/
$ gcov -o ./pthread/.libs pthread/thread.c
File 'pthread/thread.c'
Lines executed:80.00% of 50
Creating 'thread.c.gcov'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions