How can you configure the default setting of IBM Rational Rhapsody Developer Edition for C++ (RiC++) in order to include external source files into MakeFile?
In some cases, you want to import legacy source files into Rhapsody models as external elements. For those externally imported elements (classes and files), Rhapsody doesn't generate code, hence you can preserve legacy code as part of your existing model. However, by default, Rhapsody excludes those external elements from the build even though you turn CG::File::AddToMakefile property on.
For general information regarding code generation for external elements, see "Code generation for external elements" topic in Rhapsody Info Center. This technote will provide 3 solutions to allow the inclusion of external elements into the build.
Solution 1 - Use Component File element
This method is the most traditional way to include external model elements in the build. For details, you will refer to " Add source file to the build" topic in Rhapsody Info Center.
Solution 2 - Use File/Class element
Comparing to Solution 1, this method will give you a more granular control by letting you control which individual elements (either Class and/or File) to include in MakeFile. However, this method requires more manual works as compared to other presented solutions.
Note: The "File" used in this solution refers to ordinary RiC++ File to be created at package level. A "File" created at component level is commonly referred as "File (component)"
To apply this solution, follow instructions below:
- Add a Class/File element to map the external source code into the model.
- Set property CG::Class::UseAsExternal as "checked" for the added element.
- Set property CG::File::AddToMakefile as "checked".
- Set the path to the external file in property CG::Class:FileName to make Rhapsody aware the location of the external source code. The path info would be used in MakeFile generated by Rhapsody.
Note: Both absolute and relative path are supported.
- Right click the model element, from context menu, click Add New > SourceArtifact.
Note: In order to include this external model element into MakeFile, SourceArtifact is required for the external model element. To enable the display of SourceArtifact, make sure Top Menu > View > Browser Display Options > Show Source Artifacts is checked.
- Make sure the type of added SourceArtifact is set either "Logical" or "Implementation" (DO NOT choose "Specification").
- Rename SourceArtifact with the name of the external source code (e.g. rename the element to "hoo", if the external file name is "hoo.cpp").
- Click [Elements] tab of the SourceArtifact to make sure the model element is correctly mapped in SourceArtifact. In case of Class, the mapping will be done automatically. For File, manually add its parent element to [Elements] tab as below:
IMPORTANT: You might occasionally find the behavior of File is not consistent with Class. This is because File element is designed to be used as external element only, and not supposed to be built from Rhapsody. You are encouraged to use external Class element in RiC++ model to avoid any confusion you might experience.
- Generate MakeFile to make sure the external source file (e.g. hoo.obj) file is being added in the build.
Solution 3 - Use Additional Sources setting
This method is the simplest way. All you need to do is to add the path to external source files directly into [Additional Sources] field on [Settings] tab of the model configuration.
Note: You can add multiple external source files by separating with comma.
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.