Author Topic: Dependencies handling ?  (Read 25245 times)

zieQ

  • Guest
Dependencies handling ?
« on: July 13, 2005, 02:33:27 pm »
Well, I'm trying to solve the visual c++ workspace bad imports, and i have problem converting project dependencies to codeblocks.

In Visual C++, I think there's 2 sorts of dependencies:
- inter-project dependencies: say there's 2 project A and B, if A depends on B, A should be recompiled if B is modified and A should link B.
- intra-project dependencies: some external files (i.e. not .cpp or .h) should issue a compilation when modified, often due to a custom rule. For example, lexer files, resources files produce source or object files to compile/link with.

I had a deep look into Code::Blocks but i'm lost with the dependencies features !
- GetExternalDeps : i think it's the intra-project dependencies
- SetDepsOutput: I don't understand what it is for !

My questions are:
- is inter-project dependencies exist in Code::Blocks ?
- if yes, how could i say that a project A depend on a project B
- if not, could this be implemented, or at least the methods in the project class so i could finish the visual workspace loader ?
- should I use a workaround, that is linking explicitly my library B to A ?

zieQ

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Dependencies handling ?
« Reply #1 on: July 13, 2005, 03:26:10 pm »
Quote
My questions are:
- is inter-project dependencies exist in Code::Blocks ?
- if yes, how could i say that a project A depend on a project B
- if not, could this be implemented, or at least the methods in the project class so i could finish the visual workspace loader ?
- should I use a workaround, that is linking explicitly my library B to A ?

ProjectBuildTarget::SetExternalDeps() is what you want. Any file you put there, its timestamp is checked and if more recent than the current target's output, it forces re-linking.

Yiannis.
Be patient!
This bug will be fixed soon...

zieQ

  • Guest
Dependencies handling ?
« Reply #2 on: July 13, 2005, 03:57:24 pm »
Where are the intra-project dependencies then ? That is, how can I set a custom rule that compile a lexer file and produce a source file, and the project to recompile the generated file when the lexer file is modified ! Must I add the generated source file somewhere to be compiled ?

I also made a search for GetExternalDeps calls, they seem not to be used when compiling ?!! I'll make some quick test to check that !

And what file must I add to External Deps ?? lib file may not have been generated !

zieQ

  • Guest
Dependencies handling ?
« Reply #3 on: July 13, 2005, 04:20:23 pm »
I've just tested the external dependencies "feature" with 2 projects, one building a static library and one exe to link with the library.

When i click to set external deps, I'm only able to set a (existing) file, not a project name ! I set the .cdb file and the library file as dependencies of the exe project. Now the exe project is set as active. When I change the .cpp file of the library, the library is not recompiled ! When I change the .h of the library, only the exe project recompile (since the .h file is included in the main.cpp). So the external deps are not used (or nothing indicates that they are used).

So I conclude: there's no inter-project dependencies in codeblocks !! No ! Where are my answers ?  :P

zieQ

  • Guest
Dependencies handling ?
« Reply #4 on: July 18, 2005, 05:48:47 pm »
UP ? How could I set-up inter-project dependencies ?
Do you plan to add the related functions in the sdk soon ?

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Dependencies handling ?
« Reply #5 on: July 18, 2005, 06:00:26 pm »
Quote from: zieQ
UP ? How could I set-up inter-project dependencies ?
Do you plan to add the related functions in the sdk soon ?

Projects are sets of build targets. This means a project may have more than one target generating output (an executable, a library, etc). There is no way to "link" two projects together in the form of one being depended on the other.
You can, however, make a target's output dependent on another target's output (even if it belongs to a different project). That's why you select as external dependencies only executables or libraries (shared or static).

If you don't understand what I 'm saying, say so and I 'll give you an example.

Yiannis.
Be patient!
This bug will be fixed soon...

zieQ

  • Guest
Dependencies handling ?
« Reply #6 on: July 18, 2005, 06:36:02 pm »
Quote from: mandrav
There is no way to "link" two projects together in the form of one being depended on the other.

We agree on that !

Quote from: mandrav
You can, however, make a target's output dependent on another target's output (even if it belongs to a different project). That's why you select as external dependencies only executables or libraries (shared or static).

I really understand but this is not equivalent! I expect both targets to be recompiled if I modify something in the dependent target. Actually, if A is the currently selected target, A depend on B (a library) and I modify a .cpp file of B, none are recompiled except if I manually recompile B. The right way to do it is to depend on all executables/libraries/source files/user dependencies from the dependent target and that's a pain to set.

So, maybe you could add the "project dependencies" or "target dependency" feature. The main thing to do is to check that all the dependent project are up-to-date before proceeding to the compilation of the current project, and if not, perform the compilation of the dependent out-to-date project and relink.
In the SDK, 2 additionnal methods need to be implemented in cbproject.h /.cpp:
Code
addProjectDependency(wxString projectName);
wxArrayString getProjectDependencies();


What do you think about that ? Could this be implemented in the SDK even if methods are empty, so that i will be able to solve a part of the visual import bug ?!

I advocate I really need this feature. IMHO workspaces are useless if there's no way to make dependencies between projects/targets. What's the point of having many projects displayed simultaneously if they are no dependencies between them, or if they do not recompile properly when we edit some files?! Code::Blocks is great but without this feature it's unusable to me. I'll switch off using it if if this is not implemented but that would be a shame !

I keep trying to solve the visual workspace import bug but this is the main problem to the conversion for now.

Offline kagerato

  • Multiple posting newcomer
  • *
  • Posts: 56
    • kagerato.net
Dependencies handling ?
« Reply #7 on: July 18, 2005, 07:45:20 pm »
If you need the functionality that badly and believe it is simple to implement (judging from your post, it seems to safe to establish both premises), it seems quite reasonable to code it yourself.

I don't agree that workspaces were developed for the sole purpose of managing interdependent projects, and you truly have not offered any evidence for that assertion.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4315
    • Code::Blocks IDE
Dependencies handling ?
« Reply #8 on: July 18, 2005, 08:07:13 pm »
Quote
I really understand but this is not equivalent! I expect both targets to be recompiled if I modify something in the dependent target. Actually, if A is the currently selected target, A depend on B (a library) and I modify a .cpp file of B, none are recompiled except if I manually recompile B. The right way to do it is to depend on all executables/libraries/source files/user dependencies from the dependent target and that's a pain to set.

I don't believe you understand what I 'm saying.

Example:

Project A is a static library.
Project B is an executable that is linked with the static library of project A.
We want B to depend on A, so if anything is changed on A, B is updated.
Do we agree so far?

C::B allows you to set A's product, the static library, as a dependency for B's product, the executable. This is done by going to project B's properties and adding A's library as an external dependency to the B's executable target.
Clear so far?

When you change something in A, say a .cpp file, this makes A dirty so it will be compiled and linked.
When A's static library is linked again, B's executable has dirty external dependency (the relinked A's static library).
Here is the point now: if nothing's changed in B and you try to compile it, it will get re-linked because it depends on a static library which is set as an external dependency.

This is the best I can explain it to you. If you still can't understand it, maybe someone who does and is more fluent with English than me can step in and explain it better.

On another note, it just occured to me you might be talking about projects build order inside a workspace. If that's the case, then the only useful hint I can give you is that projects are built top-to-bottom, as seen in the workspace tree. This means if a project A must be compiled before project B, A must be above B in the project tree. Then a "Compile->Compile all projects" will do the trick (i.e. build all in the right order).

You have to excuse me because I have never used any Microsoft IDE, so their terminology eludes me...

HTH,
Yiannis.
Be patient!
This bug will be fixed soon...

Offline Profic

  • Multiple posting newcomer
  • *
  • Posts: 56
Dependencies handling ?
« Reply #9 on: July 18, 2005, 10:58:54 pm »
I seemed understand what zieQ wants (using A and B from your post):
he wants automatically (not manually) compile and link A if something changed in it when he tells to compile and link B. And after this compile and link B.
Is it clear? Or I misunderstand something, too...
Not fear, nor tears can reach me now, the light seems so clear as the night fades away (c) Tristania - Beyond The Veil

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Dependencies handling ?
« Reply #10 on: July 18, 2005, 11:01:25 pm »
isn't it easier then to make 1 project from it with diffrent build targets?
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Dependencies handling ?
« Reply #11 on: July 18, 2005, 11:34:30 pm »
If you read the first post, you'd see that he's "trying to solve the visual c++ workspace bad imports", and his main problem so far has been "converting project dependencies to codeblocks. "

Offline David Perfors

  • Developer
  • Lives here!
  • *****
  • Posts: 560
Dependencies handling ?
« Reply #12 on: July 18, 2005, 11:36:11 pm »
I didn't say anything :oops: :P
OS: winXP
Compiler: mingw
IDE: Code::Blocks SVN WX: 2.8.4 Wish list: faster code completion, easier debugging, refactoring

zieQ

  • Guest
Dependencies handling ?
« Reply #13 on: July 19, 2005, 09:37:33 am »
Quote from: kagerato
If you need the functionality that badly and believe it is simple to implement (judging from your post, it seems to safe to establish both premises), it seems quite reasonable to code it yourself.

Hey, I am new to C::B! First I don't have big insights about C::B project compilation so I am not able implement it for now. Second, I want the main developers approval/opinion before anything! But IMHO it should not be difficult to do ! And please remember I'm already trying to solve visual workspace imports, I don't have the time to do everything in C::B!  :shock:

Quote from: kagerato

I don't agree that workspaces were developed for the sole purpose of managing interdependent projects, and you truly have not offered any evidence for that assertion.

I can't see any use of workspaces for independent projects, please give me some examples that could not be handled by separate projects files !? If workspaces are just used to collect projects in the same place, there is no added functionnality in that. So why not just keeping independent projects in independent places and use the recent list to edit them ?

Mandrav, I'll suggest you try it, that's what I made. Profic has understood my point. When I edit a .cpp file of a library B, then ask C::B to compile A (which depend on B via library dependency as you suggest, and A is set as active project), nothing get recompiled since the library is not active (so not recompiled) ! I need to manually compile B before compiling A. That's my problem, I would like it to be automatic, via inter-project dependencies. Worse, If I edit a .h file of B, A is also set as active and use the .h file, only A is recompiled. I need to manually compile B and then A is relinked automatically. Making a dependency with the target output (library in this case) is NOT sufficient to achieve the proper behaviour I expect! That's why I keep asking for inter-project dependencies!

I think using the order of the projects to get things compiled in the proper order is not the best idea. Worse, there's no easy way to move projects up and down in the workspace project list! For sure, using project dependencies would be better for that.

Hope I am clearer!

zieQ

  • Guest
Dependencies handling ?
« Reply #14 on: July 19, 2005, 09:38:31 am »
Quote from: mispunt
isn't it easier then to make 1 project from it with diffrent build targets?


But are inter-target dependencies implemented ?  :wink: