.cpp extension in codegen [message #1775042] |
Mon, 23 October 2017 23:10  |
Eclipse User |
|
|
|
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 #1775103 is a reply to message #1775042] |
Tue, 24 October 2017 10:56   |
Eclipse User |
|
|
|
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.04037 seconds