Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318790

Summary: Wishing an action and a key to Rebuild Last Target when editing a file
Product: [Tools] CDT Reporter: Mathieu Roger <rogma.boami>
Component: cdt-buildAssignee: cdt-build-inbox <cdt-build-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: enhancement    
Priority: P3 CC: aegges
Version: 7.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Mathieu Roger CLA 2010-07-03 12:05:08 EDT
'Rebuild Last Target' is a very interesting feature. 

It would be even greater if we could call it during the edition of a file : 
it would rebuild the last target of the first englobing directory/element with an associated target.

I have several directories, each of them representing a library. When I edit a file my next action is always to build a target of the containing directory. Having to select the directory in another view (i.e., 'C/C++ Project view') is quite annoying.

Filling this demand I just realized that it is already the case in the C/C++ Project view.
 
Same idea could apply for 'Build Target'.
Having the same key mapping would be great
Comment 1 Andrew Gvozdev CLA 2010-07-03 14:20:58 EDT
Hmm, it is supposed to work from editor. Looks like there is a bug there and F9 in editor is not activated after starting of eclipse. If you run F9 from C/C++ Project view it then starts working from editor as well.
Comment 2 Mathieu Roger CLA 2010-07-03 16:26:22 EDT
Ha, interesting, I completely missed that!

In fact it works as you describe but only for direct child file of a directory.

I use the following structure :

Module/
  file1.h
  Implementation/
    file1.cpp
  Tests
    test_file1.h
    test_file1.cpp

And I have only set targets for 'Module' directory.

So when pressing F9 in file1.h : ok, launches the latest Module target.

And when pressing F9 in file1.cpp : it opens the Build Target menu for Implementation, which is empty. Same for other files. 

So, Ok, my structure is a bit unusual, except, maybe, for Test sub-directory. 

My wish is to launch the first available target by getting recursively up, i.e., skipping directories that have no associated build targets until we get one, and if none, existing behaviour.
Comment 3 Andrew Gvozdev CLA 2010-07-03 16:37:38 EDT
There is also a preference to use make target from project root, see Preferences->C/C++->Build->Make Targets - Rebuild Last Target "from project root". You can try that as an option.
Comment 4 Mathieu Roger CLA 2010-07-03 17:00:00 EDT
Thanks for pointing out this option.

It is still not satisfactory because my projects have several modules, so I would need to select the appropriate build target whereas this target is implicitly defined by the current opened file. 

I still wish to be able to rebuild the last target by searching recursively up, for example as a third option in Preferences->C/C++->Build->Make Targets - Rebuild Last Target, which would do no harm.
Comment 5 Axel Mueller CLA 2011-02-12 16:28:11 EST
(In reply to comment #4)
> Thanks for pointing out this option.
> 
> It is still not satisfactory because my projects have several modules, so I
> would need to select the appropriate build target whereas this target is
> implicitly defined by the current opened file. 
> 
> I still wish to be able to rebuild the last target by searching recursively up,
> for example as a third option in Preferences->C/C++->Build->Make Targets -
> Rebuild Last Target, which would do no harm.
In bug #333113 I added to Rebuild Last Target an option so that it will use the actual last target of the current project irrespective of the currently selected resource. Would this option help you?