IBM How to include Rational Rhapsody external source files into configuration MakeFile - United States external; AddToMakefile; build; make; File element; MakeFile; external object; external objects; make file TECHNOTE (FAQ)

QUESTION
 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? 

CAUSE
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 [File::AddToMakefile] property on.

ANSWER
For general information regarding code generation for external elements, see "Code generation for external elements [http://pic.dhe.ibm.com/infocenter/rhaphlp/v8/index.jsp?topic=%2Fcom.ibm.rhp.uml.diagrams.doc%2Ftopics%2Frhp_r_dm_cd_genrtion_extnl_elmts.html]" 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 

 * 
 * 
 * Add source file to the build
 * 


Solution 2 - Use File/Class element 

 * 
 * 
 * 
 * 
 * Note:
 * 
 * 
 * 
 * 
 *  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 [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:
   
   [/support/docview.wss?uid=swg21621937&amp;aid=1]
   
   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 

 * 
 * 
 * [Additional Sources]
 * 
 * [Settings]
 * 
 *  
   
   Note: 
 * 


RELATED INFORMATION
#Code generation for external elements [http://pic.dhe.ibm.com/infocenter/rhaphlp/v8/index.jsp?topic=%2Fcom.ibm.rhp.uml.diagrams.doc%2Ftopics%2Frhp_r_dm_cd_genrtion_extnl_elmts.html]
Add source file to the biuld [http://pic.dhe.ibm.com/infocenter/rhaphlp/v8/topic/com.ibm.rhp.uml.diagrams.doc/topics/rhp_t_dm_adding_source_files_build.html?resultof=%22%61%64%64%22%20%22%73%6f%75%72%63%65%22%20%22%73%6f%75%72%63%22%20%22%66%69%6c%65%22%20%22%62%75%69%6c%64%22%20]
About implementation and specification in a File entry of type Logical under Component I use Rhapsody for C++ and want to add a .c/.h file combo.

I know I can easily do this by adding 2 File entries under the Component level: one being Implementation type and the other Specification. Then add the appropriate code in the respective Text Elements.

Alternatively I can do the equivalent by having a single File entry of type Logical that will generate 2 files (and change the CG:ImplementationExternsion property changed to .c).

However when the type is set to Logical, I don't know where to place the code for the Implementation and the code for the Specification so that they end up each in the right file. Right now, whatever I put in the Text Element ends up in both files.

Does anyone know how I can indicate Rhapsody that "this code is the implementation (.c)" and "this code is the specification (.h)"?

---

Rhapsody 8.0.5 for C++ on Windows
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 [File::AddToMakefile] property on.