Skip to content

Commit 9c78bfe

Browse files
committed
Reusable CI: Allow specifying targets, defines, link and variant for B2 builds
1 parent f662fe5 commit 9c78bfe

1 file changed

Lines changed: 47 additions & 21 deletions

File tree

.github/workflows/reusable.yml

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ on:
9595
required: false
9696
type: string
9797
default: ''
98+
b2_targets:
99+
description: "B2 targets to build, e.g. 'libs/foo/test//bar'. Defaults to auto-detecting the tests"
100+
required: false
101+
type: string
102+
default: ''
103+
b2_defines:
104+
description: "Preprocessor defines to add"
105+
required: false
106+
type: string
107+
default: ''
108+
b2_link:
109+
description: "Build shared and/or static"
110+
required: false
111+
type: string
112+
default: 'shared,static'
113+
b2_variant:
114+
description: "Variants/Optimization level(s) to build"
115+
required: false
116+
type: string
117+
default: 'debug,release'
118+
library_folder:
119+
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."
120+
required: false
121+
type: string
122+
default: ''
98123
secrets:
99124
CODECOV_TOKEN:
100125
description: "The token for covecov.io; if defined then coverage will be collected."
@@ -113,8 +138,6 @@ concurrency:
113138
env:
114139
GIT_FETCH_JOBS: 8
115140
NET_RETRY_COUNT: 5
116-
B2_VARIANT: debug,release
117-
B2_LINK: shared,static
118141
LCOV_BRANCH_COVERAGE: ${{ inputs.branch_coverage && '1' || '0' }}
119142
CODECOV_NAME: Github Actions
120143

@@ -426,22 +449,19 @@ jobs:
426449
- name: Setup Boost
427450
run: source ci/github/install.sh
428451
env:
452+
ENABLE_REFLECTION: ${{ matrix.reflection }}
453+
XCODE_APP: ${{matrix.xcode_app}}
429454
B2_ADDRESS_MODEL: ${{matrix.address-model}}
430455
B2_COMPILER: ${{matrix.compiler}}
431456
B2_CXXFLAGS: ${{matrix.cxxflags}}
432457
B2_CXXSTD: ${{matrix.cxxstd}}
433-
ENABLE_REFLECTION: ${{ matrix.reflection }}
434458
B2_SANITIZE: ${{matrix.sanitize}}
435459
B2_STDLIB: ${{matrix.stdlib}}
436-
# Optional. Variables set here (to non-empty) will override the top-level environment variables
437-
B2_DEFINES: ${{matrix.defines}}
438-
B2_VARIANT: ${{matrix.variant}}
439-
B2_LINK: ${{matrix.link}}
440-
XCODE_APP: ${{matrix.xcode_app}}
441-
# More entries can be added in the same way, see the B2_ARGS assignment in ci/enforce.sh for the possible keys.
442-
# Set the (B2) target(s) to build, defaults to the test folder of the current library
443-
# 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`
444-
# B2_TARGETS: libs/foo/test//bar
460+
B2_DEFINES: ${{inputs.b2_defines}}
461+
B2_LINK: ${{inputs.b2_link}}
462+
B2_VARIANT: ${{inputs.b2_variant}}
463+
SELF: ${{inputs.library_folder}}
464+
445465

446466
- name: Setup coverage collection
447467
if: matrix.coverage
@@ -450,6 +470,8 @@ jobs:
450470
- name: Run tests
451471
if: '!matrix.coverity'
452472
run: ci/build.sh
473+
env:
474+
B2_TARGETS: ${{inputs.b2_targets}}
453475
# inherits environment from install.sh step
454476

455477
- name: Show config.log
@@ -587,6 +609,7 @@ jobs:
587609
run: ci\github\install.bat
588610
env:
589611
B2_TOOLSET: ${{matrix.toolset}}
612+
SELF: ${{inputs.library_folder}}
590613

591614
- name: Run tests
592615
if: '!matrix.coverage'
@@ -596,21 +619,24 @@ jobs:
596619
B2_TARGET_OS: ${{matrix.target-os}}
597620
B2_CXXSTD: ${{matrix.cxxstd}}
598621
B2_ADDRESS_MODEL: ${{matrix.address-model}}
599-
B2_DEFINES: ${{matrix.defines}}
600-
B2_VARIANT: ${{matrix.variant}}
601-
B2_LINK: ${{matrix.link}}
622+
B2_DEFINES: ${{inputs.b2_defines}}
623+
B2_LINK: ${{inputs.b2_link}}
624+
B2_VARIANT: ${{inputs.b2_variant}}
625+
SELF: ${{inputs.library_folder}}
602626

603627
- name: Collect coverage
604628
shell: powershell
605629
if: matrix.coverage
606630
run: ci\opencppcoverage.ps1
607631
env:
608632
B2_TOOLSET: ${{matrix.toolset}}
633+
B2_TARGET_OS: ${{matrix.target-os}}
609634
B2_CXXSTD: ${{matrix.cxxstd}}
610635
B2_ADDRESS_MODEL: ${{matrix.address-model}}
611-
B2_DEFINES: ${{matrix.defines}}
612-
B2_VARIANT: ${{matrix.variant}}
613-
B2_LINK: ${{matrix.link}}
636+
B2_DEFINES: ${{inputs.b2_defines}}
637+
B2_LINK: ${{inputs.b2_link}}
638+
B2_VARIANT: ${{inputs.b2_variant}}
639+
SELF: ${{inputs.library_folder}}
614640

615641
- name: Upload coverage
616642
if: matrix.coverage
@@ -719,9 +745,9 @@ jobs:
719745
B2_CXXSTD: ${{matrix.cxxstd}}
720746
B2_SANITIZE: ${{matrix.sanitize}}
721747
B2_STDLIB: ${{matrix.stdlib}}
722-
B2_DEFINES: ${{matrix.defines}}
723-
B2_VARIANT: ${{matrix.variant}}
724-
B2_LINK: ${{matrix.link}}
748+
B2_DEFINES: ${{inputs.defines}}
749+
B2_LINK: ${{inputs.link}}
750+
B2_VARIANT: ${{inputs.variant}}
725751

726752
- name: Run tests
727753
run: ci/build.sh

0 commit comments

Comments
 (0)