Customizing directory structure for generated code

The code generation mechanism provides a number of options for customizing the directory structure for the generated code. This includes both the ability to specify the output directory for code generation, as well as the ability to specify the directory structure within the output directory.

Specifying the output directory for generated code

The code generation mechanism uses the components and configurations you have created in order to determine where code should be generated.

By default, all files are generated in the directory that represents the configuration for which code is being generated. To have code generated to a different directory:

  1. Open the Features window for the relevant component.
  2. On the General tab, use the Directory field to specify the directory to which you want the code to be generated. You can enter a relative path (beneath the directory that contains your model), or an absolute path.

Specifying the directory structure within the output directory

You can use one or both of the following properties to control the directory structure used for generated code within the output directory:

  • [lang]_CG::Package::GenerateDirectory - Set the value of GenerateDirectory to True to have a directory created for each package. The code generated for elements in the package will be generated to the directory representing that package.
  • [lang]_CG::Configuration::DefaultSpecificationDirectory and [lang]_CG::Configuration::DefaultImplementationDirectory - These properties are available for C and C++ since these languages have separate specification and implementation files. Use these properties to specify the names of the subdirectories that should be used to separate the specification files from the implementation files. For example, you can have all the specification files generated to a subdirectory called inc and all the implementation files generated to a subdirectory called src. If you do not provide values for these properties, the specification and implementation files will be generated to the same directory.

    For C and C++ you can choose to use these properties in conjunction with the GenerateDirectory property. For example, if you specify "inc" as the specification directory and "src" as the implementation directory, and set the value of GenerateDirectory to True, you will end up with inc and src subdirectories under each package directory.

Note: If these standard options are not sufficient to create the directory structure you want for code generation, IBM® Engineering Systems Design Rhapsody® also provides an option to map individual model elements to specific output files and to map individual output files to specific directories. For more details, see Rhapsody code generation: mapping elements to files and mapping files to folders.