Skip to content

Commit

Permalink
CMake Implementation Selection (#2384)
Browse files Browse the repository at this point in the history
* Adding implementation in CMake and documentation

* Spelling and engaging actions for refactor/osal branch

* Adding CMake unit test for implementations and overrides

* Review fixes

* Fixing broken deployment UT sets

* Corrections for cmake UTs

* Removing long-running feature branch

* sp

* Correcting FppTest failures

* Review feedback fixes
  • Loading branch information
LeStarch authored Nov 29, 2023
1 parent 0e66d8d commit 0ed8e0b
Show file tree
Hide file tree
Showing 45 changed files with 424 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
push:
branches: [ master, devel ]
pull_request:
branches: [ master, devel, release/v3.0.0 ]
branches: [ master, devel ]
paths-ignore:
- 'docs/**'
- '**.md'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test-rpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
push:
branches: [ master, devel ]
pull_request:
branches: [ master, devel, release/v3.0.0 ]
branches: [ master, devel ]
paths-ignore:
- 'docs/**'
- '**.md'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
push:
branches: [ master, devel ]
pull_request:
branches: [ master, devel, release/v3.0.0 ]
branches: [ master, devel ]
paths-ignore:
- 'docs/**'
- '**.md'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cpplint-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [master, devel]
pull_request:
# The branches below must be a subset of the branches above
branches: [master, devel]
branches: [master, devel ]
paths-ignore:
- 'docs/**'
- '**.md'
Expand Down
2 changes: 2 additions & 0 deletions FppTest/component/active/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/../types/FormalParamTypes.cpp"
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"
)
# Needed for compiling files using Tester.hpp from outside the directory
include_directories("${CMAKE_CURRENT_LIST_DIR}/test/ut")
register_fprime_ut()
2 changes: 1 addition & 1 deletion FppTest/component/active/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "STest/Pick/Pick.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Construction and destruction
Expand Down
2 changes: 2 additions & 0 deletions FppTest/component/passive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/../types/FormalParamTypes.cpp"
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"
)
# Needed for compiling files using Tester.hpp from outside the directory
include_directories("${CMAKE_CURRENT_LIST_DIR}/test/ut")
register_fprime_ut()
2 changes: 1 addition & 1 deletion FppTest/component/passive/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "STest/Pick/Pick.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Construction and destruction
Expand Down
2 changes: 2 additions & 0 deletions FppTest/component/queued/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@ set(UT_SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/../types/FormalParamTypes.cpp"
"${CMAKE_CURRENT_LIST_DIR}/../../utils/Utils.cpp"
)
# Needed for compiling files using Tester.hpp from outside the directory
include_directories("${CMAKE_CURRENT_LIST_DIR}/test/ut")
register_fprime_ut()
2 changes: 1 addition & 1 deletion FppTest/component/queued/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// ======================================================================

#include "STest/Pick/Pick.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Construction and destruction
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/AsyncPortTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// ======================================================================

#include "PortTests.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

PORT_TEST_DEFS_ASYNC
2 changes: 1 addition & 1 deletion FppTest/component/tests/AsyncTesterHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

void Tester ::connectAsyncPorts() {
// arrayArgsAsync
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/CmdTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Command test declarations
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/EventTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Event tests
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/InternalInterfaceTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

#include "Fw/Comp/QueuedComponentBase.hpp"

Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/InternalInterfaceTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Internal interface test declarations
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/ParamTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Parameter tests
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/PortTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ======================================================================

#include "PortTests.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

PORT_TEST_DEFS(Sync)
PORT_TEST_DEFS(Guarded)
2 changes: 1 addition & 1 deletion FppTest/component/tests/PortTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "FppTest/component/active/SerialPortIndexEnumAc.hpp"
#include "FppTest/component/active/TypedPortIndexEnumAc.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Port test declarations
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/TesterHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Handlers for typed from ports
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/TesterHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
// ======================================================================

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Helper methods
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/TimeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "Fw/Time/Time.hpp"
#include "STest/Pick/Pick.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

// ----------------------------------------------------------------------
// Time test
Expand Down
2 changes: 1 addition & 1 deletion FppTest/component/tests/TlmTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
// ======================================================================

#include "TlmTests.hpp"
#include "test/ut/Tester.hpp"
#include "Tester.hpp"

TLM_TEST_DEFS
2 changes: 1 addition & 1 deletion FppTest/typed_tests/ComponentTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef FPP_TEST_COMPONENT_TEST_HPP
#define FPP_TEST_COMPONENT_TEST_HPP

#include "test/ut/Tester.hpp"
#include "Tester.hpp"

#include "gtest/gtest.h"

Expand Down
2 changes: 1 addition & 1 deletion FppTest/typed_tests/PortTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef FPP_TEST_PORT_TEST_HPP
#define FPP_TEST_PORT_TEST_HPP

#include "test/ut/Tester.hpp"
#include "Tester.hpp"
#include "FppTest/component/active/TypedPortIndexEnumAc.hpp"

#include "gtest/gtest.h"
Expand Down
2 changes: 1 addition & 1 deletion Svc/GroundInterface/test/ut/GroundInterfaceTester.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef TESTER_HPP
#define TESTER_HPP

#include <ComPacket.hpp>
#include <Fw/Com/ComPacket.hpp>
#include "GroundInterfaceGTestBase.hpp"
#include "Svc/GroundInterface/GroundInterface.hpp"

Expand Down
71 changes: 68 additions & 3 deletions cmake/API.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#
####
include_guard()
include(utilities)
set(FPRIME_TARGET_LIST "" CACHE INTERNAL "FPRIME_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_UT_TARGET_LIST "" CACHE INTERNAL "FPRIME_UT_TARGET_LIST: custom fprime targets" FORCE)
set(FPRIME_AUTOCODER_TARGET_LIST "" CACHE INTERNAL "FPRIME_AUTOCODER_TARGET_LIST: custom fprime targets" FORCE)
Expand Down Expand Up @@ -96,6 +97,10 @@ function(add_fprime_subdirectory FP_SOURCE_DIR)
get_module_name("${FP_SOURCE_DIR}")
set(FPRIME_CURRENT_MODULE "${MODULE_NAME}")

# Unset all variables that carry special meaning as it is dangerous to pass them through
init_variables(SOURCE_FILES MOD_DEPS UT_SOURCE_FILES UT_MOD_DEPS EXECUTABLE_NAME)


# Check if the binary and source directory are in agreement. If they agree, then normally add
# the directory, as no adjustments need be made.
get_filename_component(CBD_NAME "${CMAKE_CURRENT_BINARY_DIR}" NAME)
Expand Down Expand Up @@ -545,7 +550,7 @@ endmacro(register_fprime_list_helper)
# the same thing. Note: make sure the directory is on the CMake include path to use the second form.
#
# **TARGET_FILE_PATH:** include path or file path file defining above functions
###
####
macro(register_fprime_build_autocoder TARGET_FILE_PATH)
# Normal registered targets don't run in prescan
if (CMAKE_DEBUG_OUTPUT)
Expand All @@ -554,12 +559,72 @@ macro(register_fprime_build_autocoder TARGET_FILE_PATH)
register_fprime_list_helper("${TARGET_FILE_PATH}" FPRIME_AUTOCODER_TARGET_LIST)
endmacro(register_fprime_build_autocoder)


####
# Function `require_fprime_implementation`:
#
# Designates that the current module requires a separate implementation in order for it to function properly. As an
# example, Os requires an implementation of `Os_Task`. These implementations must be set via
# `choose_fprime_implementation` in the platform and may be overridden in in the executable/deployment.
#
# **IMPLEMENTATION:** implementation module name that must be covered
####
function(require_fprime_implementation IMPLEMENTATION)
resolve_dependencies(IMPLEMENTATION "${IMPLEMENTATION}")
append_list_property("${IMPLEMENTATION}" GLOBAL PROPERTY "REQUIRED_IMPLEMENTATIONS")
append_list_property("${FPRIME_CURRENT_MODULE}" GLOBAL PROPERTY "${IMPLEMENTATION}_REQUESTERS")
endfunction()

####
# Function `register_fprime_implementation`:
#
# Designates that the given implementor implements the required implementation. As an example Os_Task_Posix implements
# Os_Task. These implementations must be set via
## `choose_fprime_implementation` in the platform and may be overridden in in the executable/deployment.
#
# **IMPLEMENTATION:** implementation module name that is implemented by IMPLEMENTOR
# **IMPLEMENTOR:** implementor of IMPLEMENTATION
####
function(register_fprime_implementation IMPLEMENTATION IMPLEMENTOR)
resolve_dependencies(IMPLEMENTATION "${IMPLEMENTATION}")
resolve_dependencies(IMPLEMENTOR "${IMPLEMENTOR}")
append_list_property("${IMPLEMENTOR}" GLOBAL PROPERTY "${IMPLEMENTATION}_IMPLEMENTORS")
endfunction()
####
# Function `choose_fprime_implementation`:
#
# Designates that the given implementor is the selected implementor for the needed implementation. Platforms must call
# this function once for each defined IMPLEMENTATION. An executable/deployment/unit-test may call this function to set
# a specific implementor for any needed implementation
#
# **IMPLEMENTATION:** implementation module name that is implemented by IMPLEMENTOR
# **IMPLEMENTOR:** implementor of IMPLEMENTATION
####
function(choose_fprime_implementation IMPLEMENTATION IMPLEMENTOR)
resolve_dependencies(IMPLEMENTATION "${IMPLEMENTATION}")
resolve_dependencies(IMPLEMENTOR "${IMPLEMENTOR}")
# Check for passed in module name
if (ARGC EQUAL 3)
set(ACTIVE_MODULE "${ARGV2}")
elseif (FPRIME_CURRENT_MODULE)
set(ACTIVE_MODULE "${FPRIME_CURRENT_MODULE}")
elseif(FPRIME_PLATFORM)
set(ACTIVE_MODULE "${FPRIME_PLATFORM}")
else()
message(FATAL_ERROR "Cannot call 'choose_fprime_implementation' outside an fprime module or platform CMake file")
endif()
set_property(GLOBAL PROPERTY "${IMPLEMENTATION}_${ACTIVE_MODULE}" "${IMPLEMENTOR}")
append_list_property("${IMPLEMENTATION}" GLOBAL PROPERTY "REQUIRED_IMPLEMENTATIONS")
append_list_property("${IMPLEMENTOR}" GLOBAL PROPERTY "${IMPLEMENTATION}_IMPLEMENTORS")
endfunction()

#### Documentation links
# Next Topics:
# - Setting Options: [Options](Options.md) are used to vary a CMake build.
# - Adding Deployment: [Deployments](deployment.md) create fprime builds.
# - Adding Module: [Modules](module.md) register fprime Ports, Components, etc.
# - Adding Deployments: [Deployments](deployment.md) create fprime builds.
# - Adding Modules: [Modules](module.md) register fprime Ports, Components, etc.
# - Creating Toolchains: [Toolchains](toolchain.md) setup standard CMake Cross-Compiling.
# - Adding Platforms: [Platforms](platform.md) help fprime set Cross-Compiling specific items.
# - Adding Targets: [Targets](targets.md) for help defining custom build targets
# - Implementation Packages Design: [Implementation Packages](/Design/package-implementor.md)
####
Loading

0 comments on commit 0ed8e0b

Please sign in to comment.