Skip to content

Commit

Permalink
Add C++17 build to CI (#231)
Browse files Browse the repository at this point in the history
* Add C++17 build to CI

closes #228
- Also fixes a sq code-smell.
- fixes a unit tests that was invalid (missing memset of a datastructure)
  • Loading branch information
thirtytwobits committed Dec 14, 2021
1 parent c76eaa6 commit 92b02ff
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .github/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _cmake_configure(args: argparse.Namespace, cmake_args: typing.List[str], cma
cmake_configure_args.append("-DNUNAVUT_VERIFICATION_SER_FP_DISABLE:BOOL=ON")

if args.enable_ovr_var_array:
cmake_configure_args.append("-NUNAVUT_VERIFICATION_OVR_VAR_ARRAY_ENABLE:BOOL=ON")
cmake_configure_args.append("-DNUNAVUT_VERIFICATION_OVR_VAR_ARRAY_ENABLE:BOOL=ON")

if args.verbose > 0:
cmake_configure_args.append("-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON")
Expand Down Expand Up @@ -510,6 +510,9 @@ def _cmake_test(args: argparse.Namespace, cmake_args: typing.List[str], cmake_di
def _create_build_dir_name(args: argparse.Namespace) -> str:
name = "build_{}".format(args.language)

if args.language_standard is not None:
name += "_{}".format(args.language_standard)

name += "_{}".format(args.toolchain_family)

if args.platform is not None:
Expand Down
33 changes: 31 additions & 2 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
--build-type ${{ matrix.build_type }} \
${{ matrix.flag }}
language-verification-cpp:
language-verification-cpp-14:
runs-on: ubuntu-latest
needs: test
container: uavcan/c_cpp:ubuntu-20.04
Expand All @@ -166,12 +166,41 @@ jobs:
.github/verify.py --override .github/verify_global.ini \
--override .github/verify_cpp_${{ matrix.compiler }}_${{ matrix.architecture }}.ini \
--build-type ${{ matrix.build_type }} \
--language-standard c++14 \
${{ matrix.flag }}
language-verification-cpp-17:
runs-on: ubuntu-latest
needs: test
container: uavcan/c_cpp:ubuntu-20.04
strategy:
matrix:
build_type: [Debug, Release, MinSizeRel]
architecture: [native32, native64]
compiler: [gcc, clang]
flag: [--none, --enable-ovr-var-array, --disable-asserts]
exclude:
- build_type: Debug
flag: --disable-asserts
- build_type: Release
flag: --disable-asserts

steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: verify
run: |
.github/verify.py --override .github/verify_global.ini \
--override .github/verify_cpp_${{ matrix.compiler }}_${{ matrix.architecture }}.ini \
--build-type ${{ matrix.build_type }} \
--language-standard c++17 \
${{ matrix.flag }}
release:
if: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && github.repository == 'UAVCAN/nunavut' }}
runs-on: ubuntu-latest
needs: [compat-test-python3, language-verification-cpp, language-verification-c, sonar]
needs: [compat-test-python3, language-verification-cpp-14, language-verification-cpp-17, language-verification-c, sonar]
steps:
- uses: actions/setup-python@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"defines": ["NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY=1"],
"compileCommands": "${workspaceFolder}/.vscode/compile_commands.json",
"configurationProvider": "ms-vscode.cmake-tools",
"cStandard": "c11",
Expand Down
19 changes: 19 additions & 0 deletions .vscode/cmake-kits.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@
"NUNAVUT_VERIFICATION_TARGET_PLATFORM": "native32"
}
},
{
"name": "native64-gcc-c-nocov",
"toolchainFile": "${workspaceFolder}/verification/cmake/toolchains/gcc-native.cmake",
"cmakeSettings": {
"NUNAVUT_VERIFICATION_LANG": "c",
"NUNAVUT_VERIFICATION_TARGET_PLATFORM": "native64",
"NUNAVUT_FLAGSET": "${workspaceFolder}/verification/cmake/compiler_flag_sets/native.cmake"
}
},
{
"name": "native64-clang-c-nocov",
"toolchainFile": "${workspaceFolder}/verification/cmake/toolchains/clang-native.cmake",
"cmakeSettings": {
"NUNAVUT_VERIFICATION_LANG": "c",
"NUNAVUT_VERIFICATION_TARGET_PLATFORM": "native64",
"NUNAVUT_FLAGSET": "${workspaceFolder}/verification/cmake/compiler_flag_sets/native.cmake",
"NUNAVUT_VERIFICATION_OVR_VAR_ARRAY_ENABLE": "ON"
}
},
{
"name": "native-gcc-cpp-nocov",
"toolchainFile": "${workspaceFolder}/verification/cmake/toolchains/gcc-native.cmake",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.configurationWarnings": "Disabled",
"files.associations": {
"*.py.template": "python",
"*.cc": "c++",
"*.hpp": "c++",
"__bit_reference": "cpp",
"__config": "cpp",
"__debug": "cpp",
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following languages are currently on the roadmap:

- **Python** (already supported in `PyUAVCAN`_, pending
`transplantation into Nunavut <https://github.com/UAVCAN/pyuavcan/issues/110>`_)
- **C++11** (generates header-only libraries; `work-in-progress <https://github.com/UAVCAN/nunavut/issues/91>`_)
- **C++ 14 and newer** (generates header-only libraries; `work-in-progress <https://github.com/UAVCAN/nunavut/issues/91>`_)

Nunavut is named after the `Canadian territory`_. We chose the name because it
is a beautiful word to say and read. Also, the name fits with a theme of "places
Expand Down
2 changes: 1 addition & 1 deletion src/nunavut/lang/cpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Language(BaseLanguage):
Concrete, C++-specific :class:`nunavut.lang.Language` object.
"""

CPP_STD_EXTRACT_NUMBER_PATTERN = re.compile(r"(?:gnu|c)\+\+(\d(?:\d|\w))")
CPP_STD_EXTRACT_NUMBER_PATTERN = re.compile(r"(?:gnu|c)\+\+(\d(?:\w))")

@staticmethod
def _handle_stropping_or_encoding_failure(
Expand Down
9 changes: 7 additions & 2 deletions verification/c/suite/test_override_variable_array_capacity.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// This software is distributed under the terms of the MIT License.


#include <nunavut/support/serialization.h>

#if NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 1
# define OVERRIDE_SIZE 2
# define regulated_basics_PrimitiveArrayVariable_0_1_a_u64_ARRAY_CAPACITY_ OVERRIDE_SIZE
Expand All @@ -17,11 +19,14 @@
static void testPrimitiveArrayVariableOverride(void)
{
regulated_basics_PrimitiveArrayVariable_0_1 ref;
memset(&ref, 0, sizeof(ref));
uint8_t buf[regulated_basics_PrimitiveArrayVariable_0_1_SERIALIZATION_BUFFER_SIZE_BYTES_ - 1];

#if NUNAVUT_SUPPORT_LANGUAGE_OPTION_ENABLE_OVERRIDE_VARIABLE_ARRAY_CAPACITY == 1
TEST_ASSERT_EQUAL(sizeof(ref.a_u64.elements[0]) * OVERRIDE_SIZE, sizeof(ref.a_u64.elements));
TEST_ASSERT_EQUAL(sizeof(ref.n_f64.elements[0]) * OVERRIDE_SIZE, sizeof(ref.n_f64.elements));
TEST_ASSERT_EQUAL(OVERRIDE_SIZE, regulated_basics_PrimitiveArrayVariable_0_1_a_u64_ARRAY_CAPACITY_);
TEST_ASSERT_EQUAL(OVERRIDE_SIZE, sizeof(ref.a_u64.elements) / sizeof(ref.a_u64.elements[0]));
TEST_ASSERT_EQUAL(OVERRIDE_SIZE, regulated_basics_PrimitiveArrayVariable_0_1_n_f32_ARRAY_CAPACITY_);
TEST_ASSERT_EQUAL(OVERRIDE_SIZE, sizeof(ref.n_f32.elements) / sizeof(ref.n_f32.elements[0]));
#else
TEST_ASSERT_EQUAL(sizeof(ref.a_u64.elements[0]) *
regulated_basics_PrimitiveArrayVariable_0_1_a_u64_ARRAY_CAPACITY_,
Expand Down

0 comments on commit 92b02ff

Please sign in to comment.