Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #222: v1 platform layer #223

Merged
merged 10 commits into from
May 29, 2019
22 changes: 19 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
steps:
- label: ':hammer: native build and :mag: test'
command: "./ci/native-build-and-test.sh"
id: native-gcc-build-and-test
command: "./ci/native-gcc-build-and-test.sh"
artifact_paths:
- "build_ci_native/libuavcan"
- "build_ci_native/docs/**/*"
- "build_ci_native_gcc/libuavcan"
- "build_ci_native_gcc/docs/**/*"
plugins:
- docker#v3.1.0:
workdir: /repo
Expand All @@ -12,7 +13,21 @@ steps:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- label: ':hammer: native build using clang'
id: native-clang-build
command: "./ci/native-clang-build.sh"
plugins:
- docker#v3.1.0:
workdir: /repo
image: "uavcan/libuavcan:latest"
env:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- label: ':hammer: s32k build'
id: ontarget-s32k-build
command: "./ci/ontarget-s32k-build.sh"
artifact_paths:
- "build_ci_ontarget_s32k/**/*.log"
Expand All @@ -28,6 +43,7 @@ steps:
VERBOSE: 1
agents:
queue: 'default'
timeout_in_minutes: 15
- wait
- label: ":mag: ontarget testing"
command: "./ci/ontarget-s32k-test.sh"
Expand Down
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ file(MAKE_DIRECTORY ${EXTERNAL_PROJECT_DIRECTORY})

set(LIBUAVCAN_INCLUDE "${CMAKE_SOURCE_DIR}/libuavcan/include")
set(LIBUAVCAN_INCLUDE_GENERATED "${CMAKE_CURRENT_BINARY_DIR}/dsdl")
set(LIBUAVCAN_INCLUDE_LVS_PTEST "${CMAKE_SOURCE_DIR}/libuavcan_validation_suite/include")

include_directories(
${LIBUAVCAN_INCLUDE}
${LIBUAVCAN_INCLUDE_GENERATED}
${LIBUAVCAN_INCLUDE_LVS_PTEST}
)

if(NOT LIBUAVCAN_FLAG_SET)
Expand Down Expand Up @@ -55,11 +57,6 @@ find_package(public_regulated_data_types REQUIRED)
#
find_package(gtest REQUIRED)

#
# We generate coverage reports. Please look at them.
#
find_package(lcov REQUIRED)

#
# Finds programs needed to build the libuavcan documentation
#
Expand Down Expand Up @@ -89,6 +86,13 @@ create_dsdl_target(dsdl-regulated
#
apply_flag_set(${LIBUAVCAN_FLAG_SET})

# +---------------------------------------------------------------------------+
# | CONFIGURABLE DEFINITIONS
# +---------------------------------------------------------------------------+
if(DEFINED LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT)
add_compile_definitions(LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT=${LIBUAVCAN_INTROSPECTION_ENABLE_ASSERT})
endif()

# +---------------------------------------------------------------------------+
# | STYLE
# +---------------------------------------------------------------------------+
Expand All @@ -99,10 +103,15 @@ add_dependencies(format-generated dsdl-regulated)
create_check_style_target(format-check ON "${LIBUAVCAN_INCLUDE}/**/*.hpp")

# +---------------------------------------------------------------------------+
# | BUILD AND RUN UNIT TESTS
# | BUILD UNIT TESTS
# +---------------------------------------------------------------------------+
include(${LIBUAVCAN_TESTBUILD})

# +---------------------------------------------------------------------------+
# | DEFINE COMPILE-TIME TESTS
# +---------------------------------------------------------------------------+
include(${CMAKE_SOURCE_DIR}/test/compile/compile_tests.cmake)

# +---------------------------------------------------------------------------+
# | DOCUMENTATION GENERATION
# +---------------------------------------------------------------------------+
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ You should never rewrite a codebase from scratch. It's a terrible idea. We're re

Sorry.

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.
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.

## Documentation

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

**/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.

**/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.

**/example** - Contains a set of example applications providing real, practical, and tested uses of libuavcan.

**/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.
Expand Down Expand Up @@ -128,7 +130,7 @@ To use visual studio code to debug ontarget tests for the S32K146EVB you'll need
```
{
"cwd": "${workspaceRoot}",
"executable": "build/test_bus.elf",
"executable": "build/test_util_math.elf",
"name": "On-target unit test.",
"request": "launch",
"type": "cortex-debug",
Expand Down
16 changes: 8 additions & 8 deletions ci/native-build-and-test.sh → ci/native-clang-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ set -o pipefail
# | deploy (i.e. There's really no 'I' going on).
# +----------------------------------------------------------+

mkdir -p build_ci_native
pushd build_ci_native
# We build native tests using clang since we use gcc for
# cross-compiling. This gives us coverage by two different
# compilers.
mkdir -p build_ci_native_clang
pushd build_ci_native_clang
# We ensure we can build using clang but we rely on GCC for testing
# since clang's coverage metrics have been broken for the last
# several years.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/clang-native.cmake \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_clang \
..

make -j4

# We use ctest to run our compile tests.
ctest -VV

make docs

popd
54 changes: 54 additions & 0 deletions ci/native-gcc-build-and-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash

# +----------------------------------------------------------+
# | BASH : Modifying Shell Behaviour
# | (https://www.gnu.org/software/bash/manual)
# +----------------------------------------------------------+
# Treat unset variables and parameters other than the special
# parameters ‘@’ or ‘*’ as an error when performing parameter
# expansion. An error message will be written to the standard
# error, and a non-interactive shell will exit.
set -o nounset

# Exit immediately if a pipeline returns a non-zero status.
set -o errexit

# If set, the return value of a pipeline is the value of the
# last (rightmost) command to exit with a non-zero status, or
# zero if all commands in the pipeline exit successfully.
set -o pipefail

# +----------------------------------------------------------+
# | This script is one of the common set of commands run as
# | part of a continuous integration build pipeline.
# | These scrips are named using the following scheme:
# |
# | [build_type]-[(optional)build_type qualifier]-[build|test|report|upload].sh
# |
# | Of course, libuavcan is a header-only distribution so
# | CI is used to verify and test rather than package and
# | deploy (i.e. There's really no 'I' going on).
# +----------------------------------------------------------+

mkdir -p build_ci_native_gcc
pushd build_ci_native_gcc
# GCC is our reference compiler since it does a better job with
# coverage metrics.
cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-native.cmake \
-DLIBUAVCAN_EXT_FOLDER=build_ci_ext_gcc \
-DLIBUAVCAN_INTROSPECTION_ENABLE_ASSERT=1 \
..

make -j4

# We use ctest to run our compile tests.
ctest -VV

# This builds, runs, and reports on our native unit tests.
# TODO: when we integrate with coveralls or codacy run make cov_info
# instead to skip the genhtml step.
make cov_all

make docs

popd
3 changes: 3 additions & 0 deletions ci/ontarget-s32k-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/gcc-arm-none-eabi.cmake \

make -j4

# We use ctest to run our compile tests.
ctest -VV

popd
6 changes: 5 additions & 1 deletion cmake/modules/Findlcov.cmake
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@


find_program(LCOV lcov)
find_program(GENHTML genhtml)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(lcov
LCOV_FOUND
)

find_package_handle_standard_args(genhtml
GENHTML_FOUND
)
6 changes: 6 additions & 0 deletions cmake/toolchains/clang-native.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_ASM_COMPILER clang)

# Signal to unit tests that the coverage data will be generated by
# clang so they should try to use llvm-cov if it's available.
# Things are weird between gcov and llvm-cov right now but this
# seems to work in our Ubuntu 18 Docker container, so...?
set(LIBUAVCAN_USE_LLVM_COV ON)
8 changes: 8 additions & 0 deletions cmake/toolchains/gcc-native.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Toolchain for using gcc on what-ever-platform-this-is (aka "native").
#
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_ASM_COMPILER gcc)
22 changes: 0 additions & 22 deletions libuavcan/include/libuavcan/build_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,4 @@

/** @} */ // end of macros_platform

// +--------------------------------------------------------------------------+
/** @defgroup macros_features Feature macros.
*
* Macros to configure what features to enable in the library. Some features
* may change the amount of memory or CPU required at runtime so read the
* documentation for each carefully.
* @{
*/
/**
* Enable support for CAN-FD.
*
* Enabling this feature will increase the size of many memory buffers to
* accommodate the larger frame size of CAN-FD. This larger payload size
* translates into larger message sizes which may impact performance where
* message payloads must be transferred through system memory.
*/
#ifndef LIBUAVCAN_FEATURE_ENABLE_FD
# define LIBUAVCAN_FEATURE_ENABLE_FD 1
#endif

/** @} */ // end of macors_features

#endif // LIBUAVCAN_BUILD_CONFIG_HPP_INCLUDED
103 changes: 0 additions & 103 deletions libuavcan/include/libuavcan/bus/can.hpp

This file was deleted.

Loading