Bug 363184 - reinstate building the default make target in project subdirs
Summary: reinstate building the default make target in project subdirs
Status: REPORTED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: Make (other bugs)
Version First Reported In: git master
Platform: Compiled Sources All
: NOR wishlist
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-17 14:59 UTC by RJVB
Modified: 2017-01-14 09:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description RJVB 2016-05-17 14:59:14 UTC
KDevelop 4.x has a convenient feature where you can issue a build command (via hotkey, context menu or the toplevel menu) with  a project's subdirectory selected in the project manager. If the project uses Makefiles and one exists in that particular directory, only the default target at that level would be built. The implementation as far as I understand it from feedback in the Build view is extremely simple: 

1) chdir into the target subdir
2) call make

Reproducible: Always

Steps to Reproduce:
1. Open a project that uses Unix Makefiles
2. Select a directory containing a Makefile (as indicated by the different folder icon)
3. Issue a build command

Actual Results:  
KDevelop 4.7.3 will build only the source under the selected subdir, possibly after building any dependencies from elsewhere in the project (depending on whether that's required and the required information is available, which is usually the case for CMake-based projects)

KDevelop 5 (4.90x) simply builds the full project

Expected Results:  
KDevelop 4.7 has the preferred behaviour, which is also the behaviour I'd expect from a GUI IDE.

As pointed out on the mailing list, it is still possible to select a target in the subdir of interest and build that. There are however several reasons why the possibility of building a default target would be convenient - in addition to the aforementioned fact that it's what you'd expect from a point-and-click interface where you select an item and tell it to build :

1) building a target requires the targets to be visible, which is done via a small icon at the top of the project manager
2) it isn't always that trivial to know what the default target is (or else what specific target to build after a point edit), even in projects you authored yourself after a certain time has passed
3) this is all the more true for autoconf based projects which tend to have sometimes incredibly long lists of targets - per subdirectory.
4) finding the target of choice in a long scroll list isn't a very efficient process, ditto for finding source files (IOW, long lists of build targets, say more than 5 or 6 are best kept hidden).

As mentioned above, there shouldn't be any need for advanced parsing to determine the default target. Executing the make command in the selected directory should give the expected behaviour automatically (or else produce a sufficiently clear error message).
The implementation thus seems something that doesn't require intimate knowledge of KDevelop's internal architecture, and something I should be able to do in parallel to my other occupations. 

I think I'd just need some pointers to figure out:
- the classes and/or files that require changes (cmake, qmake, custom make project managers, which others, or is there a subclassed generic interface that could provide the feature?)
- how to obtain the selected subdir in the method that handles the build action.
Comment 1 Gaetano Mendola 2017-01-13 22:58:26 UTC
Same here. Opening a CMAKE project, going on the Project pane I can see all my build tree, however doesn't matter which folder I choose to build it starts building from root.
Comment 2 RJVB 2017-01-14 09:10:36 UTC
All this needs is someone to figure out the information flow from when you activate the Build command with a subdirectory selected in the Project manager to the Make build manager, extract the selected directory and tell Make manager to chdir there before calling make.

In addition:
Do you have the "Show Targets" option activate in the Project manager toolview (2nd toolbar button from the left)?

If so, are the targets shown reliably?

For me they are not, in fact in most projects they're not. It is true that most of the projects I use have been configured outside of KDevelop, but *with* creation of the compile_commands.json file. There is overlap between those foreign/imported projects and projects that don't show their targets but it's not a complete overlap.
Comment 3 RJVB 2017-01-14 09:16:28 UTC
I was going to add that you could write an external script that does

    cd `dirname %f` && make

but that fails for 2 reasons:
- as evident from the script command, you'd have to select a file in the folder of choice, which is counter-intuitive
- the correct dir to chdir to is not `dirname %f` but `build-directory-for %f`

Plus, selecting an external script via the project manager context menu currently doesn't work for me.