Next: , Up: Compilation/Build


9.1 The Build Menu

The build menu gives access to capabilities related to checking, parsing and compiling files, as well as creating and running executables. note that this menu is fully configurable via the Targets dialog, so what is documented in this manual are the default menus.

See The Target Configuration Dialog.

Check Syntax
Check the syntax of the current source file. Display an error message in the Messages window if no file is currently selected.
Check Semantic
Check the semantic of the current source file. Display an error message in the Messages window if no file is currently selected.
Compile File
Compile the current file. By default, will display an intermediate dialog where you can add extra switches, or simply press <Enter> to get the standard (or previous) switches. Display an error message in the Messages window if no file is selected.

If errors or warnings occur during the compilation, the corresponding locations will appear in the Locations View. If the corresponding Preference is set, the source lines will be highlighted in the editors (see The Preferences Dialog). To remove the highlighting on these lines, remove the files from the Locations View using either the contextual menu (Remove category) or by closing the Locations View.

Project
Build <main>
The menu will list of all mains defined in your project hierarchy. Each menu item will build the selected main.
Build All
Build and link all main units defined in your project. If no main unit is specified in your project, build all files defined in your project and subprojects recursively. For a library project file, compile sources and recreate the library when needed.
Compile All Sources
Compile all source files defined in the top level project.
Build <current file>
Consider the currently selected file as a main file, and build it.
Custom Build...
Display a text entry where you can enter any external command. This menu is very useful when you already have existing build scripts, make files, ... and want to invoke them from GPS. If the SHELL environment variable is defined (to e.g. /bin/sh), then the syntax used to execute the command is the one for this shell. Otherwise, the command will be spawned directly by GPS without any shell interpretation.

Clean
Clean All
Remove all object files and other compilation artifacts associated to all projects related to the current one. It allows to restart a complete build from scratch.
Clean Root
Remove all object files and other compilation artifacts associated to the root project. It does not clean objects from other related projects.

Makefile
If you have the make utility in your PATH, and have a file called Makefile in the same directory as your project file is, or if you've set the makefile property in the Make section of the project properties (see The Project Properties Editor), this menu will be displayed, giving access to all the targets defined in your makefile.
Ant
If you have the ant utility in your PATH, and have a file called build.xml in the same directory as your project file is, or if you've set the antfile property in the Ant section of the project properties (see The Project Properties Editor), this menu will be displayed, giving access to all the targets defined in your ant file.
Run
main
For each main source file defined in your top level project, an entry is listed to run the executable associated with this main file. Running an application will first open a dialog where you can specify command line arguments to your application, if needed. You can also specify whether the application should be run within GPS (the default), or using an external terminal.

When running an application from GPS, a new execution window is added in the bottom area where input and output of the application is handled. This window is never closed automatically, even when the application terminates, so that you can still have access to the application's output. If you explicitly close an execution window while an application is still running, a dialog window will be displayed to confirm whether the application should be terminated.

When using an external terminal, GPS launches an external terminal utility that will take care of the execution and input/output of your application. This external utility can be configured in the preferences dialog (External Commands->Execute command).

The GPS execution windows have several limitations compared to external terminals. In particular, they do not handle signals like <ctrl-z> and <control-c>. In general, if you are running an interactive application, we strongly encourage you to run in an external terminal.

Similarly, the Run contextual menu accessible from a project entity contains the same entries.

Custom...
Similar to the entry above, except that you can run any arbitrary executable. If the SHELL environment variable is defined (to e.g. /bin/sh), then the syntax used to execute the command is the one for this shell. Otherwise, the command will be spawned directly by GPS without any shell interpretation.

Recompute Xref info
Recompute the cross-reference information for Ada, C and C++ source files. See Support for Cross-References.
Load xref info in memory
Load all the cross-reference information in memory. This menu is generally not needed, See Support for Cross-References.
Settings
Targets
This opens the Target Configuration Dialog. See The Target Configuration Dialog.
Toolchains
Open a dialog allowing the configuration of GPS for working with two compilation toolchains. This is particulary useful when compiling a project with an old compiler, while wanting up-to-date functionalities from the associated tools (gnatmetric, gnatcheck and so on). See Working with two compilers.

The Tools->Interrupt menu can be used to interrupt the last compilation or run command. Once you have interrupted that last operation, you can interrupt the previous one by selecting the same menu again.

However, the easiest way to interrupt a specific operation, no matter if it was started last or not, is to use the Task Manager, through the Tools->Views->Tasks menu. It will show one line per running process, and right-clicking on any of these lines gives the possibility to interrupt that process.

If your application is build through a Makefile, you should probably load the Makefile.py startup script (see the menu /Tools/Plug-ins).