|
Re: .cpp extension in codegen [message #1775092 is a reply to message #1775042] |
Tue, 24 October 2017 13:43 |
|
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 |
Ernesto Posse 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?
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03017 seconds