From 315fc29a684fb3f85ae93476e55a0a8f81720bc3 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 19 May 2023 12:38:44 +0100 Subject: [PATCH 1/3] feat(codigin_guidelines): add introduction Signed-off-by: Jose Martins --- source/development/coding_style.rst | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/development/coding_style.rst b/source/development/coding_style.rst index eeecac9..b893e20 100644 --- a/source/development/coding_style.rst +++ b/source/development/coding_style.rst @@ -1,4 +1,13 @@ .. _coding_guidelines: -Coding Guidelines and Style -=========================== +Coding Guidelines +================= + +This document specifies a set of coding guidelines including code style, +formatting and file structuring and organization that shall be applied when +contributing code to the Bao project. We strive so that most of the guidelines +can be automatically checked or even enforced by the CI pipeline and try to +minimize guidelines which can not be automatically addressed. However, in the +few instances this is not possible, responsibility falls upon code reviewers +and maintainers to uphold these guidelines are applied as much as possible. + From 6709d42b22f474216966424f0034d424aa5429a1 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 19 May 2023 12:39:38 +0100 Subject: [PATCH 2/3] feat(coding_guidelines): add C lang intro and scaffold Signed-off-by: Jose Martins --- source/development/coding_style.rst | 72 ++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/source/development/coding_style.rst b/source/development/coding_style.rst index b893e20..1f1a395 100644 --- a/source/development/coding_style.rst +++ b/source/development/coding_style.rst @@ -3,11 +3,69 @@ Coding Guidelines ================= -This document specifies a set of coding guidelines including code style, -formatting and file structuring and organization that shall be applied when -contributing code to the Bao project. We strive so that most of the guidelines -can be automatically checked or even enforced by the CI pipeline and try to -minimize guidelines which can not be automatically addressed. However, in the -few instances this is not possible, responsibility falls upon code reviewers -and maintainers to uphold these guidelines are applied as much as possible. +This document specifies a set of coding guidelines, including code style, +formatting, file structuring and organization that shall be applied when +contributing code to the Bao project. We strive to ensure that most of the +guidelines can be automatically checked or even enforced by the CI pipeline and +minimize guidelines that can not be automatically addressed. In cases where it +is not feasible to automatically enforce certain guidelines, the responsibility +lies with the code reviewers and maintainers to ensure that these guidelines +are adhered to as closely as possible. +C Language +---------- + +The coding style and guidelines for C development are heavily influenced and +constrained by the MISRA C:2012 guidelines, which should take precedence above +all others in this document or elsewhere. + +Compiler Configuration +********************** + +Directory and file Structure +**************************** + +Pre-processor directives and macros +*********************************** + +Header Files +************ + +Variable Declarations, Qualifiers and Initializations +***************************************************** + +Functions +********* + +Statements +********** + +Expressions +*********** + +Literals +******** + +Identifiers and Naming +********************** + +Inline Assembly +*************** + +Compiler Directives, Intrinsic and Attributes +********************************************** + +Assertion, Error Handling and Sanity checking +********************************************* + +Comments, Documentation and License +*********************************** + +Coding Style and Formatting +*************************** + +Keyword Usage +************* + +Libraries and Headers +********************* From 8eff74f22bdeabacfb958d0a9ff36c561e64b180 Mon Sep 17 00:00:00 2001 From: Jose Martins Date: Fri, 2 Jun 2023 12:28:36 +0100 Subject: [PATCH 3/3] feat(coding_guidelines): define base compiler options Signed-off-by: Jose Martins --- source/development/coding_style.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/source/development/coding_style.rst b/source/development/coding_style.rst index 1f1a395..8e8b7d5 100644 --- a/source/development/coding_style.rst +++ b/source/development/coding_style.rst @@ -19,9 +19,35 @@ The coding style and guidelines for C development are heavily influenced and constrained by the MISRA C:2012 guidelines, which should take precedence above all others in this document or elsewhere. +All C projects should support either the GCC compiler, the Clang compiler or +both. If one compiler is supported for given project, it must be so for all +supported target architectures. + +For reach guideline we try to provide a set of compiler options which enforce +the rule, a mapping to a MISRA C:2012 and tools available in the :ref:`CI +infrastructure ` that can check if this guideline is being adhered to. + Compiler Configuration ********************** +- The C11 version shall be used. + +Compiler options: `-std=c11`. +MISRA C:2012 : R1.1 + +- No language extensions shall be allowed. + +Compiler options: `-pedantic -pedantic-errors`. +MISRA C:2012 : R1.1 + +- Treat all warnings as errors so no warnings can be ignored. + +Compiler options: `-Werrors`. + +- Enable all recommended warnings. + +Compiler options: `-Wall -Wextra`. + Directory and file Structure ****************************