Portable Projects
From Texas Instruments Embedded Processors Wiki
Contents |
Portable Projects in CCSv4
This topic describes in detail how to modify your project to facilitate having multiple users working on the same project at the same time. If you are interested in how to package up and send a project (including all source files) to another user, please refer to the Sharing Projects topic.
Project Creation
CCS projects are created inside the workspace directory by default. However, it is possible to create a CCS project outside of the workspace directory (e.g. in a source controlled directory). First dialog that appears after selecting File->New->CCS Project has a check box “Use Default location”, un checking this box allows you to specify the directory where project files should reside. Additional directory with project name will not be created if non-default location is used as user is specifying exact directory for the project in this case. Follow rest of wizard steps to create a project.
Adding Source Files
CCS provides two modes of adding source files to projects. Users can add files directly to project directory or link files to a project.
Source files in the project
- Adding files can be achieved by selecting “Add Files” from project context menu. Another way is to copy files directly into project directory. CCS projects automatically include all files that appear in directory where project exists, including all subdirectories. Thus an easy way of adding multiple files is to select all folders/files that currently contain sources and copy them into project directory. Alternatively, create a project at the root of directory that already contains all sources. This approach would work well when majority of sources are organized in some root directory (there maybe many subfolders that have sources but there is a single root). The downside of this approach is that all files in a directory and subdirectories are automatically included in project build. User needs to explicitly exclude files that should not be compiled. This may not be the best approach if many projects share the same sources.
Linking Files
- Linking files to a project creates a link reference that refers to a file in the file system. (similar to soft links on unix / linux systems). Files may be linked to a project by selecting “Link files to project” from projects context menu. In this case actual source files exist outside the root folder of the project. This could be used to control which source files are shown in a project and/or refer to source files that should not exist in a project (e.g. when a source directory tree is complex or portion of source code is delivered as standalone package). Normal user follow requires users to specify absolute path to linked file. This is ok if the project is not shared among different users. However, it breaks if project is moved around or if source directories move around on different user’s machines. (e.g. standalone software package is installed in a different directory on another user’s machine) This can be handled by specifying Linked resource path variables. They are kind of environment variables that CCS will use to resolve linked resources. To specify a new linked resource path variable open Window->Preferences. In top left corner in “type filter text” edit box enter “linked resources”, this will filter out all other options. Click on New and select a meaningful name for path variable and specify the folder where the root of your sources is located.
Automated definition of Linked Path Variables
- CCS v4 provides additional support to help with automatic definition of linked resource path variables. User creating a project may additionally create a macros.ini file that defines linked resource path variables. During project import specified variables will be automatically added to workspace settings. End user importing a project does not need to perform additional steps to build the project. Linked resource path variables defined in macros.ini file accept relative paths. This may be used to have references to common source code that exists outside projects directory structure. macros.ini needs to be placed at the root of project directory. macros.ini file has following syntax:
- PROJECT1_PATH_VARIABLE=../../MyCommonLib
- PROJECT1_PATH_VARIABLE2=C:/ThirdPartyLibLocation/
- It is recommended that linked resource path variables be a combination of project name and user defined name to minimize chances of two different projects using the same linked resources path variable. Linked resource path variables are global to workspace thus it is possible to have two different projects use the same path variable. This may be undesirable where projects are independent and have different sources.
Adding a single linked file
- Last step is to add linked resources using newly defined path variable. If adding a single or two files, then easiest is to use GUI menus. Click on File->New->File, highlight the desired project, click on Advanced, then check “Link to file in the file system” click on “Variables…” and select path variable that you added in previous step and click on “Extend…” navigate to your source file and click ok and then finish.
Adding many linked Files
- If you have many files to add an easier way is to right click on the project select “Link files to project”, navigate to where sources are, in the dialog perform multi-select and click Open. This will add all selected files using absolute path to resolve linked files. To make this project portable we now need to replace in project file the absolute portion of the path with path variable that was defined previously. Linked files that are part of the project are listed in .project file, which exists in the root directory of the project. Project View in CCS filters these files out by default. This filter can be turned off by clicking on a triangle button pointing down in project views menu bar, click on Filters… and disable “.*” filter. You can now double click on .project file to open it in CCS editor. Alternatively, you can use your favourite text editor by navigating to the file using windows explorer. Replace absolute portion of path for all linked sources with path variable. Save .project file, close and re-open the project (options are available on context menu). Verify that file location has linked resource as its location. (right click on any linked file and select properties; type: should be set to Linked file and Location: should contain path variable).
- User’s that use these type of projects would need to define path variables in Preferences to properly resolve files. Files that can not be resolved have a warning icon overlaid on top of file icon.
Specifying compiler/linker options
Last step to make project portable is to use macros to specify paths for including header files or libraries. Every project automatically defines a number of different macros that can be used in build options. To see a list of existing macros right click on project and select properties, navigate to C/C++ Build node, Macros tab contains all automatically defined macros. There are build configuration i.e. Debug/Release and Project generic macros. Using project specific macros is a bit easier as they will be automatically re-adjusted for different users, when project is imported into CCS. User may also define their own macros similarly to how linked resource path variables are defined. These macros need to be defined in global preferences (Window->Preferences->C/++-> Managed Build category). Any user defined macros will need to be defined by different users once a project is imported. (similar to how linked resource path variables would need to be defined by each user).
Leave a CommentComments
Comments on Portable Projects


Is there a way I can use only one variable to specify the linked resource and the compiler linker options.
The path variable only takes an absolute path, I tried specifying the include path in terms of his absolute path variable but it gave me errors of not being able to resolved it
--Pensive.mb 18:16, 13 April 2009 (UTC)