4.1. Importing Existing GNAT ProjectsΒΆ

Importing existing GNAT projects (i.e., those defined by a GNAT project file), is accomplished using a wizard provided by GNATbench. Two steps are required.

  • Create a new Wind River Workbench project to contain the imported GNAT project
  • Import the existing GNAT project into the new Wind River Workbench project

Strictly speaking you do not need to create a new Wind River project each time you import an existing GNAT project. You can use an existing Wind River project that is not already extended for GNATbench. The point is that the Wind River project that will contain the imported GNAT project must already exist before importing begins.

In any case, the name of the existing Wind River project must match that of the GNAT project to be imported. For example, if you import a GNAT project file named “ms1553_demo.gpr”, the Wind River Workbench project must be named “ms1553_demo”. Otherwise the project build command will not invoke the Ada builder. That being the case, creating a new Wind River project is the most likely approach.

Once the Wind River project is ready, invoke the import wizard using either the “File” menu and selecting “Import...”, or use the contextual menu in the Project Navigator and again selecting “Import...” The first approach is illustrated below.

file import menu

A new wizard page will appear (shown below), allowing you to choose which import wizard to apply. Workbench defines a number of import wizards so you may need to expand the “Ada” category. Select “Existing GNAT Project” and press Next.

import wizard selection page

On next wizard page you will make a number of configuration choices that involve changing the default options. It is vital that you make the proper choices when using this general import wizard in the context of Workbench. The wizard page and default options are as shown in the following figure.

import gnat project selection page

First, in the “Location of the root project” text entry pane, specify the location of the GNAT project file (the “gpr file”) defining the project you intend to import. You may enter the path manually or you can browse to it via the button to the right of the text entry pane.

Next, you are presented with the choice of whether to import the GNAT project into an existing Workbench project or into a new Workbench project. As indicated earlier, be sure to use the option to import into an *existing* Workbench project. Do not use the default selection for importing into a new Workbench project. Otherwise the wizard would create a new project that is not a Wind River Workbench project. Also, as indicated earlier, this existing Wind River Workbench project must have the same project name as the GNAT project being imported.

Finally, when importing the GNAT project, the wizard will attempt to import all the resources it references, such as source folders and files, and binary folders. This same page allows you to choose whether the wizard should copy these external resources into the workspace version of the project, or whether the workspace version should only contain “links” to the resources. Be sure to select the option to *copy* the resources into the workspace. Do not use the default selection for linking the resources into the workspace. This choice is necessary as long as “Standard” managed builds are used by GNATbench. The figure above shows the default selection of using links, which is typically the right option for an existing external project but should not be used with “Standard” managed builds.

The following figure illustrates the appropriate choices for a GNAT project named “sdc” to be imported into an existing Workbench project of the same name:

import\_gnat\_proj\_selection\_page\_actuals

Press Finish after making all these choices. The existing GNAT project will be imported into the existing Wind River Workbench project and all the Ada operations will be enabled.

Note that you may have to modify the GNAT project file imported by the wizard. For example, you might need to re-specify the location of the executable (a directory) if the original GNAT project file specified it with an absolute path. Similarly, the GNAT project file might specify multiple main programs or other properties that should be changed. Note that a main program is typically required for building GPP Ada projects under Workbench.

After importing the GNAT project into the existing Workbench project, it will appear in the Project Explorer as a regular GNATbench project:

imported\_gnat\_project