What Is Code Deployment?
Code deployment controls how your generated C/C++ code is organized:
-
Where files go: Public
headers in
include/, internal headers in
internal/, sources in src/
-
How files are named: Based on
UML element names with configurable patterns and extensions
-
Build integration: Automatic
CMakeLists.txt or Makefile generation
Configure Your Code Deployment and Generate Code
In the Software Producer Configuration
Diagram, select a built-in deployment or create a custom
one.
Select a Deployment Configuration
|
Built-in Deployment
|
Description
|
|
Flat
|
All files in single directory, no subdirectory structure
(default)
|
|
FlatQualified
|
Flat structure with qualified (package-prefixed) file
names
|
|
Hierarchical
|
Organized include/,
internal/, and src/
layout following the package hierarchy
|
|
CMake
(planned, not yet implemented)
|
Hierarchical layout with a generated
CMakeLists.txt template
|
|
Makefile
(planned, not yet implemented)
|
Hierarchical layout with a generated
Makefile
|
For the detailed configuration of each built-in deployment, refer
to the built-in deployments reference document.
Note:
Note: The
CMake and Makefile
built-in deployments are not yet available. Until they are
delivered, use the Hierarchical deployment
and attach a custom build file via a
Text Template if needed.
Note:
Tip: To apply a deployment to
a generation configuration, drag the deployment element from the
diagram (or from the containment tree) onto the target
generation configuration.
Creating a Custom Deployment
To create your own deployment configuration:
-
Open the Software Producer
Configuration Diagram.
-
From the diagram palette, expand the
Code Deployment category
and drag C and C++ Code
Deployment onto the diagram.
-
Give the new deployment a meaningful name and edit its
properties to match your conventions:
-
Public, internal, and source directories
-
File extensions for C and C++ headers and sources
-
File path and file name patterns (advanced)
-
To add a build file or any other companion file (such as a
CMakeLists.txt,
Makefile, or README):
-
Drag a Text Template
from the palette onto the diagram to create a new template
element.
-
Drag that Text Template
onto your C and C++ Code
Deployment to attach it as an additional
resource of the deployment.
-
To choose the output filename of an attached resource, select
it on the diagram, open its
Specification window, and
edit the File Path property
(for example,
CMakeLists.txt, or
<lib.dir>README.md to place the file
in the library directory; the path uses the
<variable> syntax of the
Path Pattern
Properties).
-
The Scope property says how
many times the resource is generated:
Project (once for the whole generation, the
default), Library (once per
<<ModelLibrary>>) or
Package (once per package that owns
generated code, inside a library or not). A
Library or Package
resource needs a discriminating variable in its
File Path
(<lib.dir>CMakeLists.txt,
<package.lib.path>/CMakeLists.txt),
otherwise every render lands on the same file and the
generator reports ESP_RES_001.
-
Edit the Body of the
Text Template to define the
content of the generated file. Templates support variable
substitution and file iteration macros (see
Template Variables).
-
To use the new deployment in a generation configuration, drag
and drop the C and C++ Code
Deployment element onto the target generation
configuration on the diagram. This sets it as the deployment
used by that configuration.
Example: Custom Embedded Deployment
A deployment named EmbeddedDeployment
configured with:
-
Public area:
api
-
Internal area:
private
-
Source area:
source
-
C header extension:
.h
-
C source extension:
.c
-
One attached Text
Template with file path
Makefile
Generate Code
Run code generation as usual. As a result, files are organized
according to your deployment configuration.
Understanding File Placement
Source Files
All implementation files (.cpp,
.c) go to the source
area regardless of visibility: Default location:
src/package/path/ClassName.cpp
ModelLibrary Context
The library root is identified by applying the standard UML
<<ModelLibrary>> stereotype to a
package. Unlike the deployment elements created from the palette,
<<ModelLibrary>> is a native UML
stereotype that you apply directly to an existing package: in the
Containment Tree, right-click
the target package, choose
Stereotype…, and select
ModelLibrary. The chosen package then becomes
the stable reference point used by the deployment to compute
public, internal, and source paths.
Example structure:
<<ModelLibrary>>
MyLibrary
├── PublicAPI (package)
│ └── PublicClass (public visibility)
└── Internal (package)
└── InternalClass (private visibility)
Paths are relative to the
<<ModelLibrary>> root:
MyLibrary/ ← ModelLibrary root
├── include/ ← publicArea (default)
│ └── API/
│ └── PublicClass.hpp
├── internal/ ← internalArea (default)
│ └── Internal/
│ └── InternalHelper.hpp
└── src/ ← sourceArea (default)
├── API/
│ └── PublicClass.cpp
└── Internal/
└── InternalHelper.cpp
Library-Relative Variables
The .lib. variables
(<package.lib.path>,
<package.lib.qname>,
<element.lib.qname> in patterns,
${package_lib_path} in templates) are relative
to the enclosing <<ModelLibrary>>,
the library itself excluded.
Two companion variables carry the library name only when there is
one: <lib.dir> is
MyLib/ inside a library and empty outside,
<lib.prefix> is MyLib_
inside a library and empty outside. Composing them gives the
library-qualified form, without an orphan separator when the model
has no library at all.
For the model below, with the Hierarchical
deployment
(<area.public>/<lib.dir><package.lib.path>/<file.name>
and
<lib.prefix><element.lib.qname>):
Model
├── MyLib <<ModelLibrary>>
│ ├── Direct class directly in the library
│ └── Sub
│ └── Deep class in a sub-package of the library
└── Plain
└── Loose class outside any library
|
Element
|
<package.lib.path>
|
<lib.dir>
|
Header file
|
<lib.prefix><element.lib.qname>
|
MyLib::Sub::Deep
|
Sub
|
MyLib/
|
include/MyLib/Sub/Deep.hpp
|
MyLib_Sub_Deep
|
MyLib::Direct
|
(empty)
|
MyLib/
|
include/MyLib/Direct.hpp
|
MyLib_Direct
|
Plain::Loose
|
Plain (no library: full path)
|
(empty)
|
include/Plain/Loose.hpp
|
Plain_Loose
|
A pattern written without the prefix, such as
<area.source>/<package.lib.path>/<file.name>,
gives the pure relative form: src/Sub/Deep.cpp.
The root package of the model is never a library, even when it
carries the <<ModelLibrary>>
stereotype.
Deployment Configuration Properties
The following properties are available on a
C and C++ Code Deployment
element.
For the formal property definition and full tagged-value reference,
refer to the C and C++ Code deployment profile definition document.
Directory Properties
|
Property
|
Type
|
Default
|
Description
|
publicArea
|
String
|
include
|
Directory for public headers
|
internalArea
|
String
|
internal
|
Directory for nonpublic (internal) headers
|
sourceArea
|
String
|
src
|
Directory for all implementation files
|
File Extension Properties
|
Property
|
Type
|
Default
|
Description
|
cppHeaderExt
|
String
|
.hpp
|
Extension for C++ header files
|
cppSourceExt
|
String
|
.cpp
|
Extension for C++ source files
|
cHeaderExt
|
String
|
.h
|
Extension for C header files
|
cSourceExt
|
String
|
.c
|
Extension for C source files
|
Path Pattern Properties
Path patterns use the <variable> syntax
(CATIA Magic convention):
|
Property
|
Type
|
Default
|
Description
|
publicHeaderPath
|
String
|
<area.public>/<lib.dir><package.lib.path>/<file.name>
|
Path pattern for public headers
|
internalHeaderPath
|
String
|
<area.internal>/<lib.dir><package.lib.path>/<file.name>
|
Path pattern for internal headers
|
sourcePath
|
String
|
<area.source>/<lib.dir><package.lib.path>/<file.name>
|
Path pattern for source files
|
Template Variables
Templates (<<TextTemplate>> body)
support automatic variable substitution using the
${variable_name} syntax. Variables are
available in both file header templates and resource templates;
some are context-specific.
Top-Level Variables
These variables are available in all
<<TextTemplate>> contexts (file
headers and resource templates):
|
Variable
|
Description
|
Available In
|
Example Value
|
${lib_name}
|
Name of the current ModelLibrary
|
All
|
MyLibrary
|
${lib_dir}
|
${lib_name}/ inside a ModelLibrary,
empty for the project scope
|
All
|
MyLibrary/
|
${lib_prefix}
|
${lib_name}_ inside a ModelLibrary,
empty for the project scope
|
All
|
MyLibrary_
|
${area_public}
|
Public header directory from deployment
|
All
|
include
|
${area_internal}
|
Internal header directory from deployment
|
All
|
internal
|
${area_source}
|
Source files directory from deployment
|
All
|
src
|
${year}
|
Current year
|
All
|
2026
|
${generation_date}
|
Date of code generation
|
All
|
2026-02-11T09:30:00Z
|
${generator_version}
|
Software Producer version
|
All
|
2026.1.0
|
${comment_banner}
|
Configurable banner string (length from
bannerLength)
|
All
|
****...****
|
${configuration_name}
|
Name of the generation configuration
|
All
|
MyConfig
|
${project_name}
|
Name of the current project
|
All
|
VehicleProject
|
${file_name}
|
Generated file name
|
File Header
|
MyClass.hpp
|
${package_name}
|
Package owning the element (in a file header) or the
package of the resource scope (in a resource: the root
model, the library or the package, see
Scope Macros)
|
All, ##PACKAGES
|
Controls
|
${package_path}
|
Full package path
|
All, ##PACKAGES
|
Root/Sub/Controls
|
${package_lib_path}
|
Package path relative to the ModelLibrary, the library
excluded
|
All, ##PACKAGES
|
Continue/Nesting
|
${element_qname}
|
Fully qualified element name
|
File Header
|
Root_Sub_MyClass
|
${element_relname}
|
Chain of non-package owners including the element,
_-joined boundary
|
File Header
|
Button_Toggle
|
${parent_relname}
|
Chain of non-package owners excluding the element,
_-joined
|
File Header
|
Button
|
${element_id}
|
UUID of source UML element
|
File Header
|
_19_0_2_abc123
|
Note:
Available In:
All = available in both file header and
resource templates. File Header = in the
fileHeaderTemplate context, where the
element is the UML element the file is generated from.
##PACKAGES = inside that
macro, and everywhere in a Package-scoped
resource (see Scope
Macros).
File Variables (Inside Macros)
When iterating file collections with macros, these variables are
available within ##MACRO_NAME { ... ##}
blocks:
|
Variable
|
Description
|
Example Value
|
${file_path}
|
Full relative path from library root
|
src/API/PublicClass.cpp
|
${file_name}
|
Filename with extension
|
PublicClass.cpp
|
${file_basename}
|
Filename without extension
|
PublicClass
|
${rel_path}
|
Path relative to area directory
|
API/PublicClass.cpp
|
File Collection Macros
Resource templates provide macros for iterating over generated
files:
|
Macro
|
Description
|
##ALL_SOURCES { ... ##}
|
Iterate all .cpp or
.c implementation files
|
##ALL_SOURCE_DIRS { ... ##}
|
Iterate the distinct directories that contain source
files
|
##PUBLIC_HEADERS { ... ##}
|
Iterate headers in public area
|
##INTERNAL_HEADERS { ... ##}
|
Iterate headers in internal area
|
##ALL_HEADERS { ... ##}
|
Iterate all headers (public + internal)
|
Macro syntax:
##MACRO_NAME { content ##}
Inside ##ALL_SOURCE_DIRS, the file variables
describe each directory rather than a file:
${file_path} (and
${rel_path}) hold the directory path, and
${file_name} holds the leaf directory name.
This is convenient for build systems that consume directories,
for example CMake’s aux_source_directory or
target_include_directories.
Scope Macros
A resource template can also iterate over the model structure
instead of the generated files:
|
Macro
|
Available in
|
Description
|
##LIBRARIES { ... ##}
|
Project scope
|
Iterates over the registered
<<ModelLibrary>> packages
(the root model is not one of them);
${lib_name},
${lib_dir} and
${lib_prefix} are reassigned per
iteration, and the collection and scope macros inside
the block are restricted to that library
|
##PACKAGES { ... ##}
|
All scopes
|
Iterates over the packages inside the current scope that
own generated code, at any depth; sets
${package_name},
${package_path} and
${package_lib_path} per iteration
|
##USED_PACKAGES { ... ##}
|
Library and
Package scope
|
Iterates over the packages the current scope uses
outside itself, from the modeled UML Usage
relationships; sets
${used_package_name},
${used_package_path} and
${used_package_lib_path} (see
Declaring
what a package uses)
|
The scope of a resource designates a
unit — the whole generation
for Project, one
<<ModelLibrary>> for
Library, one package for
Package — and the macros describe that unit
the same way at every scope: ##ALL_SOURCES
and the other collection macros list its files,
##PACKAGES the packages inside it,
##USED_PACKAGES what it uses outside itself.
${package_name},
${package_path} and
${package_lib_path} are set everywhere in the
template and designate the unit’s package: the root model in a
Project resource, the library in a
Library resource, the package in a
Package resource. Inside
##LIBRARIES they keep designating the
resource’s own unit; the iterated library is
${lib_name}.
Escape Character
Use $$ to produce a literal
$ character in template output. This is
useful when generating files that contain their own
${...} syntax (for example, CMake or Makefile
variables):
$${CMAKE_CURRENT_LIST_DIR} → renders as: ${CMAKE_CURRENT_LIST_DIR}
Example CMakeLists.txt Template
# Generated build file for ${lib_name}
add_library(${lib_name})
target_sources(${lib_name} PRIVATE
##ALL_SOURCES {
${file_path}
##}
)
target_include_directories(${lib_name}
PUBLIC ${area_public}
PRIVATE ${area_internal}
)
Generated output (for library
MyLibrary with 2 source files):
# Generated build file for MyLibrary
add_library(MyLibrary)
target_sources(MyLibrary PRIVATE
src/API/PublicClass.cpp
src/Internal/Helper.cpp
)
target_include_directories(MyLibrary
PUBLIC include
PRIVATE internal
)
Declaring what a package uses
A package-scope or library-scope build file can list the packages
the current package or library depends on. The dependency is the
one you model: a UML Usage
relationship (no other kind of dependency is read) from the
package, or from any element it owns, to the used package or to
one of its elements. Nothing is deduced from the generated
#include lines, on purpose: a use that is not
modeled is then missing from the build file and fails at build
time, which is exactly where the model gap should show.
Inside a Package-scoped or
Library-scoped
<<Resource>> template:
##USED_PACKAGES{
target_link_libraries(${package_name} ${used_package_name})
##}
Each iteration exposes ${used_package_name},
${used_package_path} and
${used_package_lib_path}. A package that uses
nothing renders an empty block, and the block renders nothing in a
Project resource: nothing is used outside the
whole generation.
What is listed follows the scope:
-
In a
Package resource: the packages used by
the package’s own elements. Its sub-packages are units of
their own and list their own usages.
-
In a
Library resource: the packages used by
every package of the library, the library’s own packages
excluded — they are not dependencies of the library.
-
In both: a Usage drawn from a package
to a package covers everything the client package
contains, so the packages below it inherit it. A Usage drawn
on
Root::Classes toward
Root::Libraries is listed by the build file
of every package with generated code under
Classes, even though
Classes itself, owning no code, has no
build file. A Usage between a class and another element is not
inherited: it belongs to the package whose files need it.
Limitations
The following features are not yet supported:
|
Feature
|
Variables
|
Description
|
##DEPENDENCIES macro
|
${dep_name},
${dep_path}
|
Planned macro for iterating library dependencies in build
files; not yet available in the current delivery
|
When this macro is made available, the
##DEPENDENCIES block iterates over library
dependencies and expose ${dep_name} (library
name) and ${dep_path} (library path) for each
dependency.
Troubleshooting
Files Not Appearing in Expected Location
Check these items: 1. Is the
library root package marked with the
<<ModelLibrary>> stereotype?
(Right-click the package in the
Containment Tree >
Stereotype… > select
ModelLibrary.) 2. Is a valid
C and C++ Code Deployment
selected in the configuration diagram? (Or leave empty for the
default flat deployment.) 3. Has the deployment been associated
with the generation configuration? (Drag and drop the deployment
onto the generation configuration on the diagram.) 4. Are UML
visibilities correctly set on classes?
Build File Not Generated
Verify: 1. The
Text Template for the build
file is attached to the deployment as an additional resource
(drag it onto the deployment after creating it on the diagram).
2. The attached resource has a valid
File Path (set in its
Specification window) and a
non-empty Body. 3. Template
syntax is valid (check $$ escaping for
literal $ characters).
Wrong File Extensions
Check the extension properties on your
deployment: - C++ header / source extensions
(defaults: .hpp / .cpp) -
C header / source extensions (defaults: .h /
.c)
For Advanced Users: Underlying Stereotypes
The palette elements described above are backed by UML stereotypes
from the SoftwareProducerCodeDeployment
profile:
|
Palette element / property label
|
Underlying stereotype
|
|
C and C++ Code
Deployment
|
<<CFamilyCodeDeployment>>
|
|
Text Template
|
<<TextTemplate>>
|
|
Additional resource (created when a
Text Template is
dropped on a deployment)
|
<<Resource>>
|
For the complete tagged-value reference and stereotype model, see
the C and C++ Code deployment profile definition document.
|