From 96148c756cf3f5270374335022b594a80a01ac45 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 08:53:04 +0000 Subject: [PATCH 01/10] Move GCC compile option to GCC folder with toolchain option --- CMakeLists.txt | 43 +++-------------------- portable/GCC/kernel_compile_options.cmake | 37 +++++++++++++++++++ 2 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 portable/GCC/kernel_compile_options.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d9ddb7ed78..51f6b3dcd2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,46 +233,11 @@ endif() add_library(freertos_kernel STATIC) -######################################################################## -# Overall Compile Options -# Note the compile option strategy is to error on everything and then -# Per library opt-out of things that are warnings/errors. -# This ensures that no matter what strategy for compilation you take, the -# builds will still occur. -# -# Only tested with GNU and Clang. -# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID -# Naming of compilers translation map: -# -# FreeRTOS | CMake -# ------------------- -# CCS | ?TBD? -# GCC | GNU, Clang, *Clang Others? -# IAR | IAR -# Keil | ARMCC -# MSVC | MSVC # Note only for MinGW? -# Renesas | ?TBD? - -target_compile_options(freertos_kernel PRIVATE - ### Gnu/Clang C Options - $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics> - - $<$:-Wall> - $<$:-Wextra> - $<$:-Wpedantic> - $<$:-Werror> - $<$:-Wconversion> - $<$:-Weverything> - - # Suppressions required to build clean with clang. - $<$:-Wno-unused-macros> - $<$:-Wno-padded> - $<$:-Wno-missing-variable-declarations> - $<$:-Wno-covered-switch-default> - $<$:-Wno-cast-align> -) +if("${FREERTOS_KERNEL_TOOLCHAIN}" STREQUAL "GCC") + include( ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/kernel_compile_options.cmake ) +endif() +target_compile_options(freertos_kernel PRIVATE ${freertos_kernel_compile_option} ) ######################################################################## add_subdirectory(include) diff --git a/portable/GCC/kernel_compile_options.cmake b/portable/GCC/kernel_compile_options.cmake new file mode 100644 index 0000000000..e6fc3c1107 --- /dev/null +++ b/portable/GCC/kernel_compile_options.cmake @@ -0,0 +1,37 @@ +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. +# +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? +set( freertos_kernel_compile_option + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + # $<$:-Werror> + $<$:-Wconversion> + $<$:-Weverything> + + # Suppressions required to build clean with clang. + $<$:-Wno-unused-macros> + $<$:-Wno-padded> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-covered-switch-default> + $<$:-Wno-cast-align> ) \ No newline at end of file From d4376c22182ce8a003c449bfb13f65a96c6463e8 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 08:58:54 +0000 Subject: [PATCH 02/10] Add CI flow to build cmake example --- .github/workflows/kernel-demos.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/kernel-demos.yml b/.github/workflows/kernel-demos.yml index 62970a171a..5bc196fcc2 100644 --- a/.github/workflows/kernel-demos.yml +++ b/.github/workflows/kernel-demos.yml @@ -90,6 +90,29 @@ jobs: working-directory: FreeRTOS/Demo/Posix_GCC run: make -j COVERAGE_TEST=1 + CMake-Example: + name: CMake Example with Native GCC + runs-on: ubuntu-latest + steps: + # Checkout user pull request changes + - name: Checkout Repository + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install GCC + shell: bash + run: | + sudo apt-get -y update + sudo apt-get -y install build-essential + + - name: Build CMake Example Demo + shell: bash + working-directory: examples/cmake_example + run: | + cmake -S . -Bbuild -DFREERTOS_KERNEL_TOOLCHAIN=GCC + cmake --build build + MSP430-GCC: name: GNU MSP430 Toolchain runs-on: ubuntu-latest From c861ea1c47df28d10bc0ecf96917ca9885724abc Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 09:14:05 +0000 Subject: [PATCH 03/10] Fix CI --- .github/workflows/kernel-demos.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/kernel-demos.yml b/.github/workflows/kernel-demos.yml index 5bc196fcc2..a2be902ee7 100644 --- a/.github/workflows/kernel-demos.yml +++ b/.github/workflows/kernel-demos.yml @@ -96,9 +96,7 @@ jobs: steps: # Checkout user pull request changes - name: Checkout Repository - - uses: actions/checkout@v3 - with: - submodules: recursive + uses: actions/checkout@v3 - name: Install GCC shell: bash From 98caa8599df92d134631fdc5ff25d7b614f03516 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 09:34:53 +0000 Subject: [PATCH 04/10] formatting && enable Werror --- CMakeLists.txt | 1 - portable/GCC/kernel_compile_options.cmake | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f6b3dcd2..4354974296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,7 +230,6 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_ " freertos_kernel_include)") endif() - add_library(freertos_kernel STATIC) if("${FREERTOS_KERNEL_TOOLCHAIN}" STREQUAL "GCC") diff --git a/portable/GCC/kernel_compile_options.cmake b/portable/GCC/kernel_compile_options.cmake index e6fc3c1107..8463c1e3e1 100644 --- a/portable/GCC/kernel_compile_options.cmake +++ b/portable/GCC/kernel_compile_options.cmake @@ -17,7 +17,7 @@ # Keil | ARMCC # MSVC | MSVC # Note only for MinGW? # Renesas | ?TBD? -set( freertos_kernel_compile_option +set( freertos_kernel_compile_option ### Gnu/Clang C Options $<$:-fdiagnostics-color=always> $<$:-fcolor-diagnostics> @@ -25,7 +25,7 @@ set( freertos_kernel_compile_option $<$:-Wall> $<$:-Wextra> $<$:-Wpedantic> - # $<$:-Werror> + $<$:-Werror> $<$:-Wconversion> $<$:-Weverything> @@ -34,4 +34,4 @@ set( freertos_kernel_compile_option $<$:-Wno-padded> $<$:-Wno-missing-variable-declarations> $<$:-Wno-covered-switch-default> - $<$:-Wno-cast-align> ) \ No newline at end of file + $<$:-Wno-cast-align> ) From e14502786b4b9579bf3b3406bb2b0a9450b4a914 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 09:37:28 +0000 Subject: [PATCH 05/10] Add useless variable to test CI --- event_groups.c | 1 + 1 file changed, 1 insertion(+) diff --git a/event_groups.c b/event_groups.c index 556637b4cd..86f5f670fc 100644 --- a/event_groups.c +++ b/event_groups.c @@ -193,6 +193,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, EventGroup_t * pxEventBits = xEventGroup; BaseType_t xAlreadyYielded; BaseType_t xTimeoutOccurred = pdFALSE; + BaseType_t useless; traceENTER_xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); From 1772d365f19cb6869efe9e92b5ad962c366c29d4 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 09:54:06 +0000 Subject: [PATCH 06/10] revert useless variable --- event_groups.c | 1 - 1 file changed, 1 deletion(-) diff --git a/event_groups.c b/event_groups.c index 86f5f670fc..556637b4cd 100644 --- a/event_groups.c +++ b/event_groups.c @@ -193,7 +193,6 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup, EventGroup_t * pxEventBits = xEventGroup; BaseType_t xAlreadyYielded; BaseType_t xTimeoutOccurred = pdFALSE; - BaseType_t useless; traceENTER_xEventGroupSync( xEventGroup, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); From 5774afcd744c80cab814729045a887468945eb14 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 10:08:32 +0000 Subject: [PATCH 07/10] Add comments as examples. --- CMakeLists.txt | 4 ++++ examples/cmake_example/CMakeLists.txt | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4354974296..0c9ad2d993 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,10 @@ endif() add_library(freertos_kernel STATIC) +# To use default compile options with GCC compiler, you can compile this CMakeLists.txt with +# "-DFREERTOS_KERNEL_TOOLCHAIN=GCC" option or you can also set freertos_kernel_compile_option +# before add_subdirectory() like comments in +# https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/examples/cmake_example/CMakeLists.txt. if("${FREERTOS_KERNEL_TOOLCHAIN}" STREQUAL "GCC") include( ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/kernel_compile_options.cmake ) endif() diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index 2bb317296e..351cb8dab1 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -18,6 +18,29 @@ set(FREERTOS_HEAP "4" CACHE STRING "" FORCE) # Select the native compile PORT set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE) +# Use default options by adding "-DFREERTOS_KERNEL_TOOLCHAIN=GCC" in cmake command OR +# provide your compile options by setting freertos_kernel_compile_option. +# +# An example to set freertos_kernel_compile_option in application cmake file. +# set( freertos_kernel_compile_option +# ### Gnu/Clang C Options +# $<$:-fdiagnostics-color=always> +# $<$:-fcolor-diagnostics> + +# $<$:-Wall> +# $<$:-Wextra> +# $<$:-Wpedantic> +# $<$:-Werror> +# $<$:-Wconversion> +# $<$:-Weverything> + +# # Suppressions required to build clean with clang. +# $<$:-Wno-unused-macros> +# $<$:-Wno-padded> +# $<$:-Wno-missing-variable-declarations> +# $<$:-Wno-covered-switch-default> +# $<$:-Wno-cast-align> ) + # Adding the FreeRTOS-Kernel subdirectory add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel) From 74b9f57b15dd23c48e2c06e9adb2eab0cbfe3157 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 11:08:37 +0000 Subject: [PATCH 08/10] Remove default compile options. --- .github/workflows/kernel-demos.yml | 2 +- CMakeLists.txt | 10 +--- examples/cmake_example/CMakeLists.txt | 58 +++++++++++++++-------- portable/GCC/kernel_compile_options.cmake | 37 --------------- 4 files changed, 41 insertions(+), 66 deletions(-) delete mode 100644 portable/GCC/kernel_compile_options.cmake diff --git a/.github/workflows/kernel-demos.yml b/.github/workflows/kernel-demos.yml index a2be902ee7..7d83d74821 100644 --- a/.github/workflows/kernel-demos.yml +++ b/.github/workflows/kernel-demos.yml @@ -108,7 +108,7 @@ jobs: shell: bash working-directory: examples/cmake_example run: | - cmake -S . -Bbuild -DFREERTOS_KERNEL_TOOLCHAIN=GCC + cmake -S . -B build cmake --build build MSP430-GCC: diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c9ad2d993..9c42b947e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,14 +232,8 @@ endif() add_library(freertos_kernel STATIC) -# To use default compile options with GCC compiler, you can compile this CMakeLists.txt with -# "-DFREERTOS_KERNEL_TOOLCHAIN=GCC" option or you can also set freertos_kernel_compile_option -# before add_subdirectory() like comments in -# https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/examples/cmake_example/CMakeLists.txt. -if("${FREERTOS_KERNEL_TOOLCHAIN}" STREQUAL "GCC") - include( ${CMAKE_CURRENT_LIST_DIR}/portable/GCC/kernel_compile_options.cmake ) -endif() - +# Set freertos_kernel_compile_option before add_subdirectory() like +# https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/examples/cmake_example/CMakeLists.txt does. target_compile_options(freertos_kernel PRIVATE ${freertos_kernel_compile_option} ) ######################################################################## diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index 351cb8dab1..8b2023efa0 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -18,28 +18,46 @@ set(FREERTOS_HEAP "4" CACHE STRING "" FORCE) # Select the native compile PORT set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE) -# Use default options by adding "-DFREERTOS_KERNEL_TOOLCHAIN=GCC" in cmake command OR -# provide your compile options by setting freertos_kernel_compile_option. +######################################################################## +# Overall Compile Options +# Note the compile option strategy is to error on everything and then +# Per library opt-out of things that are warnings/errors. +# This ensures that no matter what strategy for compilation you take, the +# builds will still occur. # +# Only tested with GNU and Clang. +# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID +# Naming of compilers translation map: +# +# FreeRTOS | CMake +# ------------------- +# CCS | ?TBD? +# GCC | GNU, Clang, *Clang Others? +# IAR | IAR +# Keil | ARMCC +# MSVC | MSVC # Note only for MinGW? +# Renesas | ?TBD? +# +# Provide your compile options by setting freertos_kernel_compile_option. # An example to set freertos_kernel_compile_option in application cmake file. -# set( freertos_kernel_compile_option -# ### Gnu/Clang C Options -# $<$:-fdiagnostics-color=always> -# $<$:-fcolor-diagnostics> - -# $<$:-Wall> -# $<$:-Wextra> -# $<$:-Wpedantic> -# $<$:-Werror> -# $<$:-Wconversion> -# $<$:-Weverything> - -# # Suppressions required to build clean with clang. -# $<$:-Wno-unused-macros> -# $<$:-Wno-padded> -# $<$:-Wno-missing-variable-declarations> -# $<$:-Wno-covered-switch-default> -# $<$:-Wno-cast-align> ) +set( freertos_kernel_compile_option + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> + + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Wconversion> + $<$:-Weverything> + + # Suppressions required to build clean with clang. + $<$:-Wno-unused-macros> + $<$:-Wno-padded> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-covered-switch-default> + $<$:-Wno-cast-align> ) # Adding the FreeRTOS-Kernel subdirectory add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel) diff --git a/portable/GCC/kernel_compile_options.cmake b/portable/GCC/kernel_compile_options.cmake deleted file mode 100644 index 8463c1e3e1..0000000000 --- a/portable/GCC/kernel_compile_options.cmake +++ /dev/null @@ -1,37 +0,0 @@ -######################################################################## -# Overall Compile Options -# Note the compile option strategy is to error on everything and then -# Per library opt-out of things that are warnings/errors. -# This ensures that no matter what strategy for compilation you take, the -# builds will still occur. -# -# Only tested with GNU and Clang. -# Other options are https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html#variable:CMAKE_%3CLANG%3E_COMPILER_ID -# Naming of compilers translation map: -# -# FreeRTOS | CMake -# ------------------- -# CCS | ?TBD? -# GCC | GNU, Clang, *Clang Others? -# IAR | IAR -# Keil | ARMCC -# MSVC | MSVC # Note only for MinGW? -# Renesas | ?TBD? -set( freertos_kernel_compile_option - ### Gnu/Clang C Options - $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics> - - $<$:-Wall> - $<$:-Wextra> - $<$:-Wpedantic> - $<$:-Werror> - $<$:-Wconversion> - $<$:-Weverything> - - # Suppressions required to build clean with clang. - $<$:-Wno-unused-macros> - $<$:-Wno-padded> - $<$:-Wno-missing-variable-declarations> - $<$:-Wno-covered-switch-default> - $<$:-Wno-cast-align> ) From a86f75286fae2019f498a2e8f008574a44e5f50a Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 11:10:17 +0000 Subject: [PATCH 09/10] Formatting --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c42b947e3..c2e142cf06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,7 @@ endif() add_library(freertos_kernel STATIC) -# Set freertos_kernel_compile_option before add_subdirectory() like +# Set freertos_kernel_compile_option before add_subdirectory() like # https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/examples/cmake_example/CMakeLists.txt does. target_compile_options(freertos_kernel PRIVATE ${freertos_kernel_compile_option} ) From 695b3a0fba0485a5fecdc389c4c230315dbf2c57 Mon Sep 17 00:00:00 2001 From: ActoryOu Date: Mon, 30 Oct 2023 11:20:21 +0000 Subject: [PATCH 10/10] Remove compile option in kernel cmake and put the sample in examples/cmake_example --- CMakeLists.txt | 4 --- examples/cmake_example/CMakeLists.txt | 40 +++++++++++++-------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2e142cf06..30172870ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,10 +232,6 @@ endif() add_library(freertos_kernel STATIC) -# Set freertos_kernel_compile_option before add_subdirectory() like -# https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/examples/cmake_example/CMakeLists.txt does. -target_compile_options(freertos_kernel PRIVATE ${freertos_kernel_compile_option} ) - ######################################################################## add_subdirectory(include) add_subdirectory(portable) diff --git a/examples/cmake_example/CMakeLists.txt b/examples/cmake_example/CMakeLists.txt index 8b2023efa0..85329678de 100644 --- a/examples/cmake_example/CMakeLists.txt +++ b/examples/cmake_example/CMakeLists.txt @@ -18,6 +18,9 @@ set(FREERTOS_HEAP "4" CACHE STRING "" FORCE) # Select the native compile PORT set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE) +# Adding the FreeRTOS-Kernel subdirectory +add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel) + ######################################################################## # Overall Compile Options # Note the compile option strategy is to error on everything and then @@ -37,30 +40,25 @@ set(FREERTOS_PORT "TEMPLATE" CACHE STRING "" FORCE) # Keil | ARMCC # MSVC | MSVC # Note only for MinGW? # Renesas | ?TBD? -# -# Provide your compile options by setting freertos_kernel_compile_option. -# An example to set freertos_kernel_compile_option in application cmake file. -set( freertos_kernel_compile_option - ### Gnu/Clang C Options - $<$:-fdiagnostics-color=always> - $<$:-fcolor-diagnostics> - $<$:-Wall> - $<$:-Wextra> - $<$:-Wpedantic> - $<$:-Werror> - $<$:-Wconversion> - $<$:-Weverything> +target_compile_options(freertos_kernel PRIVATE + ### Gnu/Clang C Options + $<$:-fdiagnostics-color=always> + $<$:-fcolor-diagnostics> - # Suppressions required to build clean with clang. - $<$:-Wno-unused-macros> - $<$:-Wno-padded> - $<$:-Wno-missing-variable-declarations> - $<$:-Wno-covered-switch-default> - $<$:-Wno-cast-align> ) + $<$:-Wall> + $<$:-Wextra> + $<$:-Wpedantic> + $<$:-Werror> + $<$:-Wconversion> + $<$:-Weverything> -# Adding the FreeRTOS-Kernel subdirectory -add_subdirectory(${FREERTOS_KERNEL_PATH} FreeRTOS-Kernel) + # Suppressions required to build clean with clang. + $<$:-Wno-unused-macros> + $<$:-Wno-padded> + $<$:-Wno-missing-variable-declarations> + $<$:-Wno-covered-switch-default> + $<$:-Wno-cast-align> ) add_executable(${PROJECT_NAME} main.c