Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 59 additions & 28 deletions .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,31 @@ on:
required: false
type: string
default: ''
b2_targets:
description: "B2 targets to build, e.g. 'libs/foo/test//bar'. Defaults to auto-detecting the tests"
required: false
type: string
default: ''
b2_defines:
description: "Preprocessor defines to add"
required: false
type: string
default: ''
b2_link:
description: "Build shared and/or static"
required: false
type: string
default: 'shared,static'
b2_variant:
description: "Variants/Optimization level(s) to build"
required: false
type: string
default: 'debug,release'
library_folder:
description: "Name of the subfolder of the Boost tree the library should be. Will be determined by the value of 'key' in meta/libraries.json."
required: false
type: string
default: ''
secrets:
CODECOV_TOKEN:
description: "The token for covecov.io; if defined then coverage will be collected."
Expand All @@ -113,8 +138,6 @@ concurrency:
env:
GIT_FETCH_JOBS: 8
NET_RETRY_COUNT: 5
B2_VARIANT: debug,release
B2_LINK: shared,static
LCOV_BRANCH_COVERAGE: ${{ inputs.branch_coverage && '1' || '0' }}
CODECOV_NAME: Github Actions

Expand Down Expand Up @@ -426,22 +449,19 @@ jobs:
- name: Setup Boost
run: source ci/github/install.sh
env:
ENABLE_REFLECTION: ${{ matrix.reflection }}
XCODE_APP: ${{matrix.xcode_app}}
B2_ADDRESS_MODEL: ${{matrix.address-model}}
B2_COMPILER: ${{matrix.compiler}}
B2_CXXFLAGS: ${{matrix.cxxflags}}
B2_CXXSTD: ${{matrix.cxxstd}}
ENABLE_REFLECTION: ${{ matrix.reflection }}
B2_SANITIZE: ${{matrix.sanitize}}
B2_STDLIB: ${{matrix.stdlib}}
# Optional. Variables set here (to non-empty) will override the top-level environment variables
B2_DEFINES: ${{matrix.defines}}
B2_VARIANT: ${{matrix.variant}}
B2_LINK: ${{matrix.link}}
XCODE_APP: ${{matrix.xcode_app}}
# More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
# Set the (B2) target(s) to build, defaults to the test folder of the current library
# Can alternatively be done like this in the build step or in the build command of the build step, e.g. `run: B2_TARGETS=libs/$SELF/doc ci/build.sh`
# B2_TARGETS: libs/foo/test//bar
B2_DEFINES: ${{inputs.b2_defines}}
B2_LINK: ${{inputs.b2_link}}
B2_VARIANT: ${{inputs.b2_variant}}
SELF: ${{inputs.library_folder}}


- name: Setup coverage collection
if: matrix.coverage
Expand All @@ -450,6 +470,8 @@ jobs:
- name: Run tests
if: '!matrix.coverity'
run: ci/build.sh
env:
B2_TARGETS: ${{inputs.b2_targets}}
# inherits environment from install.sh step

- name: Show config.log
Expand Down Expand Up @@ -587,30 +609,39 @@ jobs:
run: ci\github\install.bat
env:
B2_TOOLSET: ${{matrix.toolset}}
SELF: ${{inputs.library_folder}}

- name: Run tests
if: '!matrix.coverage'
run: ci\build.bat
- name: Determine B2 arguments
run: |
# Use Bash which is more flexible than CMD and we can reuse the logic
. ci/enforce.sh
echo "B2_FULL_ARGS=${B2_ARGS[@]}" >> "$GITHUB_ENV"
echo "SELF=$SELF" >> "$GITHUB_ENV"
if [[ -z "$B2_TARGETS" ]]; then
B2_TARGETS=libs/$SELF/test
fi
echo "B2_TARGETS=$B2_TARGETS" >> "$GITHUB_ENV"
echo "SELF=$SELF" >> "$GITHUB_ENV"
shell: bash
env:
B2_TOOLSET: ${{matrix.toolset}}
B2_TARGET_OS: ${{matrix.target-os}}
B2_CXXSTD: ${{matrix.cxxstd}}
B2_ADDRESS_MODEL: ${{matrix.address-model}}
B2_DEFINES: ${{matrix.defines}}
B2_VARIANT: ${{matrix.variant}}
B2_LINK: ${{matrix.link}}
B2_DEFINES: ${{inputs.b2_defines}}
B2_LINK: ${{inputs.b2_link}}
B2_VARIANT: ${{inputs.b2_variant}}
B2_TARGETS: ${{inputs.b2_targets}}
SELF: ${{inputs.library_folder}}

- name: Run tests
if: '!matrix.coverage'
run: ci\build.bat

- name: Collect coverage
shell: powershell
if: matrix.coverage
run: ci\opencppcoverage.ps1
env:
B2_TOOLSET: ${{matrix.toolset}}
B2_CXXSTD: ${{matrix.cxxstd}}
B2_ADDRESS_MODEL: ${{matrix.address-model}}
B2_DEFINES: ${{matrix.defines}}
B2_VARIANT: ${{matrix.variant}}
B2_LINK: ${{matrix.link}}

- name: Upload coverage
if: matrix.coverage
Expand Down Expand Up @@ -719,9 +750,9 @@ jobs:
B2_CXXSTD: ${{matrix.cxxstd}}
B2_SANITIZE: ${{matrix.sanitize}}
B2_STDLIB: ${{matrix.stdlib}}
B2_DEFINES: ${{matrix.defines}}
B2_VARIANT: ${{matrix.variant}}
B2_LINK: ${{matrix.link}}
B2_DEFINES: ${{inputs.b2_defines}}
B2_LINK: ${{inputs.b2_link}}
B2_VARIANT: ${{inputs.b2_variant}}

- name: Run tests
run: ci/build.sh
Expand Down
14 changes: 10 additions & 4 deletions ci/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ IF "%B2_CI_VERSION%" == "0" (

IF DEFINED ADDPATH (SET "PATH=%ADDPATH%%PATH%")

cd %BOOST_ROOT%

set SELF_S=%SELF:\=/%
IF NOT DEFINED B2_TARGETS (SET B2_TARGETS=libs/!SELF_S!/test)

SET B2_TOOLCXX=toolset=%B2_TOOLSET%

IF DEFINED B2_CXXSTD (SET B2_CXXSTD=cxxstd=%B2_CXXSTD%)
Expand All @@ -26,8 +31,6 @@ IF DEFINED B2_TARGET_OS (SET B2_TARGET_OS=target-os=%B2_TARGET_OS%)
IF DEFINED B2_LINK (SET B2_LINK=link=%B2_LINK%)
IF DEFINED B2_VARIANT (SET B2_VARIANT=variant=%B2_VARIANT%)

set SELF_S=%SELF:\=/%
IF NOT DEFINED B2_TARGETS (SET B2_TARGETS=libs/!SELF_S!/test)
IF NOT DEFINED B2_JOBS (SET B2_JOBS=3)

REM clang-win requires to use the linker for the manifest
Expand All @@ -39,10 +42,13 @@ IF "%B2_TOOLSET%" == "clang-win" (
)
)

cd %BOOST_ROOT%

IF DEFINED SCRIPT (
call libs\%SELF%\%SCRIPT%
) ELSE IF DEFINED B2_FULL_ARGS (
REM Echo the complete build command to the build log
ECHO b2 --abbreviate-paths %B2_TARGETS% %B2_FULL_ARGS%
REM Now go build...
b2 --abbreviate-paths %B2_TARGETS% %B2_FULL_ARGS%
) ELSE (
REM Echo the complete build command to the build log
ECHO b2 --abbreviate-paths %B2_TARGETS% %B2_TOOLCXX% %B2_CXXSTD% %B2_CXXFLAGS% %B2_DEFINES% %B2_INCLUDE% %B2_THREADING% %B2_ADDRESS_MODEL% %B2_TARGET_OS% %B2_LINK% %B2_VARIANT% -j%B2_JOBS% %B2_FLAGS%
Expand Down
30 changes: 19 additions & 11 deletions ci/enforce.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
#
# Copyright 2017 - 2019 James E. King III
# Copyright 2020 - 2025 Alexander Grund
# Copyright 2020 - 2026 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -60,8 +60,13 @@ fi

# default parallel build jobs: number of CPUs available + 1
if [ -z "${B2_JOBS:-}" ]; then
pythonexecutable=$(get_python_executable)
cpus=$(grep -c 'processor' /proc/cpuinfo || $pythonexecutable -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
if ! cpus=$(grep -c 'processor' /proc/cpuinfo); then
if pythonexecutable=$(get_python_executable); then
cpus=$($pythonexecutable -c 'import multiprocessing as mp; print(mp.cpu_count())' || echo "2")
else
cpus=2
fi
fi
export B2_JOBS=$((cpus + 1))
fi

Expand Down Expand Up @@ -97,14 +102,9 @@ if ((${B2_CI_VERSION:-1} > 0)); then

B2_ARGS=(
${B2_TOOLSET:+"toolset=$B2_TOOLSET"}
"cxxstd=$B2_CXXSTD"
${B2_CXXSTD:+"cxxstd=$B2_CXXSTD"}
${B2_CXXFLAGS:+"cxxflags=$B2_CXXFLAGS"}
)
append_b2_args B2_DEFINES define
append_b2_args B2_INCLUDE include
# shellcheck disable=SC2206
B2_ARGS=(
"${B2_ARGS[@]}"
${B2_TARGET_OS:+"target-os=$B2_TARGET_OS"}
${B2_LINKFLAGS:+"linkflags=$B2_LINKFLAGS"}
${B2_TESTFLAGS:-}
${B2_ADDRESS_MODEL:+address-model=$B2_ADDRESS_MODEL}
Expand All @@ -117,8 +117,16 @@ if ((${B2_CI_VERSION:-1} > 0)); then
${B2_TSAN:+thread-sanitizer=norecover}
${B2_UBSAN:+undefined-sanitizer=norecover}
-j"${B2_JOBS}"
${B2_FLAGS:-}
)
append_b2_args B2_DEFINES define
append_b2_args B2_INCLUDE include
# clang-win requires to use the linker for the manifest
if [[ ${B2_TOOLSET:-} == "clang-win" ]]; then
B2_ARGS+=(embed-manifest-via=linker)
fi

# shellcheck disable=SC2206
B2_ARGS+=(${B2_FLAGS:-})
else
# Legacy codepath for compatibility for for old versions of the .github/*.yml files:
# In (most) variables the prefix (such as "cxxflags=" for B2_CXXFLAGS) was included in the value, so it isn't added (again) here
Expand Down
4 changes: 4 additions & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ local B2_ADDRESS_MODEL = [ os.environ B2_ADDRESS_MODEL ] ;
local B2_CXXFLAGS = [ os.environ B2_CXXFLAGS ] ;
local B2_CXXSTD = [ os.environ B2_CXXSTD ] ;
local B2_DEFINES = [ os.environ B2_DEFINES ] ;
local B2_FULL_ARGS = [ os.environ B2_FULL_ARGS ] ;
local B2_INCLUDE = [ os.environ B2_INCLUDE ] ;
local B2_JOBS = [ os.environ B2_JOBS ] ;
local B2_LINK = [ os.environ B2_LINK ] ;
local B2_LINKFLAGS = [ os.environ B2_LINKFLAGS ] ;
local B2_TARGETS = [ os.environ B2_TARGETS ] ;
local B2_TESTFLAGS = [ os.environ B2_TESTFLAGS ] ;
local B2_THREADING = [ os.environ B2_THREADING ] ;
local B2_TOOLSET = [ os.environ B2_TOOLSET ] ;
Expand All @@ -33,10 +35,12 @@ ECHO " B2_ADDRESS_MODEL:" $(B2_ADDRESS_MODEL) ;
ECHO " B2_CXXFLAGS:" $(B2_CXXFLAGS) ;
ECHO " B2_CXXSTD:" $(B2_CXXSTD) ;
ECHO " B2_DEFINES:" $(B2_DEFINES) ;
ECHO " B2_FULL_ARGS:" $(B2_FULL_ARGS) ;
ECHO " B2_INCLUDE:" $(B2_INCLUDE) ;
ECHO " B2_JOBS:" $(B2_JOBS) ;
ECHO " B2_LINK:" $(B2_LINK) ;
ECHO " B2_LINKFLAGS:" $(B2_LINKFLAGS) ;
ECHO " B2_TARGETS:" $(B2_TARGETS) ;
ECHO " B2_TESTFLAGS:" $(B2_TESTFLAGS) ;
ECHO " B2_THREADING:" $(B2_THREADING) ;
ECHO " B2_TOOLSET:" $(B2_TOOLSET) ;
Expand Down
Loading