Implementing a Build System

Builder has support for many build systems such as autotools, meson, cmake, etc. The build system knows how to find build targets (binaries or scripts that are installed) for the runner, knows how to find build flags used by the clang service, and it can define where the build directory is. It also has an associated Ide.BuildPipelineAddin (see the next section) that specifies how to do operations like build, rebuild, clean, etc.

An outline for a Buildsystem
import gi

from gi.repository import Gio, Ide

class BasicBuildSystem(Ide.Object, Ide.BuildSystem, Gio.AsyncInitable):

    def do_init_async(self, priority, cancel, callback, data=None):
        task =, cancel, callback)
        # do something, like check if a build file exists

    def do_init_finish(self, result):
        return result.propagate_boolean()

    def do_get_priority(self):
        return 0 # Choose a priority based on other build systems' priority

    def do_get_build_flags_async(self, ifile, cancellable, callback, data=None):
        task =, cancellable, callback)
        task.ifile = ifile
        task.build_flags = []
        # get the build flags

    def do_get_build_flags_finish(self, result):
        if result.propagate_boolean():
            return result.build_flags

    def do_get_build_targets_async(self, cancellable, callback, data=None):
        task =, cancellable, callback)
        task.build_targets = []
        # get the build targets

    def do_get_build_targets_finish(self, result):
        if result.propagate_boolean():
            return result.build_targets

How does Builder know which build system to use for a project? Each has an associated “project file” ( for autotools) that has to exist in the source directory for the build system to be used. If a project has multiple project files, the priorities of each are used to decide which to use. You can see where the priority is defined in the code above. The project file is defined in the .plugin file with these lines (in the case of the make plugin):

A snippet from a .plugin file
X-Project-File-Filter-Name=Makefile Project

When a project has the right file, the build system will be initialized by IdeContext during its own initialization process.