Skip to content

Commit 9bb9b40

Browse files
authored
Merge Develop (#34)
* Fix renaming of project with janitor * Correct detected build settings around UBSAN
1 parent 9451f27 commit 9bb9b40

File tree

7 files changed

+69
-41
lines changed

7 files changed

+69
-41
lines changed

.github/actions/setup_cache/action.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inputs:
1111
generator:
1212
required: true
1313
type: string
14-
developer_mode:
14+
packaging_maintainer_mode:
1515
required: true
1616
type: string
1717

@@ -20,16 +20,13 @@ runs:
2020
using: "composite"
2121
steps:
2222
- name: Cache
23-
uses: actions/cache@v2
23+
uses: actions/cache@v3
2424
with:
2525
# You might want to add .ccache to your cache configuration?
2626
path: |
2727
~/.cache/pip
28-
${{ env.HOME }}/.cache/vcpkg/archives
29-
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
30-
${{ env.LOCALAPPDATA }}\vcpkg\archives
31-
${{ env.APPDATA }}\vcpkg\archives
32-
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.developer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}}
28+
~/.ccache
29+
key: ${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}-${{ inputs.generator }}-${{ inputs.packaging_maintainer_mode }}-${{ hashFiles('**/CMakeLists.txt') }}
3330
restore-keys: |
3431
${{ runner.os }}-${{ inputs.compiler }}-${{ inputs.build_type }}
3532

.github/constants.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PROJECT_NAME=myproject

.github/workflows/auto-clang-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77

88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- uses: DoozyX/clang-format-lint-action@v0.13
1111
with:
1212
source: '.'

.github/workflows/ci.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ on:
1212
env:
1313
CLANG_TIDY_VERSION: "15.0.2"
1414
VERBOSE: 1
15-
PROJECT_NAME: myproject
1615

1716

1817
jobs:
@@ -42,7 +41,7 @@ jobs:
4241
build_type:
4342
- Release
4443
- Debug
45-
package_maintainer_mode:
44+
packaging_maintainer_mode:
4645
- ON
4746
- OFF
4847
build_shared:
@@ -69,7 +68,7 @@ jobs:
6968

7069
# Set up preferred package generators, for given build configurations
7170
- build_type: Release
72-
package_maintainer_mode: OFF
71+
packaging_maintainer_mode: OFF
7372
package_generator: TBZ2
7473

7574
# This exists solely to make sure a non-multiconfig build works
@@ -78,42 +77,42 @@ jobs:
7877
generator: "Unix Makefiles"
7978
build_type: Debug
8079
gcov_executable: gcov
81-
package_maintainer_mode: On
80+
packaging_maintainer_mode: On
8281
enable_ipo: Off
8382

8483
# Windows msvc builds
8584
- os: windows-2022
8685
compiler: msvc
8786
generator: "Visual Studio 17 2022"
8887
build_type: Debug
89-
package_maintainer_mode: On
88+
packaging_maintainer_mode: On
9089
enable_ipo: On
9190

9291
- os: windows-2022
9392
compiler: msvc
9493
generator: "Visual Studio 17 2022"
9594
build_type: Release
96-
package_maintainer_mode: On
95+
packaging_maintainer_mode: On
9796
enable_ipo: On
9897

9998
- os: windows-2022
10099
compiler: msvc
101100
generator: "Visual Studio 17 2022"
102101
build_type: Debug
103-
package_maintainer_mode: Off
102+
packaging_maintainer_mode: Off
104103

105104
- os: windows-2022
106105
compiler: msvc
107106
generator: "Visual Studio 17 2022"
108107
build_type: Release
109-
package_maintainer_mode: Off
108+
packaging_maintainer_mode: Off
110109
package_generator: ZIP
111110

112111
- os: windows-2022
113112
compiler: msvc
114113
generator: "Visual Studio 17 2022"
115114
build_type: Release
116-
package_maintainer_mode: On
115+
packaging_maintainer_mode: On
117116
enable_ipo: On
118117
build_shared: On
119118

@@ -126,16 +125,22 @@ jobs:
126125
script: |
127126
core.setFailed('There is a mismatch between configured llvm compiler and clang-tidy version chosen')
128127
129-
- uses: actions/checkout@v2
128+
- uses: actions/checkout@v3
130129

131130
- name: Setup Cache
132131
uses: ./.github/actions/setup_cache
133132
with:
134133
compiler: ${{ matrix.compiler }}
135134
build_type: ${{ matrix.build_type }}
136-
package_maintainer_mode: ${{ matrix.package_maintainer_mode }}
135+
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }}
137136
generator: ${{ matrix.generator }}
138137

138+
- name: Project Name
139+
uses: cardinalby/export-env-action@v2
140+
with:
141+
envFile: '.github/constants.env'
142+
143+
139144
- name: Setup Cpp
140145
uses: aminya/setup-cpp@v1
141146
with:
@@ -156,7 +161,7 @@ jobs:
156161

157162
- name: Configure CMake
158163
run: |
159-
cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.package_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
164+
cmake -S . -B ./build -G "${{matrix.generator}}" -D${{ env.PROJECT_NAME }}_ENABLE_IPO=${{matrix.enable_ipo }} -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=${{matrix.packaging_maintainer_mode}} -D${{ env.PROJECT_NAME }}_ENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' }} -DGIT_SHA:STRING=${{ github.sha }}
160165
161166
- name: Build
162167
# Execute the build. You can specify a specific target with "--target <NAME>"

.github/workflows/codeql-analysis.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ on:
2020
schedule:
2121
- cron: '38 0 * * 5'
2222

23-
env:
24-
PROJECT_NAME: myproject
2523

2624
jobs:
2725
analyze:
@@ -50,7 +48,7 @@ jobs:
5048

5149

5250
steps:
53-
- uses: actions/checkout@v2
51+
- uses: actions/checkout@v3
5452

5553
- name: Setup Cache
5654
uses: ./.github/actions/setup_cache
@@ -60,6 +58,11 @@ jobs:
6058
packaging_maintainer_mode: ${{ matrix.packaging_maintainer_mode }}
6159
generator: ${{ matrix.generator }}
6260

61+
- name: Project Name
62+
uses: cardinalby/export-env-action@v2
63+
with:
64+
envFile: '.github/constants.env'
65+
6366

6467
- name: Setup Cpp
6568
uses: aminya/setup-cpp@v1

.github/workflows/template-janitor.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- OFF
3434

3535
steps:
36-
- uses: actions/checkout@v2
36+
- uses: actions/checkout@v3
3737

3838
- name: Setup Cache
3939
uses: ./.github/actions/setup_cache
@@ -74,7 +74,7 @@ jobs:
7474
- name: Insert new org and project
7575
run: |
7676
# rename the CMake project to match the github project
77-
find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} +
77+
find src include test fuzz_test cmake -type f -exec sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" .github/constants.env CMakeLists.txt Dependencies.cmake ProjectOptions.cmake .github/workflows/ci.yml .github/workflows/codeql-analysis.yml configured_files/config.hpp.in {} +
7878
7979
# Update URL placeholders for project
8080
sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt
@@ -122,20 +122,28 @@ jobs:
122122
gcovr: false
123123
opencppcoverage: false
124124

125+
- name: Project Name
126+
uses: cardinalby/export-env-action@v2
127+
with:
128+
envFile: '.github/constants.env'
129+
130+
125131

126132
- name: Test simple configuration to make sure nothing broke
127133
run: |
128-
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF
134+
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.NEW_SAFE_PROJECT }}_PACKAGING_MAINTAINER_MODE:BOOL=ON
129135
# Build it because we may have broken something in the cpp/hpp files
130136
cmake --build build
131137
132-
- uses: EndBug/add-and-commit@v4
138+
- uses: EndBug/add-and-commit@v9
133139
# only commit and push if we are not a template project anymore!
134140
if: fromJson(steps.get_repo_meta.outputs.data).is_template != true
135141
with:
142+
add: -A
136143
author_name: Template Janitor
137144
author_email: template.janitor@example.com
138145
message: 'Cleanup template and initialize repository'
146+
pathspec_error_handling: exitImmediately
139147
env:
140148
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
141149

@@ -156,7 +164,7 @@ jobs:
156164
- OFF
157165

158166
steps:
159-
- uses: actions/checkout@v2
167+
- uses: actions/checkout@v3
160168

161169
- name: Setup Cache
162170
uses: ./.github/actions/setup_cache
@@ -223,14 +231,16 @@ jobs:
223231

224232
- name: Test simple configuration to make sure nothing broke (default compiler,cmake,developer_mode OFF)
225233
run: |
226-
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF
234+
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -D${{ env.PROJECT_NAME }}_PACKAGING_MAINTAINER_MODE:BOOL=ON
227235
228-
- uses: EndBug/add-and-commit@v4
236+
- uses: EndBug/add-and-commit@v9
229237
# only commit and push if we are a template and project name has changed
230238
if: fromJson(steps.get_repo_meta.outputs.data).is_template == true && env.TEST_RUN == 'false'
231239
with:
240+
add: -A
232241
author_name: Template Janitor
233242
author_email: template.janitor@example.com
234243
message: 'Change Template Name'
244+
pathspec_error_handling: exitImmediately
235245
env:
236246
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ProjectOptions.cmake

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@ include(cmake/LibFuzzer.cmake)
33
include(CMakeDependentOption)
44
include(CheckCXXCompilerFlag)
55

6-
macro(myproject_setup_options)
7-
option(myproject_ENABLE_HARDENING "Enable hardening" ON)
8-
option(myproject_ENABLE_COVERAGE "Enable coverage reporting" OFF)
9-
cmake_dependent_option(
10-
myproject_ENABLE_GLOBAL_HARDENING
11-
"Attempt to push hardening options to built dependencies"
12-
ON
13-
myproject_ENABLE_HARDENING
14-
OFF)
156

7+
macro(myproject_supports_sanitizers)
168
if((CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" OR CMAKE_CXX_COMPILER_ID MATCHES ".*GNU.*") AND NOT WIN32)
179
set(SUPPORTS_UBSAN ON)
1810
else()
@@ -24,6 +16,19 @@ macro(myproject_setup_options)
2416
else()
2517
set(SUPPORTS_ASAN ON)
2618
endif()
19+
endmacro()
20+
21+
macro(myproject_setup_options)
22+
option(myproject_ENABLE_HARDENING "Enable hardening" ON)
23+
option(myproject_ENABLE_COVERAGE "Enable coverage reporting" OFF)
24+
cmake_dependent_option(
25+
myproject_ENABLE_GLOBAL_HARDENING
26+
"Attempt to push hardening options to built dependencies"
27+
ON
28+
myproject_ENABLE_HARDENING
29+
OFF)
30+
31+
myproject_supports_sanitizers()
2732

2833
if(NOT PROJECT_IS_TOP_LEVEL OR myproject_PACKAGING_MAINTAINER_MODE)
2934
option(myproject_ENABLE_IPO "Enable IPO/LTO" OFF)
@@ -90,9 +95,12 @@ macro(myproject_global_options)
9095
myproject_enable_ipo()
9196
endif()
9297

98+
myproject_supports_sanitizers()
99+
93100
if(myproject_ENABLE_HARDENING AND myproject_ENABLE_GLOBAL_HARDENING)
94101
include(cmake/Hardening.cmake)
95-
if(myproject_ENABLE_SANITIZER_UNDEFINED
102+
if(NOT SUPPORTS_UBSAN
103+
OR myproject_ENABLE_SANITIZER_UNDEFINED
96104
OR myproject_ENABLE_SANITIZER_ADDRESS
97105
OR myproject_ENABLE_SANITIZER_THREAD
98106
OR myproject_ENABLE_SANITIZER_LEAK)
@@ -177,7 +185,11 @@ macro(myproject_local_options)
177185

178186
if(myproject_ENABLE_HARDENING AND NOT myproject_ENABLE_GLOBAL_HARDENING)
179187
include(cmake/Hardening.cmake)
180-
if(myproject_ENABLE_SANITIZER_UNDEFINED)
188+
if(NOT SUPPORTS_UBSAN
189+
OR myproject_ENABLE_SANITIZER_UNDEFINED
190+
OR myproject_ENABLE_SANITIZER_ADDRESS
191+
OR myproject_ENABLE_SANITIZER_THREAD
192+
OR myproject_ENABLE_SANITIZER_LEAK)
181193
set(ENABLE_UBSAN_MINIMAL_RUNTIME FALSE)
182194
else()
183195
set(ENABLE_UBSAN_MINIMAL_RUNTIME TRUE)

0 commit comments

Comments
 (0)