junction - Integrate subprojects

This element is a link to another BuildStream project. It allows integration of multiple projects into a single pipeline.

Overview

kind: junction

# Specify the BuildStream project source
sources:
- kind: git
  url: upstream:projectname.git
  track: master
  ref: d0b38561afb8122a3fc6bafc5a733ec502fcaed6

# Specify the junction configuration
config:

  # Override project options
  options:
    machine_arch: "%{machine_arch}"
    debug: True

  # Optionally look in a subpath of the source repository for the project
  path: projects/hello

Note

Junction elements may not specify any dependencies as they are simply links to other projects and are not in the dependency graph on their own.

With a junction element in place, local elements can depend on elements in the other BuildStream project using the additional junction attribute in the dependency dictionary:

depends:
- junction: toolchain.bst
  filename: gcc.bst
  type: build

While junctions are elements, only a limited set of element operations is supported. They can be tracked and fetched like other elements. However, junction elements do not produce any artifacts, which means that they cannot be built or staged. It also means that another element cannot depend on a junction element itself.

Note

BuildStream does not implicitly track junction elements. This means that if we were to invoke: bst build –track-all ELEMENT on an element which uses a junction element, the ref of the junction element will not automatically be updated if a more recent version exists.

Therefore, if you require the most up-to-date version of a subproject, you must explicitly track the junction element by invoking: bst source track JUNCTION_ELEMENT.

Furthermore, elements within the subproject are also not tracked by default. For this, we must specify the –track-cross-junctions option. This option must be preceeded by –track ELEMENT or –track-all.

Sources

bst show does not implicitly fetch junction sources if they haven’t been cached yet. However, they can be fetched explicitly:

bst source fetch junction.bst

Other commands such as bst build implicitly fetch junction sources.

Options

options:
  machine_arch: "%{machine_arch}"
  debug: True

Junctions can configure options of the linked project. Options are never implicitly inherited across junctions, however, variables can be used to explicitly assign the same value to a subproject option.

Nested Junctions

Junctions can be nested. That is, subprojects are allowed to have junctions on their own. Nested junctions in different subprojects may point to the same project, however, in most use cases the same project should be loaded only once. BuildStream uses the junction element name as key to determine which junctions to merge. It is recommended that the name of a junction is set to the same as the name of the linked project.

As the junctions may differ in source version and options, BuildStream cannot simply use one junction and ignore the others. Due to this, BuildStream requires the user to resolve possibly conflicting nested junctions by creating a junction with the same name in the top-level project, which then takes precedence.