Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » .cpp extension in codegen
.cpp extension in codegen [message #1775042] Tue, 24 October 2017 03:10 Go to next message
Anantha Krishnan is currently offline Anantha KrishnanFriend
Messages: 26
Registered: April 2014
Junior Member
Simple questiob, sorry could not fined any hints in Forum/documentation.

How do we codegen from Papyrus-RT so that the generated files have .cpp and .hpp extensions, not .cc and .hh as set by default I presume.

Thanks.
Re: .cpp extension in codegen [message #1775092 is a reply to message #1775042] Tue, 24 October 2017 13:43 Go to previous messageGo to next message
Charles Rivet is currently offline Charles RivetFriend
Messages: 219
Registered: May 2014
Location: Canada
Senior Member

Hi Anantha,

I know I am no providing an answer to your question - there are better people to answer this - but as the Papyrus-RT product lead, I would be interested in understanding why you need to do this?

Knowing the answer to this question will help me in better identifying the future requirements for the tool and provide an increasingly better user experience.
Your feedback would be greatly appreciated (and if other readers of this forum are interested, please also comment!)

Thank you!


/Charles Rivet
Re: .cpp extension in codegen [message #1775103 is a reply to message #1775042] Tue, 24 October 2017 14:56 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Sorry, there is no way to tell the code generator to use other file extensions at this point. If you'd like that feature, I suggest opening a bug for it.

In the meantime, it's easy enough to do a batch file rename. For example in bash you can do:

for f in *.cc; do mv $f ${f/.cc/.cpp}; done


You would have to rename files in the MakefileTop.mk, CMakeLists.txt (if you use cmake) and replace all the #include statements in the generated code though. You could also automate that in bash, e.g.

sed "s/\.cc/\.cpp/g" MakefileTop.mk > temp.mk; mv temp.mk MakefileTop.mk


But doing that automatically for the #include directives wouldn't work, because it would replace the includes of the runtime library as well, which are fixed with a .hh extension. This would require a more careful script, like this (after the batch renaming above):

for f in *.cpp; do
    sed -i '' -E '/#include "umlrt/!s/#include "([A-Za-z0-9]+)\.hh/#include "\1\.hpp/g' $f
done


If you are not very familiar with sed, this means: for each file f with .cpp extension, edit the file (sed) in-place (-i) without a temporary file ('') using extended regular expressions (-E), considering only the lines where the pattern '#include "umlrt' does *not* occur (!), substituting (s) the pattern '#include "([A-Za-z0-9]+)\.hh' by the pattern '#include \1.hpp' (where \1 is the same as the sequence inside (...) in the first pattern) and do this globally (g), i.e. for every occurrence.

If you are on Windows, you should have Cygwin and you can install sed there. If you are on Linux or macOS you should already have sed built-in.

Out of curiosity, is there any particular reason why you want .cpp/.hpp extensions instead of .cc/.hh?
Re: .cpp extension in codegen [message #1775187 is a reply to message #1775103] Thu, 26 October 2017 02:18 Go to previous messageGo to next message
Anantha Krishnan is currently offline Anantha KrishnanFriend
Messages: 26
Registered: April 2014
Junior Member
Thanks Charles and Ernesto fo the detailed query and the detailed reply.

I am really not sure if I need this, but I was trying to create the TargetRTS for Mirochip PIC32 in MPLabX. For some reason, and I admit I did not investigate this very far, the IDE seems to fail to do a simple compile of any file with .cc extension, though it seems to have in Settings the facility to declare these as accepted extensions for C++ source files.Changing the same file(s) to .cpp extension then lets the compile proceed as needed.

Should this still be a bug/enhancement request?

Thanks for the sed tips, too.

Anantha Krishnan

Re: .cpp extension in codegen [message #1775233 is a reply to message #1775187] Thu, 26 October 2017 14:45 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Hm... Interesting. I wasn't aware of MPLabX. If some compilers do require other extensions, then yes, we should provide a preference for the code generator. Could you submit a bug/enhancement to bugzilla?

Thanks

Re: .cpp extension in codegen [message #1775290 is a reply to message #1775233] Fri, 27 October 2017 08:58 Go to previous message
Anantha Krishnan is currently offline Anantha KrishnanFriend
Messages: 26
Registered: April 2014
Junior Member
Thanks, I have submitted a bug.
Previous Topic:Registering an UML-RT Package using Extension Points
Next Topic:Eclipse Extension Point
Goto Forum:
  


Current Time: Wed Apr 24 21:55:02 GMT 2024

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

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

Back to the top