Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: tankist02 on September 18, 2011, 10:22:41 pm

Title: What's up with .depend files?
Post by: tankist02 on September 18, 2011, 10:22:41 pm
First of all many thanks for developers who created such a great product and then gave it out for free. I started using CB about a month ago and except for this particular issue found it quite useful.

Here is my problem - .depend files for all my projects contain only the following line:

# depslib dependency file v1.0

Because of that if a header file is changed I have to rebuild the whole workspace to guarantee to get the changes.

I did many builds/rebuilds for both Debug and Release mode using the global workspace or individual projects. I noticed that sometimes a project .depend would contain correct dependencies information, but then it would be gone after next edit/build. I couldn't observe any logic in how/when dependencies are generated (or rather not).

Editing .cpp files works fine - relevant libraries are built and dependent programs relinked.

I searched Internet and these forums for the topic and found a couple similar complains without any resolution.

BTW I have a parallel set of regular Makefiles that utilize recommended generation/usage of .d files - and this setup works correctly for the same source code.

My system:

30 C++ projects organized into one global workspace
CodeBlocks 10.05
Scientific Linux 6.1 x86_64

Any help would be greatly appreciated.
Title: Re: What's up with .depend files?
Post by: Alpha on September 18, 2011, 10:37:43 pm
Is this (http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks#Using_project_dependencies) what you are looking for?

You could also try Project->Properties...->Build targets (tab)->Dependencies... and add all the used header files as External dependency files (this would have to be done on all relevant projects).
Title: Re: What's up with .depend files?
Post by: tankist02 on September 19, 2011, 03:12:34 am
I am not looking for how to set up inter-project dependencies. I did it and it works great. What I am looking for is how/when .depend files are generated. These files contain dependencies at the source code level, e.g. which .cpp files depend on which .h files. For some reason in my case all .depend files are empty, so when a header file is modified .cpp files that depend on it are not re-compiled.

Probably generation of .depend files happens at the Preprocessing phase (from the link you provided). Unfortunately there are no more details about what exactly going on at this phase.

Any other ideas/pointers?
Title: Re: What's up with .depend files?
Post by: tankist02 on September 19, 2011, 03:19:34 am
More details about my setup:

In Toolchain executables I set to use ccache to speed up compilation:

C compiler: ccache_gcc
C++ compiler: ccache_g++

where ccache_gcc is the following script:

Code
#!/bin/sh

## Invoke g++ with ccache and pass all parameters to them
ccache gcc "$@"

and

ccache_g++:

Code
#!/bin/sh

## Invoke g++ with ccache and pass all parameters to them
ccache g++ "$@"


Title: Re: What's up with .depend files?
Post by: Alpha on September 19, 2011, 04:57:00 am
What I am looking for is how/when .depend files are generated. These files contain dependencies at the source code level, e.g. which .cpp files depend on which .h files. For some reason in my case all .depend files are empty, so when a header file is modified .cpp files that depend on it are not re-compiled.
OK, that makes sense; unfortunately I do not have much experience with .depend files.
Have you tried
You could also try Project->Properties...->Build targets (tab)->Dependencies...
Sometimes I find that simply opening the External dependency window causes Code::Blocks to correctly generate .depend files.

(Your compiler setup looks fine so I doubt that is the problem.)

@Anyone else: Perhaps someone with more experience in this area could share their thoughts?
Title: Re: What's up with .depend files?
Post by: oBFusCATed on September 19, 2011, 09:10:55 am
tankist02: can you try with the normal g++, without ccache?
Title: Re: What's up with .depend files?
Post by: tankist02 on September 19, 2011, 09:31:18 pm
Did that. Rebuilt a few times, closed and opened CB, even opened External dependencies dialog - didn't help. BTW rebuild time went from 1 min (with ccache) to 7 mins (without ccache). I'd rather keep using ccache. :)
Title: Re: What's up with .depend files?
Post by: stahta01 on September 19, 2011, 09:39:17 pm
A shoot in the dark; are the includes
Code
#include "header.h"

or
Code
#include <header.h>

Tim S.
Title: Re: What's up with .depend files?
Post by: tankist02 on September 20, 2011, 12:02:23 am
I have both: <> for system files and "" for my own code. I am interested in dependencies of .cpp on my headers.

What's interesting: I manually adjusted one of .cbp files (corrected the output path). After CB reloaded the project file the corresponding .depend file was correctly generated.

On the other hand, at one point I removed all .depend files, reloaded and rebuilt the main workspace, but generated .depend were all empty (except the line: # depslib dependency file v1.0)
Title: Re: What's up with .depend files?
Post by: tankist02 on September 20, 2011, 12:17:21 am
It looks I found how to trigger correct generation of .depend files: after I edited a .cpp file, saved it and built the corresponding project the related .depend file was correctly re-generated.
Title: Re: What's up with .depend files?
Post by: tankist02 on September 20, 2011, 01:10:19 am
And I also found that switching to a different workspace may re-write correct .depend files with empty ones.   :(

More details:

- Loaded a smaller workspace. Edited at least one .cpp file in each project. Built each project after the edit. .depend files are correct

- Loaded a larger workspace that included all the projects from the smaller one plus some more. Edited a .cpp file in a new project. Built the project. .depend file for that project became correct, but all other .depend files became empty.

From my experiments it looks that .depend generation algorithm contains a bug (at least on Linux x86_64) which may be triggered when a new "superset" workspace is loaded and built.

Perhaps it would be helpful to have a "manual overdrive" to re-generate .depend files, probably somewhere in advanced options.