Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Pass selected file to Make target
Pass selected file to Make target [message #1737820] Wed, 13 July 2016 09:28 Go to next message
Arno Moonen is currently offline Arno MoonenFriend
Messages: 4
Registered: July 2016
Junior Member
At the company I'm currently working for, several IDEs are being used (they develop firmware for different embedded platforms). All their C projects use a Makefile, so we decided to also add rules to their default Makefile to run static code analysis tools.

One of the IDEs they use is Eclipse. Here we have added additional targets to the Make Target view, that triggers the lint target from the Makefile, for example. Since we use multiple IDEs we can tell the tools called by the Makefile to generate specific output for the IDE being used. For Eclipse we do this by adjusting the Build Command and adding something like IDE_ENV=eclipse to the end. This works just fine.

Recently one of the engineers mentioned that it would be really helpful if he could run the tools, as defined in the Makefile, for a single file. So, I updated the Makefile and it now accepts a variable SOURCE_FILE with the path of the file that needs to be checked.

In Eclipse I tried adding SOURCE_FILE=${selected_resource_loc} and just SOURCE_FILE=${resource_loc}, but these variable do not seem to work when running a Make Target. I also tried to use $(selected_resource_loc) and $(resource_loc) directly in the Makefile, but without any luck.

Can somebody tell me how I can pass the current selected file to Make when running a target from the Make Target view?

PS: I've also asked this question on StackOverflow (can not add the link yet since this is my first post), but no answers have been posted yet, which gives me the feeling that it might not be possible currently.
Re: Pass selected file to Make target [message #1737862 is a reply to message #1737820] Wed, 13 July 2016 14:54 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
I suspect the issue here is that selected_resource_loc and the like are empty when the focus is on the Make Target view.

Here is how to get around it, instead of using the view, press "Shift-F9" or right-click on the file and choose Make Targets -> Build. In the Make Target view I have "FILE=${selected_resource_loc} lint" as my Make target.
Re: Pass selected file to Make target [message #1737863 is a reply to message #1737862] Wed, 13 July 2016 14:54 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
PS I couldn't find the question on SO, did you tag it with the eclipse-cdt tag?
Re: Pass selected file to Make target [message #1738201 is a reply to message #1737863] Mon, 18 July 2016 06:11 Go to previous messageGo to next message
Arno Moonen is currently offline Arno MoonenFriend
Messages: 4
Registered: July 2016
Junior Member
Did not know that tag existed on SO.
I've added it to the post now.
http://stackoverflow.com/questions/38144010/pass-selected-file-to-make-target-in-eclipse

I'll try your suggestion today.
Re: Pass selected file to Make target [message #1738205 is a reply to message #1738201] Mon, 18 July 2016 06:46 Go to previous messageGo to next message
Arno Moonen is currently offline Arno MoonenFriend
Messages: 4
Registered: July 2016
Junior Member
I just tried your suggestion and it is definitely a step in the right direction.
I see that the value is passed along to Make just fine, however Make seems to be executed in the installation path of Eclipse (or LPCxpresso in my case), instead of the project folder.

Update: both project_loc and project_name appear to be empty.
Adding -f C:\absolute\path\to\Makefile works, but isn't very clean.

[Updated on: Mon, 18 July 2016 06:48]

Report message to a moderator

Re: Pass selected file to Make target [message #1738234 is a reply to message #1738205] Mon, 18 July 2016 10:19 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 416
Registered: June 2014
Senior Member
Hi Arno,

I don't know why LPCxpresso is not setting the directory correctly, on vanilla current CDT, the execution directory of Make is controlled by a combination of "Build Location" -> "Build Directory" located in project properties -> C/C++ Build. The other part of the combination is where in the tree the make target is created in the "Make Target" view.

I think you can get this to work, but I also think that the flow could use some improving.

For that, I can recommend another solution altogether, Eclipse EASE, which lets you script the Eclipse environment, and in this case you could use it to add a menu option to the context menu of your c files to run the command.

Have a look at https://opensource.com/life/16/2/how-use-python-hack-your-ide for some ideas. EASE's homepage is https://eclipse.org/ease/

Jonah
Re: Pass selected file to Make target [message #1738455 is a reply to message #1738234] Wed, 20 July 2016 05:50 Go to previous message
Arno Moonen is currently offline Arno MoonenFriend
Messages: 4
Registered: July 2016
Junior Member
I'll check the properties you mentioned and I will most definitely have a look at EASE (the concept sounds very interesting).
Previous Topic:Eclipse Arduino c++ ide
Next Topic:Building a project retracts the directory list
Goto Forum:
  


Current Time: Sat Apr 20 04:11:53 GMT 2024

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

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

Back to the top