Skip to content

Buildsystem backends

Linus Seelinger edited this page Mar 10, 2015 · 2 revisions

Builders are located at src/Units/Builder.

When creating a new builder, it should be helpful to look at existing ones.

Input

A builder receives a ProjectMemberTarget which specifies the source files and dependencies to be included.

Some functions also receive the current MainWidget.

Settings

A builder can hold additional information, which can be saved to XML by implementing load and save accordingly.

Those can also be exposed to the user by implementing init_ui. Return null if you do not provide a UI, return the corresponding widget if you do.

Make use of this only if absolutely necessary! Usually, the ProjectMemberTarget should contain all information you need.

Building

The building process happens in build. Your build directory is

build/$(target.binary_name)/BUILDSYSTEM/

where BUILDSYSTEM is the name of your backend. You have to make sure this directory exists.

The build process must include

  • building all selected sources
  • setting defines and dependencies according to the system's status
  • copying all referenced data files to subdirectories of the build directory according to the data members, set build directory macros accordingly (-X -DDATADIRNAME DATADIR for valac)
  • compiling and including all referenced gresources

In contrast to exporting, avoid duplicating files for building (e.g. use the original source files).

Helper

You can use the Helper class to take over some common work:

  • write_gresource_xml writes a gresource file based on a ProjectMemberGResource
  • write_config_vapi writes a vapi file containing definitions for data directories
  • copy_recursive recursively copies files and directories

Exporting

Exporting (export) should result in a buildable and installable, self-contained copy of the project at

export/$(target.binary_name)/BUILDSYSTEM/.

You probably can share a lot of code with build.

Dependencies and defines must be represented completely (i.e. include all conditions!) in order to allow building on any machine.

You have to specify whether you provide export functionality as the return value of can_export.

Running

The binary resulting from the build should be executed in run and killed in abort_run.

States

Whenever you start or finish the building process or run a binary etc. you should change the variable state accordingly. A signal will be emitted automatically to notify other components of this change.

Clone this wiki locally