Skip to content

Commit 3ef30c4

Browse files
Issue #222: v1 platform layer (#223)
* Issue #222: v1 platform layer Interim PR here but I wanted to get this through review before it got too big. Things of interest: 1. Coverage build logic is complete. 2. Better definition around the LVS (Libuavcan Validation Suite) 3. Start of the "media" layer for CAN. 4. More sadness that it isn't five years from now and we could just use C++14. * adding compile-time test * Update ci/native-gcc-build-and-test.sh Co-Authored-By: Pavel Kirienko <[email protected]> * Update libuavcan/include/libuavcan/transport/media/can.hpp Co-Authored-By: Pavel Kirienko <[email protected]> * Tests, docs, and changes per PR comments. * Update libuavcan/include/libuavcan/transport/media/can.hpp Co-Authored-By: Pavel Kirienko <[email protected]> * updating the docs with media layer design * cleaning up some codacity warnings * removed \"porting\" as a term. * Adding newline to end of media.md.
1 parent 2cf6da0 commit 3ef30c4

37 files changed

+62433
-249
lines changed

.buildkite/pipeline.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
steps:
22
- label: ':hammer: native build and :mag: test'
3-
command: "./ci/native-build-and-test.sh"
3+
id: native-gcc-build-and-test
4+
command: "./ci/native-gcc-build-and-test.sh"
45
artifact_paths:
5-
- "build_ci_native/libuavcan"
6-
- "build_ci_native/docs/**/*"
6+
- "build_ci_native_gcc/libuavcan"
7+
- "build_ci_native_gcc/docs/**/*"
78
plugins:
89
- docker#v3.1.0:
910
workdir: /repo
@@ -12,7 +13,21 @@ steps:
1213
VERBOSE: 1
1314
agents:
1415
queue: 'default'
16+
timeout_in_minutes: 15
17+
- label: ':hammer: native build using clang'
18+
id: native-clang-build
19+
command: "./ci/native-clang-build.sh"
20+
plugins:
21+
- docker#v3.1.0:
22+
workdir: /repo
23+
image: "uavcan/libuavcan:latest"
24+
env:
25+
VERBOSE: 1
26+
agents:
27+
queue: 'default'
28+
timeout_in_minutes: 15
1529
- label: ':hammer: s32k build'
30+
id: ontarget-s32k-build
1631
command: "./ci/ontarget-s32k-build.sh"
1732
artifact_paths:
1833
- "build_ci_ontarget_s32k/**/*.log"
@@ -28,6 +43,7 @@ steps:
2843
VERBOSE: 1
2944
agents:
3045
queue: 'default'
46+
timeout_in_minutes: 15
3147
- wait
3248
- label: ":mag: ontarget testing"
3349
command: "./ci/ontarget-s32k-test.sh"

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ file(MAKE_DIRECTORY ${EXTERNAL_PROJECT_DIRECTORY})
1717

1818
set(LIBUAVCAN_INCLUDE "${CMAKE_SOURCE_DIR}/libuavcan/include")
1919
set(LIBUAVCAN_INCLUDE_GENERATED "${CMAKE_CURRENT_BINARY_DIR}/dsdl")
20+
set(LIBUAVCAN_INCLUDE_LVS_PTEST "${CMAKE_SOURCE_DIR}/libuavcan_validation_suite/include")
2021

2122
include_directories(
2223
${LIBUAVCAN_INCLUDE}
2324
${LIBUAVCAN_INCLUDE_GENERATED}
25+
${LIBUAVCAN_INCLUDE_LVS_PTEST}
2426
)
2527

2628
if(NOT LIBUAVCAN_FLAG_SET)
@@ -55,11 +57,6 @@ find_package(public_regulated_data_types REQUIRED)
5557
#
5658
find_package(gtest REQUIRED)
5759

58-
#
59-
# We generate coverage reports. Please look at them.
60-
#
61-
find_package(lcov REQUIRED)
62-
6360
#
6461
# Finds programs needed to build the libuavcan documentation
6562
#
@@ -99,10 +96,15 @@ add_dependencies(format-generated dsdl-regulated)
9996
create_check_style_target(format-check ON "${LIBUAVCAN_INCLUDE}/**/*.hpp")
10097

10198
# +---------------------------------------------------------------------------+
102-
# | BUILD AND RUN UNIT TESTS
99+
# | BUILD UNIT TESTS
103100
# +---------------------------------------------------------------------------+
104101
include(${LIBUAVCAN_TESTBUILD})
105102

103+
# +---------------------------------------------------------------------------+
104+
# | DEFINE COMPILE-TIME TESTS
105+
# +---------------------------------------------------------------------------+
106+
include(${CMAKE_SOURCE_DIR}/test/compile/compile_tests.cmake)
107+
106108
# +---------------------------------------------------------------------------+
107109
# | DOCUMENTATION GENERATION
108110
# +---------------------------------------------------------------------------+

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ UAVCAN stack in C++
33

44
[![Build Status](https://badge.buildkite.com/af844974c06af6406e3b2192d98298b02b30f6ebebb5f8b16c.svg)](https://buildkite.com/uavcan/libuavcan-v1)
55
[![Forum](https://img.shields.io/discourse/https/forum.uavcan.org/users.svg)](https://forum.uavcan.org)
6+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/5d487b332d99498699a0af687fa513a1)](https://www.codacy.com/app/UAVCAN/libuavcan_v1?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=UAVCAN/libuavcan&amp;utm_campaign=Badge_Grade)
67

78
Portable reference implementation of the [UAVCAN protocol stack](https://new.uavcan.org) in C++ for embedded systems, Linux, and POSIX-compliant RTOSs.
89

@@ -25,7 +26,7 @@ You should never rewrite a codebase from scratch. It's a terrible idea. We're re
2526

2627
Sorry.
2728

28-
The reason we opted for a complete rewrite is that so much is changing. Between the updates to the specification, the abandonment of C++98 support, switching to header-only, removing the drivers from the main repository, adding CAN-FD support, etc, etc, etc; it was obvious that we'd be rewriting everything anyway. The good news is that v0 exists, is fully supported, and will be liberally copy-and-pasted from as this makes sense for v1. What we don't have is any git history tracing from v1 since this would be deceiving. Futhermore, the unit tests in uavcan v0 are a bit of a mess so we'll be writing them in a way that is more sustainable.
29+
The reason we opted for a complete rewrite is that so much is changing. Between the updates to the specification, the abandonment of C++98 support, switching to header-only, removing the drivers from the main repository, adding CAN FD support, etc, etc, etc; it was obvious that we'd be rewriting everything anyway. The good news is that v0 exists, is fully supported, and will be liberally copy-and-pasted from as this makes sense for v1. What we don't have is any git history tracing from v1 since this would be deceiving. Futhermore, the unit tests in uavcan v0 are a bit of a mess so we'll be writing them in a way that is more sustainable.
2930

3031
## Documentation
3132

@@ -42,6 +43,8 @@ The reason we opted for a complete rewrite is that so much is changing. Between
4243

4344
**/test/ontarget** - Tests cross-compiled for specific hardware* and run on a set of dedicated test devices. These tests may have strict timing constraints and may require specific physical or virtual busses and other test apparatuses be present. Each on-target test will fully document its requirements to enable anyone with access to the appropriate hardware to reproduce the tests. Furthermore, these tests must be inherently automateable having clear pass/fail criteria reducible to a boolean condition.
4445

46+
**/test/compile** – Tests that run in the compiler. Most of these will be tests that pass if they fail to compile. For example, some tests will purposefully define template parameters that will cause static_asserts to fail. Tests that pass if they do compile are less interesting here since such happy paths are normally covered by unit-tests.
47+
4548
**/example** - Contains a set of example applications providing real, practical, and tested uses of libuavcan.
4649

4750
**/commons** - Reference implementations for parts of the libuavcan library. These implementations are optional but are provided as a convenience to accelerate evaluation and integration of libuavcan.
@@ -128,7 +131,7 @@ To use visual studio code to debug ontarget tests for the S32K146EVB you'll need
128131
```
129132
{
130133
"cwd": "${workspaceRoot}",
131-
"executable": "build/test_bus.elf",
134+
"executable": "build/test_util_math.elf",
132135
"name": "On-target unit test.",
133136
"request": "launch",
134137
"type": "cortex-debug",

ci/native-build-and-test.sh renamed to ci/native-clang-build.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ set -o pipefail
3030
# | deploy (i.e. There's really no 'I' going on).
3131
# +----------------------------------------------------------+
3232

33-
mkdir -p build_ci_native
34-
pushd build_ci_native
35-
# We build native tests using clang since we use gcc for
36-
# cross-compiling. This gives us coverage by two different
37-
# compilers.
33+
mkdir -p build_ci_native_clang
34+
pushd build_ci_native_clang
35+
# We ensure we can build using clang but we rely on GCC for testing
36+
# since clang's coverage metrics have been broken for the last
37+
# several years.
3838
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/clang-native.cmake \
39-
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext \
39+
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_clang \
4040
..
41+
4142
make -j4
4243

44+
# We use ctest to run our compile tests.
4345
ctest -VV
4446

45-
make docs
46-
4747
popd

ci/native-gcc-build-and-test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env bash
2+
3+
# +----------------------------------------------------------+
4+
# | BASH : Modifying Shell Behaviour
5+
# | (https://www.gnu.org/software/bash/manual)
6+
# +----------------------------------------------------------+
7+
# Treat unset variables and parameters other than the special
8+
# parameters ‘@’ or ‘*’ as an error when performing parameter
9+
# expansion. An error message will be written to the standard
10+
# error, and a non-interactive shell will exit.
11+
set -o nounset
12+
13+
# Exit immediately if a pipeline returns a non-zero status.
14+
set -o errexit
15+
16+
# If set, the return value of a pipeline is the value of the
17+
# last (rightmost) command to exit with a non-zero status, or
18+
# zero if all commands in the pipeline exit successfully.
19+
set -o pipefail
20+
21+
# +----------------------------------------------------------+
22+
# | This script is one of the common set of commands run as
23+
# | part of a continuous integration build pipeline.
24+
# | These scrips are named using the following scheme:
25+
# |
26+
# | [build_type]-[(optional)build_type qualifier]-[build|test|report|upload].sh
27+
# |
28+
# | Of course, libuavcan is a header-only distribution so
29+
# | CI is used to verify and test rather than package and
30+
# | deploy (i.e. There's really no 'I' going on).
31+
# +----------------------------------------------------------+
32+
33+
mkdir -p build_ci_native_gcc
34+
pushd build_ci_native_gcc
35+
# GCC is our reference compiler since it does a better job with
36+
# coverage metrics.
37+
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-native.cmake \
38+
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_gcc \
39+
-DLIBUAVCAN_INTROSPECTION_ENABLE_ASSERT=1 \
40+
..
41+
42+
make -j4
43+
44+
# We use ctest to run our compile tests.
45+
ctest -VV
46+
47+
# This builds, runs, and reports on our native unit tests.
48+
# TODO: when we integrate with coveralls or codacy run make cov_info
49+
# instead to skip the genhtml step.
50+
make cov_all
51+
52+
make docs
53+
54+
popd

ci/ontarget-s32k-build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-arm-none-eabi.cmake \
4545

4646
make -j4
4747

48+
# We use ctest to run our compile tests.
49+
ctest -VV
50+
4851
popd

cmake/common.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ function(apply_flag_set ARG_FLAG_SET)
3131
set(LOCAL_CMAKE_ASM_FLAGS "${LOCAL_CMAKE_ASM_FLAGS} ${ITEM}")
3232
endforeach()
3333

34+
# +-----------------------------------------------------------------------+
35+
# | CONFIGURABLE DEFINITIONS
36+
# +-----------------------------------------------------------------------+
37+
if(DEFINED LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT)
38+
set(LOCAL_CMAKE_C_FLAGS "${LOCAL_CMAKE_C_FLAGS} -DLIBUAVCAN_INTROSPECTION_ENABLE_ASSERT=${LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT}")
39+
set(LOCAL_CMAKE_CXX_FLAGS "${LOCAL_CMAKE_CXX_FLAGS} -DLIBUAVCAN_INTROSPECTION_ENABLE_ASSERT=${LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT}")
40+
endif()
41+
# +-----------------------------------------------------------------------+
42+
3443
set(CMAKE_C_FLAGS ${LOCAL_CMAKE_C_FLAGS} PARENT_SCOPE)
3544
set(CMAKE_CXX_FLAGS ${LOCAL_CMAKE_CXX_FLAGS} PARENT_SCOPE)
3645
set(CMAKE_EXE_LINKER_FLAGS ${LOCAL_CMAKE_EXE_LINKER_FLAGS} PARENT_SCOPE)
3746
set(CMAKE_ASM_FLAGS ${LOCAL_CMAKE_ASM_FLAGS} PARENT_SCOPE)
3847

3948
add_definitions(${DEFINITIONS_SET})
49+
4050
endfunction()

cmake/compiler_flag_sets/native.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ list(APPEND CXX_FLAG_SET
6565

6666
set(EXE_LINKER_FLAG_SET )
6767
set(DEFINITIONS_SET )
68+

cmake/modules/Findlcov.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11

2-
32
find_program(LCOV lcov)
3+
find_program(GENHTML genhtml)
44

55
include(FindPackageHandleStandardArgs)
66

77
find_package_handle_standard_args(lcov
88
LCOV_FOUND
99
)
10+
11+
find_package_handle_standard_args(genhtml
12+
GENHTML_FOUND
13+
)

cmake/modules/Findlibuavcan_docs.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function (create_docs_target ARG_DOCS_TARGET_NAME ARG_ADD_TO_ALL)
3030
set(DOXYGEN_RDOMAIN_W_PROJECT org.uavcan.libuavcan)
3131
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/docs)
3232
set(DOXYGEN_CONFIG_FILE ${DOXYGEN_OUTPUT_DIRECTORY}/doxygen.config)
33-
set(DOXYGEN_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/libuavcan/include\" \"${CMAKE_CURRENT_SOURCE_DIR}/README.md\"")
33+
set(DOXYGEN_INPUT "\"${CMAKE_CURRENT_SOURCE_DIR}/libuavcan/include\" \"${CMAKE_CURRENT_SOURCE_DIR}/README.md\" \"${CMAKE_CURRENT_SOURCE_DIR}/doc_source/media.md\"")
3434
set(DOXYGEN_MAINPAGE "\"${CMAKE_CURRENT_SOURCE_DIR}/README.md\"")
3535

3636
# +-----------------------------------------------------------------------+
@@ -40,6 +40,10 @@ function (create_docs_target ARG_DOCS_TARGET_NAME ARG_ADD_TO_ALL)
4040
set(DOXYGEN_HTML_STYLESHEET ${DOXYGEN_OUTPUT_DIRECTORY}/customdoxygen.css)
4141
set(DOXYGEN_HTML_HEADER ${DOXYGEN_OUTPUT_DIRECTORY}/header.html)
4242
set(DOXYGEN_HTML_FOOTER ${DOXYGEN_OUTPUT_DIRECTORY}/footer.html)
43+
set(DOXYGEN_IMAGE_PATH ${DOXYGEN_OUTPUT_DIRECTORY}/images)
44+
set(DOXYGEN_LOGO ${DOXYGEN_OUTPUT_DIRECTORY}/images/html/uavcan_logo_icon.png)
45+
46+
file(COPY ${DOXYGEN_SOURCE}/images DESTINATION ${DOXYGEN_OUTPUT_DIRECTORY})
4347

4448
configure_file(${DOXYGEN_SOURCE}/header.html
4549
${DOXYGEN_OUTPUT_DIRECTORY}/header.html

0 commit comments

Comments
 (0)