Skip to main content



      Home
Home » Eclipse Projects » Papyrus for Real Time » .cpp extension in codegen
.cpp extension in codegen [message #1775042] Mon, 23 October 2017 23:10 Go to next message
Eclipse UserFriend
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 09:43 Go to previous messageGo to next message
Eclipse UserFriend
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!
Re: .cpp extension in codegen [message #1775103 is a reply to message #1775042] Tue, 24 October 2017 10:56 Go to previous messageGo to next message
Eclipse UserFriend
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] Wed, 25 October 2017 22:18 Go to previous messageGo to next message
Eclipse UserFriend
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 10:45 Go to previous messageGo to next message
Eclipse UserFriend
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 04:58 Go to previous message
Eclipse UserFriend
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 May 21 23:04:53 EDT 2025

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

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

Back to the top