### 7.4 Extending Projects

#### 7.4.1 Description of extending projects

The project files were designed to support big projects, with several hundreds or thousands of source files. In such contexts, one developer will generally work on a subset of the sources. It is also not rare for such a project to take several hours to fully compile. Most developers therefore do not need to have the full copy of the project compiled on their own machine or personal disk space.

However, it is still useful to be able to access other source files of the application, for instance to find out whether a subprogram can be changed and where it is currently called.

Such a setup can be achieved through extending projects. These are special types of projects that inherit most of their attributes and source files from another project, and can have, in their source directories, some source files that hide/replace those inherited from the original project.

When compiling such projects, the compiler will put the newly created project files in the extending project's directory, and will leave the original untouched. As a result, the original project can be shared read-only among several developers (for instance, it is usual for this original project to be the result of a nightly build of the application).

#### 7.4.2 Creating extending projects

This project wizard allows you to easily create extending projects. You should select an empty directory (which will be created automatically if needed), as well as a list of source files you want to work on initially. New files can also be added later.

As a result, GPS will copy the selected source files to the new directory (if you so decided), and create a number of project files there. It will then load a new project, which has the same properties as the previous one, except that some files are found transparently in the new directory, and object files resulting from the compilation are create into that directory as opposed to the object directory of the original project.

#### 7.4.3 Adding files to extending projects

Once you have loaded an extending project in GPS, things work mostly transparently. If you open a file through the `File->Open From Project` dialog, the files found in the local directory of your extending project will be picked up first.

The build actions will create object files in the extending project's directory, leaving the original project untouched.

It might happen that you want to start working on a source file that you had not added in the extending project when it was created. You can of course edit the file found in the original project, provided you have write access to it. However, it is generally better to edit it in the context of the extending project, so that the original project can be shared among developers.

This can be done by clicking on the file in the `Project View`, then selecting the menu `Add To Extending Project`. This will popup a dialog asking whether you want GPS to copy the file to the extending project's directory for you. GPS might also create some new project files in that directory if necessary, and automatically reload the project as needed. From then on, if you use the menu `File->Open From Project`, GPS will first see the file from the extending project.

Note that open editors will still be editing the same file they were before, so you should open the new file if needed.