B2 Workflow

This action runs a complete B2 workflow from Boost source files.

If you are developing a Boost library, this is usually the next step in your workflow after setting up a C++ compiler and fetching dependencies with Install Packages.

It takes the Boost source directory and runs the usual steps to test the specified modules. This includes compiling b2 if needed and generating a proper user-config.jam file.

This action is particularly useful for Boost library proposals, where B2 is mandatory. It assumes the library being tested is in the libs directory of the Boost super-project and that source-dir is the root of the super-project.

Next steps

If your library also supports CMake, the next step in your workflow should usually be CMake Workflow. Otherwise, the next step in your workflow should usually be the generation of reports, with tools such as the Create Flamegraph (when matrix.time-trace) and Create Changelog (usually in another workflow job). You can also include customs steps to upload coverage reports (when matrix.coverage).

If your b2 workflow provides CMake installation and configuration scripts, it is also usual to include multiple CMake workflow steps as integration tests for CMake.

Example

steps:
- name: B2 Workflow
  uses: alandefreitas/cpp-actions/b2-workflow@v1.7.0
  with:
    source-dir: ${{ steps.boost-clone.outputs.boost-dir }}
    modules: variant2
    toolset: ${{ matrix.b2-toolset }}
    build-variant: ${{ matrix.build-type }}
    cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx || '' }}
    cxxstd: ${{ matrix.cxxstd }}
    address-model: ${{ (matrix.x86 && '32') || '64' }}
    asan: ${{ matrix.asan }}
    ubsan: ${{ matrix.ubsan }}
    tsan: ${{ matrix.tsan }}
    shared: ${{ matrix.shared }}

Input Parameters

Parameter

Description

Default

source-dir

The boost source directory.

This path will be used to build and install B2 for the workflow and test the specified modules.

.

build-dir

Changes the build directories for all project roots being built.

When this option is specified, all Jamroot files must declare a project name.

The build directory for the project root will be computed by concatenating the value of the --build-dir option, the project name specified in Jamroot, and the build dir specified in Jamroot (or bin, if none is specified).

The option is primarily useful when building from read-only media, when you can’t modify Jamroot.

cxx

Path to C++ compiler.

If the input is not specified, the action will use the compiler defined by the environment variable CXX.

If the environment variable is not specified, the action will use the default compiler as identified by B2.

cxxflags

Flags to be used with the C++ compiler. If the input is not specified, the action will use the flags defined by the environment variable CXXFLAGS. If the environment variable is not specified, the action will use the default flags as identified by B2.

ccflags

Flags to be used with the C compiler.

If the input is not specified, the action will use the flags defined by the environment variable CFLAGS.

If the environment variable is not specified, the action will use the default flags as identified by B2.

cxxstd

Comma-separated list of standards with which B2 will build and test the program.

If the input is not specified, the action will use the standards defined by the environment variable CXXSTD.

If the environment variable is not specified, the action will use the default standards as identified by B2.

B2 will iteratively build and test the specified modules with multiple standards.

shared

Determines if the link option should be shared so that it creates shared libraries.

If the input is not specified, the action will use the value defined by the environment variable BUILD_SHARED_LIBS.

If the environment variable is not specified, the action will use the default value as identified by B2.

toolset

B2 toolset name. The toolset is somewhat equivalent to a CMake generator.

If not specified, the action will use the toolset defined by the environment variable B2_TOOLSET.

If the environment variable is not specified, the action will use the default toolset detected by B2.

build-variant

Custom build variants. If the provided variant is a CMake build-type, the argument is mapped to the equivalent B2 variant:

- Releaserelease

- Debugdebug

- RelWithDebInforelease with debug-symbols=on

- <other> → lowercase <other>

If the input is not specified, the action will use the value defined by the environment variable B2_BUILD_VARIANT.

If the environment variable is not specified, the action will use the value from build-type.

build-type

An alternative to build-variant, for compatibility with CMake workflows. When build-variant is not provided, this input is used to set the build variant.

If the input is not specified, the action will use the value defined by the environment variable B2_BUILD_TYPE.

If the environment variable is not specified, the action will use the default value as identified by B2.

modules

The list of modules we should test with B2 in the libs directory of the Boost super-project.

The directory libs/<module>/test will be provided for each module in the list. ⚠️ This parameter is required.

address-model

Valid B2 list of address models.

asan

Enable address-sanitizer.

ubsan

Enable undefined-sanitizer.

tsan

Enable thread-sanitizer.

coverage

Enable coverage.

linkflags

Extra linker flags.

threading

B2 threading option.

rtti

Enables or disables run-time type information.

clean

Cleans all targets in the current directory and in any sub-projects.

Note that unlike the clean target in make, you can use --clean together with target names to clean specific targets.

false

clean-all

Cleans all targets, no matter where they are defined.

In particular, it will clean targets in parent Jamfiles, and targets defined under other project roots.

false

abbreviate-paths

Compresses target paths by abbreviating each component.

This option is useful to keep paths from becoming longer than the filesystem supports.

See also the B2 documentation section “Target Paths”.

true

hash

Compresses target paths using an MD5 hash.

This option is useful to keep paths from becoming longer than the filesystem supports.

This option produces shorter paths than --abbreviate-paths does, but at the cost of making them less understandable.

See also the B2 documentation section “Target Paths”.

false

rebuild-all

Equivalent to the -a option.

Causes all files to be rebuilt.

false

dry-run

Equivalent to the -n option.

Do not execute the commands, only print them.

false

stop-on-error

Equivalent to the -q option.

Stop at the first error, as opposed to continuing to build targets that don’t depend on the failed ones.

false

config

Equivalent to the --config=filename option.

Override all configuration files.

site-config

Equivalent to the --site-config=filename option.

Override the default site-config.jam.

user-config

Equivalent to the --user-config=filename option.

Override the default user-config.jam.

When this option is specified, the action will not generate a user-config.jam file with the cxx toolset path.

project-config

Equivalent to the --project-config=filename option.

Override the default project-config.jam.

debug-configuration

Equivalent to the --debug-configuration option.

Produces debug information about the loading of B2 and toolset files.

If not specified, the value is inherited from trace-commands.

debug-building

Equivalent to the --debug-building option.

Prints what targets are being built and with what properties.

If not specified, the value is inherited from trace-commands.

debug-generators

Equivalent to the --debug-generators option.

Produces debug output from the generator search process. Useful for debugging custom generators.

If not specified, the value is inherited from trace-commands.

include

Additional include paths for C and C++ compilers.

define

Additional macro definitions for C and C++ compilers. The string should be either SYMBOL or SYMBOL=VALUE.

runtime-link

Equivalent to the --runtime-link=<shared,static> option.

Determines if shared or static version of C and C++ runtimes should be used.

jobs

Number of jobs to use in parallel builds.

If the input is not specified, the action will use the value defined by the environment variable B2_JOBS.

If the environment variable is also not specified, the action will use the number of processors available in the system.

trace-commands

Trace commands executed by the workflow.

false