Skip to content

Commit 71e0ccd

Browse files
Adding VariableLengthArray and PMR namespace (#28)
* Adding VariableLengthArray and PMR namesapce Providing a polyfill of much of the pmr namespace for C++14. Adding VariableLengthArray as an allocator-aware vector. CETL's VLA differs from vector in three respects: 1. it supports the CETL-specific reallocation extension to PMR::memory_resource 2. it will tightly fit into a maximum size when elements are pushed without calling reserve first. 3. it avoids undefined behaviour when exceptions are disabled. An unintended benefit: this works with C++17/AppleClang which does not support PMR. * some cleanups to get CI started. * fixes for CI * adding external project creation to verify.py * once more with feeling Fixing CI to properly report test coverage and to actually execute the compile tests. * fixing examples per Pavel's comments * fixing some bugs, improving coverage * adding copy ctor with additional allocator arg * fixing a bug found when coverage increased * two tweaks
1 parent f2510e7 commit 71e0ccd

File tree

93 files changed

+13149
-2619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+13149
-2619
lines changed

cetlvast/cmake/toolchains/clang-native.cmake renamed to .devcontainer/cmake/toolchains/clang-native.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,4 @@
1010
set(CMAKE_C_COMPILER clang CACHE FILEPATH "C compiler")
1111
set(CMAKE_CXX_COMPILER clang++ CACHE FILEPATH "C++ compiler")
1212
set(CMAKE_ASM_COMPILER clang CACHE FILEPATH "assembler")
13-
set(CMAKE_CXX_STANDARD ${CETLVAST_CPP_STANDARD})
1413
set(CMAKE_CXX_STANDARD_REQUIRED ON)
15-
16-
set(CMAKE_C_COVERAGE_PROCESSOR "llvm-cov gcov")

cetlvast/cmake/toolchains/gcc-native.cmake renamed to .devcontainer/cmake/toolchains/gcc-native.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,4 @@
99
set(CMAKE_C_COMPILER gcc CACHE FILEPATH "C compiler")
1010
set(CMAKE_CXX_COMPILER g++ CACHE FILEPATH "C++ compiler")
1111
set(CMAKE_ASM_COMPILER gcc CACHE FILEPATH "assembler")
12-
set(CMAKE_CXX_STANDARD ${CETLVAST_CPP_STANDARD})
1312
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14-
set(CMAKE_C_COVERAGE_PROCESSOR gcov)

.devcontainer/devcontainer.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
"customizations": {
55
"vscode": {
66
"extensions": [
7-
"ms-vscode.cpptools",
8-
"twxs.cmake",
9-
"ms-vscode.cmake-tools",
10-
"ban.spellright",
11-
"xaver.clang-format"
7+
"ms-vscode.cpptools-extension-pack",
8+
"streetsidesoftware.code-spell-checker",
9+
"xaver.clang-format",
10+
"vadimcn.vscode-lldb",
11+
"matepek.vscode-catch2-test-adapter",
12+
"ms-vscode.hexeditor"
1213
]
1314
}
1415
},
1516
"workspaceFolder": "/repo",
1617
"workspaceMount": "source=${localWorkspaceFolder},target=/repo,type=bind,consistency=delegated",
1718
"mounts": [
18-
"source=profile,target=/root,type=volume",
19+
"source=profile-cetl,target=/root,type=volume",
1920
"target=/root/.vscode-server,type=volume"
2021
]
2122
}

.github/workflows/cetlvast.yml

Lines changed: 59 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,75 +15,92 @@ jobs:
1515
container: ghcr.io/opencyphal/toolshed:ts22.4.3
1616
strategy:
1717
matrix:
18-
std: [base, intermediate, target]
18+
build_flavor: [Debug, Release]
19+
exceptions: [exceptions, no-exceptions]
20+
std: [14, 17, 20]
1921
toolchain: [gcc, clang]
20-
suite: [unittest, compile]
22+
include:
23+
- build_flavor: Coverage
24+
exceptions: no-exceptions
25+
std: 14
26+
toolchain: gcc
27+
exclude:
28+
- build_flavor: Debug
29+
exceptions: no-exceptions
30+
std: 14
31+
toolchain: gcc
2132
steps:
2233
- uses: actions/checkout@v3
23-
- name: setup environment common
24-
run: >
25-
echo "CETLVAST_EXT_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls extdir none)" >> $GITHUB_ENV;
26-
echo "CETLVAST_SUITE_UNITTEST_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls builddir unittest)" >> $GITHUB_ENV;
27-
echo "CETLVAST_SUITE_BUILD_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls builddir none)" >> $GITHUB_ENV;
28-
echo "CETLVAST_COVERAGE_REPORT_FORMAT=sonarqube" >> $GITHUB_ENV
2934

3035
- name: Cache ext modules
3136
id: cetlvast-ext
3237
uses: actions/cache@v3
3338
env:
3439
cache-name: cetlvast-ext-cache
3540
with:
36-
path: ${{ env.CETLVAST_EXT_PATH }}
41+
path: cetlvast/build_external
3742
key: gtest_b796f7d44681514f58a683a3a71ff17c94edb0c1
3843
- name: run tests
3944
run: >
40-
./cetlvast/verify.py -cd ./cetlvast
41-
--force-ninja
42-
--coverage ${{ env.CETLVAST_COVERAGE_REPORT_FORMAT }}
43-
--build-flavor Debug
45+
./build-tools/bin/verify.py
46+
-v
47+
--online
4448
--asserts
45-
--generate-test-report testExecutions.xml
49+
--${{ matrix.exceptions }}
50+
--build-flavor ${{ matrix.build_flavor }}
4651
--cpp-standard ${{ matrix.std }}
4752
--toolchain ${{ matrix.toolchain }}
48-
${{ matrix.suite }}
53+
test
54+
- name: debug output
55+
if: ${{ runner.debug == '1' }}
56+
run: ls -lAhR build/
4957
- name: upload-artifacts
5058
uses: actions/upload-artifact@v3
5159
with:
52-
name: ${{ matrix.suite }}-${{ matrix.std }}-${{ matrix.toolchain }}
60+
name: ${{ matrix.build_flavor }}-${{ matrix.exceptions }}-${{ matrix.std }}-${{ matrix.toolchain }}
5361
path: |
54-
${{ env.CETLVAST_SUITE_BUILD_PATH }}/compile_commands.json
55-
${{ env.CETLVAST_SUITE_BUILD_PATH }}/cetlvast/suites/${{ matrix.suite }}
62+
build/compile_commands.json
63+
build/*/**/coverage.xml
64+
build/*/**/*-sonarqube.xml
65+
build/*/**/gcovr_html/*.*
5666
if-no-files-found: error
5767
docs:
5868
runs-on: ubuntu-latest
5969
container: ghcr.io/opencyphal/toolshed:ts22.4.3
6070
steps:
6171
- uses: actions/checkout@v3
62-
- name: setup environment
63-
run: >
64-
echo "CETLVAST_SUITE_DOCS_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls builddir docs)" >> $GITHUB_ENV;
65-
echo "CETLVAST_EXT_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls extdir none)" >> $GITHUB_ENV
6672
- name: Cache ext modules
6773
id: cetlvast-ext
6874
uses: actions/cache@v3
6975
env:
7076
cache-name: cetlvast-ext-cache
7177
with:
72-
path: ${{ env.CETLVAST_EXT_PATH }}
78+
path: cetlvast/build_external
7379
key: gtest_b796f7d44681514f58a683a3a71ff17c94edb0c1
74-
- name: Check Style
75-
run: |
76-
./cetlvast/verify.py -cd ./cetlvast lint
77-
- name: verify
78-
run: ./cetlvast/verify.py -cd ./cetlvast docs
80+
- name: doc-gen
81+
run: >
82+
./build-tools/bin/verify.py
83+
-v
84+
--online
85+
--asserts
86+
--build-flavor Debug
87+
--cpp-standard 14
88+
build-docs
7989
- name: Setup Pages
90+
if: ${{ github.event_name != 'pull_request' }}
8091
uses: actions/configure-pages@v3
8192
- name: Upload docs
8293
if: ${{ github.event_name != 'pull_request' }}
8394
uses: actions/upload-pages-artifact@v1
8495
with:
85-
path: "${{ env.CETLVAST_SUITE_DOCS_PATH }}/html/"
86-
96+
path: "build/suites/docs/html/"
97+
- name: upload-pr-docs
98+
if: ${{ github.event_name == 'pull_request' }}
99+
uses: actions/upload-artifact@v3
100+
with:
101+
name: pr-docs
102+
path: "build/suites/docs/html/"
103+
if-no-files-found: error
87104
sonarqube:
88105
needs:
89106
- verification
@@ -96,28 +113,19 @@ jobs:
96113
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis by sonarqube.
97114
- name: Install sonar-scanner
98115
uses: SonarSource/sonarcloud-github-c-cpp@v1
99-
- name: setup environment
100-
run: >
101-
echo "CETLVAST_EXT_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls extdir none)" >> $GITHUB_ENV;
102-
echo "CETLVAST_SUITE_BUILD_PATH=$(./cetlvast/verify.py -cd ./cetlvast -ls builddir none)" >> $GITHUB_ENV;
103-
echo "CETLVAST_COVERAGE_REPORT=$(./cetlvast/verify.py -cd ./cetlvast -ls covri --coverage sonarqube unittest)" >> $GITHUB_ENV;
104-
echo "CETLVAST_TEST_REPORT=$(./cetlvast/verify.py -cd ./cetlvast -ls tests -gtr testExecutions.xml unittest)" >> $GITHUB_ENV;
105-
echo "CETLVAST_CPP_BASE=c++$(./cetlvast/verify.py -cd ./cetlvast -ls cppstd --cpp-standard base docs)" >> $GITHUB_ENV
106116

107117
- name: Cache ext modules
108118
id: cetlvast-ext
109119
uses: actions/cache@v3
110120
env:
111121
cache-name: cetlvast-ext-cache
112122
with:
113-
path: ${{ env.CETLVAST_EXT_PATH }}
123+
path: cetlvast/build_external
114124
key: gtest_b796f7d44681514f58a683a3a71ff17c94edb0c1
115-
116125
- uses: actions/download-artifact@v3
117126
with:
118-
name: unittest-base-clang
119-
path: ${{ env.CETLVAST_SUITE_BUILD_PATH }}
120-
127+
name: Coverage-no-exceptions-14-gcc
128+
path: build
121129
- name: Run sonar-scanner
122130
env:
123131
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -128,16 +136,18 @@ jobs:
128136
--define sonar.projectKey=OpenCyphal_CETL
129137
--define sonar.projectName=CETLVaSt
130138
--define sonar.projectVersion=1.0
131-
--define sonar.sources=include,cetlvast/suites/unittest
139+
--define sonar.sources=include,cetlvast/suites/unittest/sonar.cpp
140+
--define sonar.tests=cetlvast/suites/unittest,cetlvast/suites/docs/examples
141+
--define sonar.test.inclusions=test_*.cpp,example_*.cpp
132142
--define sonar.sourceEncoding=UTF-8
133143
--define sonar.host.url=https://sonarcloud.io
134144
--define sonar.cfamily.ignoreHeaderComments=false
135-
--define sonar.coverage.exclusions="cetlvast/suites/unittest/**/*"
136-
--define sonar.cpd.exclusions="cetlvast/suites/unittest/**/*"
137-
--define sonar.cfamily.compile-commands=${{ env.CETLVAST_SUITE_BUILD_PATH }}/compile_commands.json
138-
--define sonar.cfamily.reportingCppStandardOverride=${{ env.CETLVAST_CPP_BASE }}
139-
--define sonar.coverageReportPaths=${{ env.CETLVAST_COVERAGE_REPORT }}
140-
--define sonar.testExecutionReportPaths=${{ env.CETLVAST_TEST_REPORT }}
145+
--define sonar.coverage.exclusions="cetlvast/suites/unittest/**/*,cetlvast/suites/docs/examples/**/*,**/sonar.cpp"
146+
--define sonar.cpd.exclusions="cetlvast/suites/unittest/**/*,cetlvast/suites/docs/examples/**/*,**/sonar.cpp"
147+
--define sonar.cfamily.compile-commands="build/compile_commands.json"
148+
--define sonar.cfamily.reportingCppStandardOverride=c++14
149+
--define sonar.coverageReportPaths="build/suites/unittest/coverage.xml,build/suites/docs/examples/coverage.xml"
150+
--define sonar.testExecutionReportPaths="build/suites/unittest/unittest-sonarqube.xml,build/suites/docs/examples/examples-sonarqube.xml"
141151
142152
deploy-docs:
143153
if: ${{ (github.event_name == 'release' && !github.event.release.prerelease) || github.event_name == 'workflow_dispatch' }}

.github/workflows/codeql.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ jobs:
5151
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
5252

5353
- run: |
54-
echo "Building unittests for analysis"
55-
./cetlvast/verify.py -cd ./cetlvast -bf Debug unittest
54+
./build-tools/bin/verify.py -v --dont-force-ninja --online clean-build-build_examples
5655
5756
- name: Perform CodeQL Analysis
5857
uses: github/codeql-action/analyze@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ __pycache__
1313
.mypy*
1414
.pyenv
1515
.dockerup
16+
.scannerwork
1617

1718
# Eclipse
1819
.metadata

.vscode/cmake-kits.json

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,18 @@
11
[
22
{
3-
"name": "unittest-gcc",
3+
"name": "toolshed-gcc",
44
"description": "Compile and run unit tests using the host's default gcc toolchain.",
5-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/gcc-native.cmake",
5+
"toolchainFile": "${workspaceFolder}/.devcontainer/cmake/toolchains/gcc-native.cmake",
66
"cmakeSettings": {
7-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
8-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/unittest.cmake"
7+
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/default.cmake"
98
}
109
},
1110
{
12-
"name": "unittest-clang",
11+
"name": "toolshed-clang",
1312
"description": "Compile and run unit tests using the host's default clang toolchain.",
14-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/clang-native.cmake",
13+
"toolchainFile": "${workspaceFolder}/.devcontainer/cmake/toolchains/clang-native.cmake",
1514
"cmakeSettings": {
16-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
17-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/unittest.cmake"
18-
}
19-
},
20-
{
21-
"name": "compile-gcc",
22-
"description": "Compile and run compilation tests using the host's default gcc toolchain.",
23-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/gcc-native.cmake",
24-
"cmakeSettings": {
25-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
26-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/compile.cmake"
27-
}
28-
},
29-
{
30-
"name": "compile-clang",
31-
"description": "Compile and run compilation tests using the host's default clang toolchain.",
32-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/clang-native.cmake",
33-
"cmakeSettings": {
34-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
35-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/compile.cmake"
36-
}
37-
},
38-
{
39-
"name": "docs-gcc",
40-
"description": "Build the documentation and examples programs.",
41-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/gcc-native.cmake",
42-
"cmakeSettings": {
43-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
44-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/docs.cmake"
45-
}
46-
},
47-
{
48-
"name": "docs-clang",
49-
"description": "Build the documentation and examples programs.",
50-
"toolchainFile": "${workspaceFolder}/cetlvast/cmake/toolchains/clang-native.cmake",
51-
"cmakeSettings": {
52-
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/native.cmake",
53-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/docs.cmake"
54-
}
55-
},
56-
{
57-
"name": "lint",
58-
"description": "Static checkers.",
59-
"cmakeSettings": {
60-
"CETLVAST_TEST_SUITE": "${workspaceFolder}/cetlvast/cmake/suites/lint.cmake"
15+
"CETLVAST_FLAG_SET": "${workspaceFolder}/cetlvast/cmake/compiler_flag_sets/default.cmake"
6116
}
6217
}
6318
]

0 commit comments

Comments
 (0)