Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
cbMakefileGen plugin
Vorl:
--- Quote from: kisoft on August 02, 2007, 07:15:46 am ---About dependences:
My investigations is empty, I can't found possibility for get dependences for files now. If you knows, get me information.
--- End quote ---
I don't know CB very well but I would be surprise that you cannot access to the dependences. I will try to have a look at the source code tomorrow. As a last resort, I think that the depences are in the file <projectname>.depend and it would be possible to parse this file (?).
kisoft:
--- Quote from: Vorl on August 02, 2007, 06:06:15 pm ---
--- Quote from: kisoft on August 02, 2007, 07:15:46 am ---About dependences:
My investigations is empty, I can't found possibility for get dependences for files now. If you knows, get me information.
--- End quote ---
I don't know CB very well but I would be surprise that you cannot access to the dependences. I will try to have a look at the source code tomorrow. As a last resort, I think that the depences are in the file <projectname>.depend and it would be possible to parse this file (?).
--- End quote ---
No, I can't found this possibility. I think C::B has this feature.
<projectname>.depend: I want investigate sources for search using this file. I want search using it like internal object (like tree for each file).
depslib (plugins/compilergcc/depslib) contant a lot functions for check dependencies, I investigate this library now.
Vorl:
After a quick look in the source code today, it seems effectively that it won't be easy : everything seems done by depslib but it does not propose a method to get the list of dependences for a file.
the .depend file is actually the dump of the cache of depslib. Parsing it could be the simplest way.
Another way would be to use the -M... options of gcc but it will be more complex I think.
eranif:
The easiest way to find dependencies is to let g++ to tell you what are they by using -MT, -MD & -MM flags.
For example, lets say you have a project with 2 files, test.cpp and main.cpp, and they both link into an executable, so the makefile
that can handle dependencies is something like this:
--- Code: ---Objects=Debug\test.o Debug\main.o
IncludePath=-I.
TestExec: $(Objects)
g++ -o TestExec $(Objects)
Debug\test.o: test.cpp Debug\test.o.d
g++ -c test.cpp -g -o Debug\test.o $(IncludePath)
Debug\test.o.d:
@g++ -g $(IncludePath) -MTDebug\test.o -MFDebug\test.o.d -MM test.cpp
Debug\main.o: main.cpp Debug\main.o.d
g++ -c main.cpp -g -o Debug\main.o $(IncludePath)
Debug\main.o.d:
@g++ -g $(IncludePath) -MTDebug\main.o -MFDebug\main.o.d -MM main.cpp
clean:
-if exist Debug\test.o del Debug\test.o
-if exist Debug\test.o.d del Debug\test.o.d
-if exist Debug\main.o del Debug\main.o
-if exist Debug\main.o.d del Debug\main.o.d
-if exist $(OutputFile) del $(OutputFile)
-if exist $(OutputFile).exe del $(OutputFile).exe
-include Debug/*.d
--- End code ---
Note that for every object, I am adding another dependencie: <object_name>.d, for example:
--- Code: ---Debug\test.o: test.cpp Debug\test.o.d
--- End code ---
Now, the rule for 'Debug\test.o.d', is:
--- Code: ---Debug\test.o.d:
@g++ -g $(IncludePath) -MTDebug\test.o -MFDebug\test.o.d -MM test.cpp
--- End code ---
which invokes g++ preprocessor to create it. Open the .d file (it is a text file), and you will see there a single makefile rule generated by g++ for Debug\test.o, which includes all the dependencies required for test.o (I used here MM to omit system dependencies, such as stdio.h etc)
By chagning any of the file that test.cpp is including, the makefile will recompile it.
HTH,
Eran
kisoft:
--- Quote from: Vorl on August 03, 2007, 07:06:26 pm ---After a quick look in the source code today, it seems effectively that it won't be easy : everything seems done by depslib but it does not propose a method to get the list of dependences for a file.
the .depend file is actually the dump of the cache of depslib. Parsing it could be the simplest way.
Another way would be to use the -M... options of gcc but it will be more complex I think.
--- End quote ---
If .depend is C::B feature (I think it's true) then I being use this file for parsing for search dependencies.
--- Quote from: eranif on August 03, 2007, 09:29:19 pm ---The easiest way to find dependencies is to let g++ to tell you what are they by using -MT, -MD & -MM flags.
For example, lets say you have a project with 2 files, test.cpp and main.cpp, and they both link into an executable, so the makefile
that can handle dependencies is something like this:
...
--- End quote ---
Thank you very much, eranif. Example is excellent and very completely!
This method is good for gcc compiler only. Another compilers has other or don't has this feature.
But this method - one more way and may be used optionally.
So, parsing is win now :)
.d method will be realizated later if anybody wish it.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version