software-dl.ti.com Open in urlscan Pro
2a02:26f0:3500:591::b48  Public Scan

Submitted URL: https://dev.ti.com/tirex4-desktop/nodeContent?devices=AM3352&node=A__APCOPn6qUQAjzKNUeB0cuQ__ccs_devtools__FUz-xrs_...
Effective URL: https://software-dl.ti.com/ccs/esd/documents/ccs_portable-projects.html
Submission: On September 26 via manual from SG — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

Portable Projects


INTRODUCTION

Projects that are shared among multiple users should be made portable. Portable
projects should essentially avoid absolute paths.

There are two main areas where absolute paths should be avoided:

 * When linking source files.
 * When specifying compiler include paths and linker search paths.


VARIABLES

To facilitate the creation of portable projects, there are two kinds of
variables supported by CCS - Path Variables and Build Variables.

Path Variables specify locations in the file system. The path to linked source
files/resources can be set relative to these variables. This allows you to avoid
references to a fixed location on your file system.


Build Variables specify locations, strings etc. They can be used in the project
build options, for example, when specifying paths for header files or libraries.


You can set paths to be relative to either predefined variables or user-defined
variables.

To see the complete list of Path variables go to Project Properties → Resource →
Linked Resources → Path Variables tab.

To see the complete list of Build variables, go to Project Properties → Build →
Variables tab, and check the box Show system variables.

NOTE:

There are also Dynamic Variables. These are all predefined, and are only used
within Debug Configurations.


PREDEFINED VARIABLES

Each CCS project contains a predefined set of Path and Build variables. Some of
these are defined by Eclipse (such as PARENT_LOC, PROJECT_LOC and WORKSPACE_LOC)
and some are defined by CCS (such as CG_TOOL_ROOT, CCS_INSTALL_ROOT).

For example, CG_TOOL_ROOT is set to the root installation directory of the
version of compiler tools chosen to build the project. When you change the
compiler version used by the project, this variable is automatically updated to
the appropriate path for the selected version.

CCS also defines some variables when a TI software product (such as Simplelink
SDK, C2000Ware, etc.) is installed into CCS and selected for the project. An
example is COM_TI_SIMPLELINK_XXXX_SDK_INSTALL_DIR (where XXXX is the device
name). This variable is automatically set to the root installation directory of
the version of Simplelink SDK product selected in the Project Properties →
General → Products tab. If you have multiple versions of the SDK installed and
change the version of SDK used by the project in the Project Properties →
General → Products tab, this variable is automatically updated to the
appropriate path for the selected version.


USER-DEFINED VARIABLES

Custom Build and Path variables can be created at the workspace level or project
level.

When you create a new variable at the workspace level it will automatically
propagate as both Path variable and Build variable for all projects in the
workspace. This is advantageous for projects checked into source control as the
project does not have to be modifed with each checkout.

When you create a new variable at the project level it will apply only to that
specific project. This allows the project to be portable across different
workspaces and computers.


CREATING VARIABLE AT WORKSPACE LEVEL

To create a workspace level Build or Path variable:

 * Go to menu Window → Preferences → Code Composer Studio → Build → Variables.
 * Click the Add button to define a new variable.
 * Specify the Variable name, Type and Value.
 * Click Apply and Close.

This screenshot shows an example of setting a new variable called MYROOT.







If the Type selected is File, Directory or Path, then the variable gets defined
as both a Build variable and a Path variable for all projects in the workspace.
If the Type selected is not one of the above then the variable gets defined as
just a Build variable. Note that for it to be accepted as a Path variable the
path should be absolute.

In this example, the Type selected is Directory so the variable is defined as
both a Build variable and Path variable.

To confirm the variable is defined:

 * Select any project in the workspace.
 * From the context menu, go to Properties → Resource → Linked Resources → Path
   Variables tab.
 * Observe that the variable set earlier is shown here.
   
 * Go to Build → Variables tab, and check the box to Show system variables.
 * Observe that the variable set earlier is shown here as well.
   

This variable can now be used both as a Path variable and as a Build variable.


CREATING VARIABLE AT PROJECT LEVEL

To create a project level Build variable:

 * Go to Project Properties → Build → Variables tab.
 * Click the Add button to define a new variable.
 * Specify the Variable name, Type and Value.

This will define the variable as a Build variable. It will also define it as a
Path variable if the Type selected is File, Directory or Path.

To create a project level Path variable:

 * Go to Project Properties → Resource → Linked Resources → Path Variables tab.
 * Click the New button to define a new variable.
 * Specify the Variable name, Type and Value.

This will define the variable as a Path variable and also as a Build variable.


LINKING SOURCE FILES

To make a project portable, use Path variables when linking source files to the
project. You can use predefined Path variables or custom variables that you
created.

To link files relative to the Path variable:

 * Select Add Files from project context menu, browse and select the file(s) you
   wish to link.
 * In the dialog that comes up, select Link to files and choose whether to
   create a link relative to PROJECT_LOC (selected by default, and resolves to
   the root folder of the current project) or to one of the other available path
   variables.
   


SPECIFYING COMPILER/LINKER OPTIONS

To make a project portable, use Build variables in the project build options,
such as when specifying compiler include paths and linker search paths. You can
use the predefined system variables or variables that you created.

Refer to the value of a variable using the syntax ${VAR}. For paths relative to
the variable use ${VAR}/dir_name/.

The screenshot below shows an example of using the user-defined variable MYROOT
and several predefined variables in the project's compiler include options.








SHARING VARIABLES FILE

You can share variables among multiple users by defining the needed variables to
an *.ini file that the user can import.

 * The file can be automatically read during a project import if:
   * the file is named macros.ini and
   * the file is at the project root location
 * Otherwise the file can be manually imported via menu File → Import → Build
   Variables.
 * After import, the variables are set both as Path variables and Build
   variables.
 * The variables are set at the workspace level.

The syntax for defining variables in the *.ini file is

VAR = VALUE


By default, variable definitions are assumed to be paths. However, there is
support for specifying a string type for the variable. To specify a variable as
a string type, prepend the variable definition with [string].

[string] VAR = VALUE


PORTABLE TARGET AND DEBUG CONFIGURATIONS

Target configuration files and debug configurations can be made portable by
specifying their locations using a relative path instead of absolute path.


TARGET CONFIGURATIONS

When a Target Configuration file is linked to a project it defaults to an
absolute path. The steps below show how to link a target configuration file and
then convert the absolute path to variable relative path:

 * Open the Target Configurations view (menu View → Target Configurations).
 * Right-click on the desired target configuration, go to Link File to Project
   and select the project that will use this specific target configuration.
 * Go to the Project Explorer view, highlight the project selected in the
   previous step.
 * From the project's context menu, go to Properties → Resource → Linked
   Resources. The target configuration file should be shown there.
 * Highlight the target configuration and click on Convert.... After a few
   confirmation screens, the path to the target configuration will be
   automatically changed to a path relative to a variable.
 * Click OK to accept all changes.


DEBUG CONFIGURATIONS

Debug Configurations can also be made portable by ensuring that there are no
absolute paths used in their fields.

When launching a project-based debug session for the first time, the debug
configuration generated for that project is portable by default. This is because
it uses Dynamic Variables.


DYNAMIC VARIABLES

In Eclipse (and by extension, CCS) Build and Path Variables can not be used
directly in the fields of Debug Configurations. However there are variables that
can be used specifically within Debug Configurations, called Dynamic Variables.
In CCS Debug Configurations, Dynamic variables can be used in the Target
Configuration, Initialization Script (since CCSv9.2), and Program fields.

Some common Dynamic variables include (where myProjectName is the name of the
project that you wish to reference):

 * ${build_artifact:myProjectName} - resolves to the output file built by the
   project, in the build directory of the project's active build configuration.
   * Automatically used in the Program field, in the Debug Configuration
     generated by launching a project-based debug session.
 * ${target_config_active_default:myProjectName} - resolves to the active target
   configuration file of the project's active build configuration.
   * Automatically used in the Target Configuration field, in the Debug
     Configuration generated by launching a project-based debug session.
 * ${workspace_loc:/myProjectName/directoryName/fileName.ext} - resolves to an
   arbitrary file or directory of an open project; this works even if the
   project's folder is outside of your workspace.
   * In CCSv9.2 and higher, this is automatically used whenever you specify a
     file using the Workspace... button, in the Debug Configurations dialog.

USING BUILD/PATH VARIABLES IN DEBUG CONFIGURATIONS

While Build and Path variables like ${PROJECT_BUILD_DIR} can not be used
directly in the fields of Debug Configurations, there is a Dynamic variable
(build_var) that can be used as a wrapper to evaluate any Build or Path variable
in the context of a given project and build configuration. Usage is as follows:

 * ${build_var:/myProjectName/buildConfigurationName/BUILD_VARIABLE} - evaluates
   BUILD_VARIABLE in the context of myProjectName's buildConfigurationName build
   configuration.
 * ${build_var:/myProjectName/BUILD_VARIABLE} - evaluates BUILD_VARIABLE in the
   context of myProjectName's active build configuration.
 * ${build_var:BUILD_VARIABLE} - evaluates BUILD_VARIABLE in the context of the
   currently selected resource's project's active build configuration.
   * NOTE: this usage is not recommended, because the currently selected
     resource comes from the Project Explorer or the active editor, and the
     behaviour may be difficult to predict.

EXAMPLE

Assume there is an open workspace project called "myProjectName", and in that
project's active build directory there is an executable file called "file1.out".
To load that file to the target when launching a debug session on the project,
you may set the project's Debug Configuration's Program field to:

Select text

${build_var:/myProjectName/PROJECT_BUILD_DIR}/file1.out


 * The build_var Dynamic variable will evaluate the PROJECT_BUILD_DIR Build
   variable for myProjectName's active build configuration; this resolves to
   myProjectName's active build directory.
 * Then, "/file1.out" is appended to that directory, and you have the full path
   to the desired file.

RESOURCES

Code Composer Studio
Related Technical Documents
TI E2E Technical Forums


This work is licensed under a Creative Commons
Attribution-NonCommercial-NoDerivatives 4.0 International License.
Last updated: May 17 2022 18:00 Central Time
 * Introduction
 * Variables
   * Predefined Variables
   * User-defined Variables
     * Creating Variable at Workspace Level
     * Creating Variable at Project Level
 * Linking Source Files
 * Specifying Compiler/Linker Options
 * Sharing Variables File
 * Portable Target and Debug Configurations
   * Target Configurations
   * Debug Configurations
     * Dynamic Variables
       * Using Build/Path Variables in Debug Configurations

×Close


Die TI-Websites verwenden Cookies, um die Seitenfunktionalität und Ihre
persönliche Benutzererfahrung zu verbessern. Um weitere Informationen zu
erhalten oder Ihre Präferenzen zu ändern, besuchen Sie die Seite mit unserer
Cookie-Richtlinie. Klicken Sie auf „Annehmen und Fortfahren“, um Cookies
anzunehmen und zur Seite zu gelangen.
Präferenzen verwalten Annehmen und Fortfahren