NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.
Creating portable projects in CCSv5
When is it necessary to create a portable project? If you wish to share a project with another user and the person receiving the project file already has a copy of the common sources for the project so you are only sharing the project files, then you would need to make the project portable. A typical scenario might be one where multiple users are working on the same project, the project folder/files are checked into source control and another user would check it out and use it. The idea behind making a project portable is to eliminate absolute paths as much as possible in the project so the project is re-usable with minimal modifications.
To facilitate the creation of portable projects, there are two main variables to define in CCS – Path Variables and Build Variables.
Path variables specify locations in the file systems. The path to source files/resources linked to the project can then be made relative to these variables.
Build variables specify locations, strings etc. They are used in the project build options, for example, when specifying paths for header files or libraries.
These variables can be set at the project level and will be carried over when the project is shared with another user. If the other user has the source files/libraries installed in a different folder, they can simply modify the path variable and build variable to point to their root software directory.
Steps to create a portable project
The key to creating portable projects is to avoid absolute paths. The below steps show how to create a portable project assuming a project structure similar to TI’s controlSuite software as an example.
- The folder F2806x_common contains common source/include/linker command files shared across different projects
- The folder F2806x_examples contain the project folders
- The folder F2806x_headers contains more include/linker command files
Another user may only have F2806x_common and F2806x_headers folders and you may want to share a project you created with that user.
To create a new portable project:
- Create a new project in CCS (assume the project is created within the F2806x_examples folder)
- Create a new Linked Resource path variable – Right-click on the project, go to Properties->Resource->Linked Resources. On the Path Variables tab, click on New and add a new variable.
The variable name CONTROLSUITE_ROOT is being used in this example. Set it to point to the root location of the software, in this case, the root folder which holds the F2806x_common, F2806x_examples and F2806x_headers sub-folders.
- Create a new Build Variable – Right-click on the project, go to Properties->Build. On the Build Variables tab, click on Add and add a new variable.
Point it to the root location of the software. In this example, the same name CONTROLSUITE_ROOT is being used for the build variable as well.
- Now add the resources (source files) to your project - Right-click on the project, go to Add Files, choose the file(s) to add to project. Then choose Link to Files. Make sure to check the box “Create link locations relative to:” as otherwise the links will be absolute path locations rather than relative paths. Then choose the path variable relative to which you want the resources to be set up. The path variable it defaults to is PROJECT_LOC which is the location of the project. If this is chosen, the relative paths for linked resources will be relative to this variable. This is ok if all users of the project will be using the same file structure, including location of project folder. You have the option of choosing a different path variable, either one already provided or one that you created. To make it more portable, choose the path to be relative to CONTROLSUITE_ROOT. This will set up all your linked resources that are part of your project to have paths relative to the variable CONTROLSUITE_ROOT
- Continue setting up the rest of your project build options
- When adding include paths for header files and search paths for libraries in the Compiler and Linker options, specify paths relative to the build variable CONTROLSUITE_ROOT.
These are the basic steps required to set up a project such that it can be shared among many users without much trouble. Let’s say user A has the common source and include files installed under c:\Programs\ti\Software, and user B shares a project that he created using the above structure, user A can change the Linked Resource path variable and build variable to point to his root directory c:\Programs\ti\Software, and the project should build.
- If you need to add libraries to the project, the preferred method is to add them via the Linker->File Search Path option. The library name can be added under --library option and the path can be added under --search_path option as relative to a path variable.
- If you have pre or post build steps in the project, try to use path variables instead of hard-coded paths.
Refer to the following wiki pages for additional details about this topic