Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Make it Stop Building Dependencies(Eclipse builds dependencies of a project even when I don't want it to)
Make it Stop Building Dependencies [message #1705903] Wed, 19 August 2015 22:31 Go to next message
Nir Friedman is currently offline Nir FriedmanFriend
Messages: 5
Registered: May 2015
Junior Member
I'm using an external build tool, that's handled entirely outside of Eclipse. I have a bunch of different projects in my workspace, which have dependencies between them both in reality, and in Eclipse. These dependencies (expressed in the project references) are necessary so that indexing works properly.

I have played around with different ways of launching the external build tool. I've found that the best way is to, under Project Properties -> Builders, leave CDT Builder checked, and under C++ build, simply enter the appropriate build command. The alternative is to uncheck CDT Builder, and add a new Builder, which is just an external tool. As far as I can tell, this has a very major disadvantage. Assuming your external tool still streams compiler (and unit test) error messages back to stdout and stderr, CDT Builder will parse the output. This gives you two things: hyper links; i.e. you can click on the error messages in the console output and it will bring you to the file, and it will also mark the errors on the left in your file. These two features are invaluable for quick reaching a file and systematically debugging it.

So imagine I am working on a project A, in the workspace, that references project B in the workspace. I create a custom build command in project A, and I rebind Ctrl+B to only build the current project. However, every time I launch the build command for project A, Eclipse also tries to build project B. This is not necessary, as the external build system I use already does everything automatically. Is there any way I can make Eclipse not build dependent projects? I'd prefer a solution more elegant than making every build except for the one I'm working on a no-op at any given time.
Re: Make it Stop Building Dependencies [message #1705912 is a reply to message #1705903] Thu, 20 August 2015 02:31 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I can only tell you what I do. You may not want to do this but it may give you hints on where to look,

All of my projects are external makefile builds.

In project properties:

    On the Builder options I have every thing checked (including the CDT Builder.
    Under C/C++ Build: I have

      Build type: external builder
      Use default builder is checked
      Build command: make
      Behavior tab has Build on save disabled.



I never let it refresh anything but the current project mostly because I rarely change other project when working on a particular one. I doubt this is necessary. (C/C++ Builder refresh policy tab)

I have also turned off automatic discovery because it gets confused. Nice idea for some but for me it's a nuisance. This means I have to manually enter the include paths so the indexer still works (Project Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc.). A bit tedious but generally only needed once per project.

I don't link projects (all project references are turned off). There doesn't seem to be any reason for linking other than automatic builds and maybe for auto discovery.

When I want to build I use the Make Target view to which I've added targets (such as all and clean) then select the one I want. It remembers the last one used for each project so pressing F9 in an open project file executes the last make build target for whatever project the file resides in. It forgets them when Eclipse is closed.

I never bothered even letting the makefile build other projects as needed but again mostly because my necessity for it is low. Doing so may require setting the refresh policy under C/C++ Builder options as they must be manually refreshed when I build them externally but mostly only the object files change and I don't really care if Eclipse knows about them or not.


HTH
Re: Make it Stop Building Dependencies [message #1705968 is a reply to message #1705912] Thu, 20 August 2015 13:41 Go to previous messageGo to next message
Nir Friedman is currently offline Nir FriedmanFriend
Messages: 5
Registered: May 2015
Junior Member
As I wrote above, project references are necessary for indexing to work properly. If e.g. I remove the reference to project B in project A, then when I go to a file in project A that has #include's of files in project B, these includes immediately become unresolved.
Re: Make it Stop Building Dependencies [message #1705972 is a reply to message #1705968] Thu, 20 August 2015 14:30 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
That doesn't happen for me and I have no projects linked. I jump from one project to the next and indexer works fine in all cases though sometimes I have to force a rebuild of it.

Reread what I said about automatic Discovery and Project Properties --> C/C++ General --> Preprocessor Include Paths, Macros, etc.

In any case, I was showing you what I did that avoids spurious rebuilds and not necessarily a specific solution.
Re: Make it Stop Building Dependencies [message #1705974 is a reply to message #1705972] Thu, 20 August 2015 15:13 Go to previous messageGo to next message
Nir Friedman is currently offline Nir FriedmanFriend
Messages: 5
Registered: May 2015
Junior Member
If I understand you correctly, it seems like you manually enter all the include paths that any given project needs. This means that if project A uses project B, and the underlying build system has several include paths for project B, that means I will need to add multiple include paths to project A, just for project B. The number of include paths I'll have to carefully add in this fashion is actually quadratic with the number of projects. Adding a new project goes from quickly ticking off a bunch of boxes, to painstakingly entering a dozen or more paths. Additionally, any time that a slight change in include structure is done, everything will break, so this approach is very brittle as well. I'm not 100% sure what you mean by automatic discovery, but in my approach, all the inter-project includes are discovered automatically via "Heuristic Resolution of Includes"; this normally works within the same project but when you add project references it works across projects as well. This doesn't require Eclipse to parse the output of my build system or anything like that.

I think this approach is strictly more work and less robust than using project references and giving each project a default config build command to just do nothing. Thank you though for sharing, it's always interesting to see how many approaches there are with Eclipse.
Re: Make it Stop Building Dependencies [message #1705976 is a reply to message #1705974] Thu, 20 August 2015 15:50 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
I guess it really depends on what you are doing. In my case, if Project A references Project B it will unlikely change so, yes, the paths are inserted manually but only once when the project is defined and usually it's only one path on the order of "xxxx/inc". The paths can also be saved and loaded from an xml file which in turn can be edited if need be.

Seems your way has an unwanted side effect. So much for robustness. The price of doing it the easy way, maybe. Perhaps it's a bug.

I'm not sure, but I think "Heuristic Resolution of Includes" has more to do with when they are scanned and not when or if they are found. But then, I'm no expert and it's something I don't use. I've completely disabled discovery. It has caused me too many problems. YMMV.


Re: Make it Stop Building Dependencies [message #1705989 is a reply to message #1705976] Thu, 20 August 2015 18:06 Go to previous messageGo to next message
Nir Friedman is currently offline Nir FriedmanFriend
Messages: 5
Registered: May 2015
Junior Member
The fact that A references B isn't likely to change, but new projects are added not infrequently, there are many different people working on many different subsets of projects. This adds a tremendous amount of work and complexity to project files.

Yes, it has an unwanted side effect. This is because Eclipse's builder is really designed for Makefiles, and it's assumed that projects are separate makes. The idea that the build system is already aware of all the different projects and handles all this automatically is not really how Eclipse sees the world. I'd hardly call my approach the easy way; that's the design. I'm pretty sure project references aren't there for decoration. At any rate, an unwanted side effect is quite orthogonal to robustness. I've already listed reasons why I think my approach is more robust than explicitly listing every include directory.

Heuristic resolution of includes means that within projects, it will try to resolve #includes by looking at where there can possibly be a match. It will simply assume that your build has the appropriate -I arguments. This means both marking the include resolved, and allowing the index for that file to use symbols from the include. I know this is the case, because all my code resolves includes perfectly, and I have not either: a) specified any of the include paths explicitly, or b) allowed Eclipse to parse the build/link commands produced by my build system (which is what I think is called discovery). So there is no other way in which Eclipse could be resolving the includes.

Anyhow, as an update to the problem: one thing that has surprised me (and annoyed me) is the following. I create a "Default" profile for every single project consisting of a no-op build, and I give project A an additional profile "TargetA" with a command, which only depends on other projects "Default" (in project references), and I similarly give project B an additional target "TargetB". I set TargetA and TargetB active. When I build project A, it still insists on running the command specified by TargetB. I would argue that this is simply an outright bug; I explicitly selected that the "TargetA" configuration only depends on the "Default" configuration of project B, so why would it build TargetB?
Re: Make it Stop Building Dependencies [message #1706204 is a reply to message #1705989] Mon, 24 August 2015 18:49 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Quote:
Heuristic resolution of includes means that within projects, it will try to resolve #includes by looking at where there can possibly be a match.



FYI: from the help under Indexer preferences (C/C++):
Allow heuristic resolution of includes
Activate this checkbox to allow the indexer to skip indexing duplicate include files.

It may act as you have said but the documentation implies only a very simple heuristic which is employed to determine when a file might be scanned. You may be confusing it with Use heuristics to resolve paths in the Build Output Parser Options of the Discovery tab.


Quote:
Yes, it has an unwanted side effect. This is because Eclipse's builder is really designed for Makefiles, and it's assumed that projects are separate makes. The idea that the build system is already aware of all the different projects and handles all this automatically is not really how Eclipse sees the world.


If you think the spurious builds occurring when using your approach are inappropriate submit a bug report if you haven't already. However you may be merely disagreeing with a design decision and what you really want is an enhancement.

I'm curious though why whatever is actually doing your builds doesn't recognize it has nothing to do and act as a no-op when executed? If it does then it's no different than using make recursively. If you are getting actual builds vs. just messages saying the builder was called, perhaps that is where your problem actually resides?

[Updated on: Mon, 24 August 2015 22:26]

Report message to a moderator

Previous Topic:IAR plugins
Next Topic:Cannot use ctrl+click, hover, etc.
Goto Forum:
  


Current Time: Tue Apr 23 05:32:48 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top