Skip to content

Commit f4fbd65

Browse files
Fixing #16 and introducing polyfill namespaces. (#18)
* Fixing #16 and introducing polyfill namespaces. * changed everything to .hpp
1 parent 2a5a53f commit f4fbd65

File tree

21 files changed

+434
-213
lines changed

21 files changed

+434
-213
lines changed

.vscode/settings.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"/(lib)?cyphal/g",
1111
"/ovfl/g",
1212
"/Cyphal/ig",
13+
"/cetl/i",
14+
"/cetlvast/i",
1315
"/tparam/g",
1416
"/\\.hpp/g",
1517
"/endcode/g",
@@ -20,14 +22,18 @@
2022
"/g(oogle)?test/",
2123
"/(?:de?|con)struct(?:able?|or)/i",
2224
"/copydoc/",
23-
"/(r)?begin/",
24-
"/(r)?end/",
25+
"/\\b(r)?begin/",
26+
"/\\b(r)?end/",
2527
"/cetl(vast)?/",
2628
"/(c|d)tor/i",
2729
"/arr/",
2830
"/subspan/i",
29-
"/nodiscar/",
30-
"/trimleft/"
31+
"/nodiscard/",
32+
"/trimleft/",
33+
"/polyfill/i",
34+
"/autosar/i",
35+
"/__cplusplus/",
36+
"/<cassert>/"
3137
],
3238
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
3339
"cmake.configureOnOpen": false,
@@ -42,7 +48,6 @@
4248
],
4349
"editor.wordWrapColumn": 120,
4450
"editor.rulers": [
45-
80,
4651
120
4752
],
4853
"files.eol": "\n",

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ docker run --rm -it -v ${PWD}:/repo ghcr.io/opencyphal/toolshed:ts22.4.x
5858
```
5959
3. cd into the CETLVaSt test suite directory then run the verify script to
6060
configure the unittest suite with `--configure-only` and (we suggest)
61-
`--force-ninja`. By including `-vv` you can see the exact cmake commands
62-
verify.py is executing and you and use `--dry-run` if you really don't
63-
like my python script so much that you want to do all the typing yourself
64-
(It's not like I spent a ton of time documenting all of these options for
65-
you. No no. It's fine. Don't try to apologize now...):
61+
`--force-ninja`. This step is important because it pulls test-only dependencies
62+
from github (i.e. googletest) and configures them for use by CETLVaSt. By
63+
including `-vv` you can see the exact cmake commands verify.py is executing and
64+
you and use `--dry-run` if you really hate my python script so much that you
65+
want to do all the typing yourself (It's not like I spent a ton of time
66+
documenting all of these options for you. No no. It's fine. Don't try to
67+
apologize now...):
6668
```
6769
cd cetlvast
6870
./verify.py -vv --configure-only --force-ninja unittest

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ Cyphal Embedded Template Library
1010

1111
## include
1212

13-
The include directory contains the CETL headers all within a folder, "cetl".
13+
The include directory contains the CETL headers all within a folder, "cetl". Types found under "cetl/pfXX" folders and
14+
within `cetl::pfxx` namespaces are ["polyfill"](https://en.wikipedia.org/wiki/Polyfill_(programming)) types that adhere
15+
to the XX standard. For example, `cetl::pf20::span` is a type that adheres, as closely as possible, to the C++20
16+
specification for the `std::span` type.
17+
18+
> Any type found directly under the cetl folder does *not* adhere to a known standard and is specific only to CETL.
19+
20+
Also under each "cetl/pfXX" folder will be a "cetlpf.hpp" header. These headers enable automatic polyfill behavior but do
21+
so by violating certain AUTOSAR-14 rules. We recommend using the CETL polyfill types directly in code that adheres
22+
to AUTOSAR-14.
1423

1524
TODO: Once [Issue #12](https://github.com/OpenCyphal-Garage/CETL/issues/12) is complete we'll provide some more
1625
info here on how we expect you to take a dependency on CETL.
@@ -39,13 +48,13 @@ mimicking other support libraries like Boost.
3948
the default STL allocator but will always support an alternative way to manage their memory.
4049
- **CETL minimizes type aliasing and never injects typedef or macros into external namespaces.** – If an `std::uint8_t`
4150
will suffice CETL uses that explicitly. If a function should be constexpr the constexpr keyword will be used. etc.
42-
- **CETL tries really, really hard to not use macros**With the exception of include guard ifndef clauses, CETL does
51+
- **CETL tries really, really hard to not use macros**Except where AUTOSAR-14 Rule A16-0-1 permits, CETL does
4352
not use any C macros where a C++ template or other construct will suffice.
4453
- **CETL is [Autosar C++14](https://www.autosar.org/fileadmin/standards/adaptive/20-11/AUTOSAR_RS_CPP14Guidelines.pdf)
4554
compliant** – Where it violates Autosar rules comments will provide a clear rationale.
46-
- **CETL headers have minimal dependencies** – While there is a `cetl/cetl.h` it is minimal and does not drag a large
55+
- **CETL headers have minimal dependencies** – While there is a `cetl/cetl.hpp` it is minimal and does not drag a large
4756
set of conventions, typedefs, and other constructs that will pollute your code. Each type provided is isolated as much
48-
as practical and users that want to copy and paste one of the CETL headers into their project can easily elide cetl.h
57+
as practical and users that want to copy and paste one of the CETL headers into their project can easily elide cetl.hpp
4958
with minimal effort.
5059

5160

cetlvast/cmake/modules/Finddocs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function (create_docs_target ARG_DOCS_TARGET_NAME ARG_ADD_TO_ALL ARG_EXAMPLES_PA
4343
file(GLOB_RECURSE DOXYGEN_INPUT_LIST
4444
LIST_DIRECTORIES false
4545
CONFIGURE_DEPENDS
46-
${CETL_ROOT}/include/**/*.h
46+
${CETL_ROOT}/include/**/*.hpp
4747
)
4848

4949
list(APPEND DOXYGEN_INPUT_LIST "${CETL_ROOT}/README.md")

cetlvast/cmake/suites/compile.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,11 @@ add_custom_target(
8585
DEPENDS
8686
${ALL_TESTS}
8787
)
88+
89+
add_custom_target(
90+
suite_all
91+
COMMENT
92+
"All CETL suites define this target as a default action scripts can rely on."
93+
DEPENDS
94+
test_all
95+
)

cetlvast/cmake/suites/docs.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,11 @@ add_custom_target(
8989
find_package(docs REQUIRED)
9090

9191
create_docs_target(docs ON ${CETLVAST_PROJECT_ROOT}/suites/docs/examples "${ALL_EXAMPLES}")
92+
93+
add_custom_target(
94+
suite_all
95+
COMMENT
96+
"All CETL suites define this target as a default action scripts can rely on."
97+
DEPENDS
98+
docs
99+
)

cetlvast/cmake/suites/lint.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@
99
# +---------------------------------------------------------------------------+
1010
find_package(clangformat REQUIRED)
1111

12-
create_check_style_target(format-check ${CETLVAST_STYLE_CHECK} "${CETL_INCLUDE}/**/*.h")
12+
create_check_style_target(format-check ${CETLVAST_STYLE_CHECK} "${CETL_INCLUDE}/**/*.hpp")
13+
14+
add_custom_target(
15+
suite_all
16+
COMMENT
17+
"All CETL suites define this target as a default action scripts can rely on."
18+
DEPENDS
19+
format-check
20+
)

cetlvast/cmake/suites/unittest.cmake

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,13 @@ add_custom_target(
176176
${ALL_TESTS}
177177
)
178178

179-
# +---------------------------------------------------------------------------+
180-
# If we can we try to upload the report to sonarqube.
181-
#
182-
find_package(sonar-scanner)
183-
184-
if (SONAR_SCANNER_FOUND)
185-
message(STATUS "sonarqube upload binary was defined. Adding the upload target: sonarqube_upload")
186-
add_custom_target(
187-
sonarqube_upload
188-
${SONARQUBE} --root ${CMAKE_CURRENT_SOURCE_DIR} ${CETLVAST_NATIVE_TEST_BINARY_DIR}/coverage.info -v
189-
COMMENT "Upload to sonarqube (requires that SONARQUBE_TOKEN is defined in the environment)."
190-
)
191-
192-
else()
193-
message(STATUS "sonarqube upload script not found. Upload target will not be available.")
194-
endif()
195-
179+
add_custom_target(
180+
suite_all
181+
COMMENT
182+
"All CETL suites define this target as a default action scripts can rely on."
183+
DEPENDS
184+
test_all
185+
)
196186

197187
# Write a README to create the tests folder.
198188
file(WRITE ${CETLVAST_NATIVE_TEST_BINARY_DIR}/README.txt

cetlvast/suites/compile/test_span_empty.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
/// Copyright Amazon.com Inc. or its affiliates.
88
/// SPDX-License-Identifier: MIT
99
///
10-
#include "cetl/cetl.h"
11-
#include "cetl/span.h"
10+
#include "cetl/cetl.hpp"
11+
#include "cetl/pf20/span.hpp"
1212

1313
#ifndef CETLVAST_COMPILETEST_PRECHECK
1414
static_assert(__cplusplus >= CETL_CPP_STANDARD_17, "We simply pass this test (i.e. fail to compile) for C++14");
1515
#endif
1616

1717
int main()
1818
{
19-
cetl::span<int,0> subject;
19+
cetl::pf20::span<int,0> subject;
2020
#ifndef CETLVAST_COMPILETEST_PRECHECK
2121
subject.empty(); // this should fail because nodiscard is available
2222
#else

0 commit comments

Comments
 (0)