I receive a lot of questions from people who want to generate and compile code from Rhapsody using another compiler then the ones that are in the standard installation.
Since IBM is delivering some pre-adapted frameworks but does not officially supports them it is the users responsibility to do some adaptation work.
My usual answer is: switch to the RXF. Is smaller, faster and more comfortable since we took the command-line out of the workflow.
But sometimes this is not the answer. Adapting an OXF to a new RTOS is a bit difficult but using another compiler is not that hard.
Unfortunately the documentation to do this is very scarce and not really clear. So here is a (hopefully) better guideline to do that.
Last weeks I was quite busy (and in another time-zone…) Yes back in the US! Again, Florida and Michigan.
In Florida I, of course, visited my friend in Fort Myers and then went to Orlando for the IBM IoT Exchange. I had a presentation there together with Ed Grinberg from Depuy, Boston. I made the movie using my iPhone so the quality is a bit less than professional…
I was also interviewed together with Tom Capelle by the great guys of Quick Bytes, Graeme & Ryan. We spoke about the Sodius-Willert Merger.
Back to Work….
OK.. How do you create an adapter for another compiler. We assume you use C++ and want to adapt the QNX adapter to a newer version.
- Never change the original files of the framework. Always make copies and create your own adapter.
- When you have changed property files: re-read the model to update the properties in your model.
- Use a decent editor to edit files. I recommend notepad++, is free and awesome.
- The instructions are for C++, just replace C++ with C and that will work as well.
- Either install all tools in the same directory on ALL workstations of everybody in the project or use environment variables to align all differences. (First solution is preferred)
- A property file (Only the factory, factory<lang>, site and site<lang> files, not your own!) must have an extra “end” on a newline. Also escape al quotes (“) and backslashes (\)
How does it work?
If you generate code in Rhapsody, a makefile is also generated. When you press build, Rhapsody will call your makefile using an available make for that environment. How does Rhapsody knows what to call? It’s all in the properties, mate!
So assume you’ve selected
The Share Directory
This directory contains all the secrets to Frameworks. The following subdirectories are interesting:
contains files that must be added to the build process and the makefiles for the frameworks itself. Also contains the batch files that Rhapsody calls when building applications.
- Lang<Language> (C, Cpp, Java, Ada)
This contains the source-code from the framework
Contains files added to the make process.
The profiles that can be loaded (The RXF is completely adapted using profiles)
Contains all property files. This is where Site,prp and Site<language>.prp are located. Also the Factory.prp and the Factory<language>.prp are here. NEVER NEVER NEVER edit these!!!!
There are more directories but these are the interesting ones when making an Adapter.
Step 1, edit the sitec++.prp
So in Share\properties you’ll find siteC++.prp that is usually empty unless you have already added something. We have to add only one (1) property that we can copy from the factoryC++.prp file (Open that factoryC++.prp. search for environment and copy the line. Add that to your siteC++.prp file)
Subject CPP_CG Metaclass Configuration Property Environment Enum "MSVC,MSVCDLL,MSVCStandardLibrary,VxWorks, VxWorks6diab,VxWorks6gnu,VxWorks6diab_RTP, VxWorks6gnu_RTP,Solaris2,Cygwin,MicrosoftWinCE600, OseSfk,Linux,Solaris2GNU,QNXNeutrinoGCC, QNXNeutrinoMomentics,NucleusPLUS-PPC, WorkbenchManaged,WorkbenchManaged653, WorkbenchManaged_RTP" "MSVC" end end end
This is the “standard”. Now I recommend deleting all the environments that you will never use to make stuff more readable. Then add your own environment, in our case we will call it QNXv7Momentics. We want all changes for our environment in a separate file, that makes it easier to exchange the new adapter with others. This file can be included in the siteC++.prp file with the “Include” statement. The content of the siteC++.prp is something as follows:
Include "QNXv7Momentics.prp" Subject CPP_CG Metaclass Configuration Property Environment Enum "MSVC,MSVCDLL,Cygwin, QNXv7Momentics, QNXNeutrinoMomentics," "MSVC" end end end
Now copy the donor environment (QNXNeutrinoMomentics) to a new file QNXv7Momentics.prp in the Properties directory. (Same procedure, open factoryC++.prp and search for “QNXNeutrinoMomentics”). You have to add the Subject, that is CPP_CG. (Properties always have a Subject and a Metaclass but you can group them in a prp file) Don’t forget the “end” statements!
Edit the properties
Now it is time to edit. You probably have to edit more but that goes beyond the scope of this BLOG. I will describe the most important ones (here you can see the escaping of the backslash and the quotes, don’t forget that!!):
Property InvokeMake String "\"$OMROOT/etc/Executer.exe\" \"\\\"\\\"$OMROOT\\\"\\etc\\qnxv7cwmake.bat $makefile $maketarget \\\" \""
Here you fill in the name of your batchfile that compiles the Rhapsody generated code. You have to create that file later (In the “Share\etc” directory)
This file contains the commands to call the make command in your environment. Now it is time to figure out how the make command of your environment works.
@echo off if "%2"=="" set target=all if "%2"=="build" set target=all if "%2"=="rebuild" set target=clean all if "%2"=="clean" set target=clean set QNXROOT=<The root of your QNX Install> set MAKEFLAGS=-I%QNXROOT%/target/qnx7/usr/include -I%QNXROOT%/target/qnx7/usr/include/c++/5.4.0 set QNX_TARGET=%QNXROOT%/target/qnx7 set QNX_HOST=%QNXROOT%/host/win64/x86_64 set QCC_CONF_PATH=%QNX_HOST%/etc/qcc set LD_LIBRARY_PATH=%QNXROOT%/target/qnx7/lib set PATH=%QNXROOT%/host/win64/x86_64/usr/bin;%PATH% make -s %target% -f %1 %3 %4 %5 %6 %7 %8 %9
This is the example for my installation, fill in the correct paths for your environment.
The following properties determine what you give the compiler. OmFileCPPCompileSwitches is what you fill in the “Settings” Tab of your Rhapsody component.
Property CPPCompileCommand MultiLine " @echo Compiling $OMFileImpPath $(CREATE_OBJ_DIR) @$(CC) $OMFileCPPCompileSwitches -o $OMFileObjPath $OMFileImpPath " Property CompileSwitches MultiLine "-lang-c++ -I. -I$OMDefaultSpecificationDirectory -I$(OMROOT) -I$(OMROOT)/LangCpp -I$(OMROOT)/LangCpp/oxf $(INST_FLAGS) $(INCLUDE_PATH) $(INST_INCLUDES) -DUSE_IOSTREAM -DOM_USE_NOTHROW_GEN $OMCPPCompileCommandSet -c " Property CCCompileCommandString "" Property CPPCompileDebug String "-g" Property CPPCompileRelease String "-O" Property LinkSwitches String "-Bstatic" Property LinkDebug String "-g" Property LinkRelease String "-O"
The next step is to create the makefile. This is generated from Rhapsody. There is a template for the makefile with “magic” macros that expand to the information inside the Rhapsody model.
Property MakefileContent MultiLine " **** Lots of Stuff **** "
If your environment is close to the donor environment then you do not have to change much here. Otherwise it is possible that you have to go to all the lines and decide if that is still correct.
So… the rest will be in the next episode
Happy Modeling with Rhapsody
Walter van der Heiden (email@example.com)