6

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?

Arno Moonen
  • 1,134
  • 2
  • 10
  • 28
  • I tried running it as an External Tool, however the output does not get parsed by Eclipse when I run it like that. – Arno Moonen Jul 04 '16 at 06:53
  • I've tried multiple things and I don't think it's possible at the moment. Maybe you should try to post this on the eclipse forum or to open a feature request on eclipse's Bugzilla. It seems that the variables are never interpreted in this field. – Tim Jul 05 '16 at 06:58
  • (Just an idea:) Did you enable refresh when you ran make as an external tool? – vlp Sep 01 '16 at 19:25
  • Maybe i misintepred you, but if you right-click a file in the project tree, there is an option "Build selected file(s)". Is that what you are looking for? Edit: seem like this only works with autogenerated make file though (?) :( – foolo Jan 22 '17 at 22:02
  • It's not just about building, I want to to run a specific rule from my makefile and pass the selected/active file as an argument. – Arno Moonen Jan 23 '17 at 07:28

1 Answers1

1

Some Eclipse special variables can be not recognized in a build configuration. Instead of running build procedure try to use External Tools Configuration.

Similar problem was described here: Custom command for Eclipse on current file .

Mikolaj
  • 43
  • 4
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/16788814) – budi Jul 21 '17 at 18:00
  • 2
    Thank you for info. I added some details to my answer. – Mikolaj Jul 21 '17 at 18:19