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_directory]
copy

SYNOPSIS

gprbuild [options] [-P]{project_file[=main}]

PARAMETERS

-P [=

]
    Specify project file and optional main source

-aP
    Ignore project file path for source lookup

-C
    Create missing object, library, and exec directories

-c
    Compile only, no bind or link

--compile-only
    Synonym for -c

-u
    Rebuild only modified files (default incremental)

-j
    Number of parallel compile processes

-v
    Verbose output

-vP[0-3]
    Project verbosity levels (0=quiet, 3=full)

--root-dir=
    Root directory for all generated files

--subdirs=
    Place objects/libs/execs in specified subdir

--link-only
    Link only, assume objects up-to-date

--bind-only
    Bind only (Ada), assume objects compiled

-d
    Dump dependencies to files

-D
    Rebuild files newer than specified date

-gnatx
    Pass switches to GNAT compiler (e.g., -gnata)

-Xname=value
    Set external project attribute

-eL
    List library files for project

-eS
    List sources for project

-h|--help
    Display help and exit

--version
    Display version info

--create-default
    Create default project file

-cargs
    Additional compiler args

-bargs
    Additional binder args

-largs
    Additional linker args

DESCRIPTION

gprbuild is a flexible, high-performance build tool from the GNAT (GNU Ada) ecosystem, designed for constructing complex, multi-language software projects using declarative GNAT Project Files (.gpr). Primarily for Ada, it supports C, C++, Fortran, Rust, and more via configurable toolchains. It automates dependency resolution, compilation, Ada binding, and linking, with smart incremental rebuilds to skip unchanged files.

Projects define sources, libraries, executables, directories, and attributes in .gpr files, enabling hierarchical multi-projects, cross-compilation, and custom builders. Features include parallel jobs (-j), verbose logging, object directory management, and integration with tools like Alire (Ada package manager). It excels in large-scale, safety-critical systems, outperforming traditional make in scalability and maintainability.

gprbuild replaced gnatmake, adding better multi-language support and project extensibility. Invoke with a project file for full builds or options for partial steps like compile-only.

CAVEATS

Requires valid .gpr project files; errors if paths/sources invalid. Parallel builds (-j) may increase memory use. Not for Makefile-based projects without conversion.

PROJECT FILES

Define via .gpr with attributes like for Source_Dirs, for Object_Dir, for Main. Hierarchical via extend. See projectmanager reference.

MULTI-LANGUAGE

Configure via Languages package: e.g., C=>(Compiler="gcc"). Uses gprconfig for tool discovery.

EXAMPLES

gprbuild -P myproj.gpr
gprbuild -P myproj -j8 -vP1
gprbuild --root-dir=build -P app.gpr=src/main.adb

HISTORY

Developed by AdaCore starting 2006 as gnatmake successor in GNAT Pro 6.0. Open-sourced in GPL; matured with GPS IDE integration. Default Ada builder since GNAT 7+; supports Alire since 2020.

SEE ALSO

gnatmake(1), gnat(1), gprconfig(1), make(1), cmake(1)

Copied to clipboard