LinuxCommandLibrary

gprbuild

Build Ada projects using project files

TLDR

Build a project (assuming only one *.gpr file exists in the current directory)

$ gprbuild
copy

Build a specific [P]roject file
$ gprbuild -P [project_name]
copy

Clean up the build workspace
$ gprclean
copy

Install compiled binaries
$ gprinstall --prefix [path/to/installation/dir]
copy

SYNOPSIS

gprbuild [options] project_file

PARAMETERS

-P project_file
    Specifies the main project file to build.

-X name=value
    Sets the value of an external variable used in the project file.

--RTS=rts_name
    Specifies the runtime system to use.

-c switches
    Passes switches directly to the compiler.

-l switches
    Passes switches directly to the linker.

-build-mode=mode
    Specifies the build mode (e.g., debug, release).

-m
    Force recompilation. Equivalent to make clean; gprbuild

--target=target_name
    Set the target platform for the build.

--src-subdirs=dirs
    Specifies additional directories to search for source files.

--create-missing-dirs
    Create missing directories required by the project.

--no-rebuild
    Do not automatically rebuild if the environment changes.

-v
    Verbose mode.

-h
    Display help information.

DESCRIPTION

GPRbuild is a command-line tool used to build Ada and SPARK projects managed by GPRbuild project files. It automates the compilation, linking, and other build processes necessary to create executables and libraries from Ada and SPARK source code.

It utilizes project files (typically with a .gpr extension) to define the project structure, dependencies, compiler flags, and other build settings. This allows developers to manage complex projects with numerous source files and dependencies in a structured and maintainable way. GPRbuild simplifies the build process, reducing errors and improving consistency across different development environments. It supports various build modes including debug, release, and customized profiles defined within the project file. It aims to be compatible with Make and other build systems. The tool effectively manages build order and avoids unnecessary recompilations through dependency analysis.

GPRbuild interacts closely with the Ada compiler (GNAT), utilizing its features and capabilities to produce optimized and robust executables.

CAVEATS

GPRbuild is highly dependent on well-formed project files. Errors in the project file can lead to unexpected build behavior or failures. Careful planning and validation of the project file are recommended. The integration with other build systems, while intended, may sometimes require manual intervention or customization.

ERROR HANDLING

GPRbuild typically returns non-zero exit codes when errors occur during the build process. Error messages are generally informative, pinpointing the source of the problem. Examining the compiler output closely is crucial for diagnosing build failures.

PROJECT FILE STRUCTURE

Project files are written in a declarative language specific to GPRbuild. They define source directories, object directories, executable names, library names, and dependencies on other projects or libraries. Understanding the structure of these files is fundamental to using GPRbuild effectively.

HISTORY

GPRbuild was developed as part of the GNAT toolchain to provide a dedicated build system for Ada and SPARK projects. It evolved to address the specific needs of Ada development, offering features tailored to the language's characteristics and project structures. Its development was driven by the need for a robust and reliable build tool that could handle the complexities of large Ada projects, ensuring consistent builds and efficient dependency management.

SEE ALSO

gnatmake(1), make(1)

Copied to clipboard