Skip to content

Commit

Permalink
Fix nasa#2507, add EDS cmake hooks
Browse files Browse the repository at this point in the history
Adds CFE_EDS_ENABLED_BUILD option at the top level, along with
other logic that is tied in only when this is set TRUE.

By default it is set to FALSE, so it does not change any existing
workflows yet.

Also added are the keys for two configuration values for reflecting
EDS DB objects (pointers) and some minor cleanup.
  • Loading branch information
jphickey committed Jan 31, 2024
1 parent 37f1d28 commit 64f9a63
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 15 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ project(CFE C)
# Allow unit tests to be added by any recipe
enable_testing()

# This switch determines whether to use EDS framework
# By default it is set OFF/false as this is a new/experimental feature.
option(CFE_EDS_ENABLED_BUILD "Use EDS framework" OFF)

# Always create directories to hold generated files/wrappers
# EDS makes signficant use of generated files. In non-EDS builds
# some headers and wrapper files are also generated. Directories
# may simply remain empty if not used/needed in the current config.
file(MAKE_DIRECTORY
"${CMAKE_BINARY_DIR}/eds"
"${CMAKE_BINARY_DIR}/obj"
"${CMAKE_BINARY_DIR}/inc"
"${CMAKE_BINARY_DIR}/src"
)

# Include the global routines
include("cmake/global_functions.cmake")

Expand Down Expand Up @@ -123,4 +138,3 @@ prepare()
foreach(SYSVAR ${TGTSYS_LIST})
process_arch(${SYSVAR})
endforeach(SYSVAR ${TGTSYS_LIST})

11 changes: 11 additions & 0 deletions cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ function(add_cfe_app APP_NAME APP_SRC_FILES)
add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN})
target_link_libraries(${APP_NAME} core_api)

# If using "local" EDS linkage, then link the app with the EDS library here.
# Note that the linker will only pull in the compilation unit that actually
# resolves an undefined symbol, which in this case would be the app-specific
# DATATYPE_DB object if one is referenced at all.
#
# By linking with the respective application like this, the net result is that
# only the _referenced_ EDS DBs (i.e. those for loaded apps) are held in memory.
if (CFE_EDS_ENABLED_BUILD AND CFE_EDS_LINK_MODE STREQUAL LOCAL)
target_link_libraries($(APP_NAME) cfe_edsdb_static)
endif()

# An "install" step is only needed for dynamic/runtime loaded apps
if (APP_DYNAMIC_TARGET_LIST)
cfs_app_do_install(${APP_NAME} ${APP_DYNAMIC_TARGET_LIST})
Expand Down
6 changes: 0 additions & 6 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ function(prepare)
add_definitions(-DSIMULATION=${SIMULATION})
endif (SIMULATION)

# Create directories to hold generated files/wrappers
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/eds")
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/obj")
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/inc")
file(MAKE_DIRECTORY "${MISSION_BINARY_DIR}/src")

# Certain runtime variables need to be "exported" to the subordinate build, such as
# the specific arch settings and the location of all the apps. This list is collected
# during this function execution and exported at the end.
Expand Down
38 changes: 38 additions & 0 deletions cmake/mission_defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,44 @@ set(MISSION_MODULE_SEARCH_PATH
set(osal_SEARCH_PATH ".")
set(psp_SEARCH_PATH ".")

# Account for differences when EDS is enabled
if(CFE_EDS_ENABLED_BUILD)

# Propagate the setting to a C preprocessor define of the same name
# The CFE_EDS_ENABLED_BUILD switch indicates that any
# compile-time preprocessor blocks should be enabled in this build
add_definitions(-DCFE_EDS_ENABLED_BUILD)

# The EDS database is an object (or set of objects) generated by the tools from the EDS files.
# This can be linked into CFE either as a whole (GLOBAL) or as part of each app (LOCAL).
#
# LOCAL mode may use less memory by only only including DB objects for the apps that are
# originating or terminating CFS message traffic, but GLOBAL mode is simpler as it ensures
# that the entire DB is accessible by any app, even for data definitions that are not its own.
#
# NOTE: If running CI/TO, SBN, or other "generic" apps that relay SB traffic (or otherwise
# handle data that may not have originated on the same CFE instance) then it is recommended
# to stay with GLOBAL mode.
set(CFE_EDS_LINK_MODE GLOBAL)

# The standard msg module is not used in EDS build, edslib provides an alternate
list(REMOVE_ITEM MISSION_CORE_MODULES msg)

list(APPEND MISSION_CORE_MODULES
"edslib"
"missionlib"
"edsmsg"
)

list(APPEND MISSION_MODULE_SEARCH_PATH
"tools/eds/cfecfs" # CFE/CFS modules and extensions from EdsLib
)

# edslib exists directly under tools/eds (EDS runtime libraries)
set(edslib_SEARCH_PATH "tools/eds")

endif(CFE_EDS_ENABLED_BUILD)

# Include "cfe_assert" library in all builds, because it is included
# in the default startup script. It should not have any effect if not
# used.
Expand Down
37 changes: 37 additions & 0 deletions cmake/target/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,43 @@ set(CFE_LINK_NORMAL_LIBS
${${TGTNAME}_STATIC_APPLIST}
)

# If EDS is enabled, then the generated dictionary objects are linked with CFE.
# This can be done statically or dynamically, depending on user preferences.
if (CFE_EDS_ENABLED_BUILD)
# Determine EDS object linking mode for final executable.
# This should be configured via the toolchain file,
# with the default being FALSE (static link)
if (CFE_EDS_LINK_MODE STREQUAL LOCAL)

# In local link mode, no static EDS object is linked
# The CFE_EDS_STATIC_DB_OBJECT macro will be NULL
target_compile_definitions(core-${TGTNAME} PRIVATE
CFE_EDS_STATIC_DB_OBJECT=NULL
)

else()

# In this mode the full EDS object is statically linked
# The CFE_EDS_STATIC_DB_OBJECT macro will be defined
target_compile_definitions(core-${TGTNAME} PRIVATE
CFE_EDS_STATIC_DB_OBJECT=EDS_DATABASE
)

# In addition, also pull in the runtime lib, which
# supports script language bindings and UI display
list(APPEND CFE_LINK_WHOLE_LIBS
edslib_runtime_static
)

endif()

list(APPEND CFE_LINK_WHOLE_LIBS
cfe_edsdb_static
cfe_missionlib_runtime_static
cfe_missionlib_interfacedb_static
)
endif(CFE_EDS_ENABLED_BUILD)

# Handle the list of "embedded files" that should be linked into CFE.
# These are arbitrary files in the mission config that are converted
# into C data structures and linked with the executable. This is
Expand Down
34 changes: 34 additions & 0 deletions cmake/target/inc/target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ typedef const struct
const void *Value;
} CFE_ConfigKeyValue_t;

/**
* The "EdsLib_DatabaseObject" is an abstract structure here.
*/
typedef struct EdsLib_DatabaseObject CFE_EdsDbObject_t;
typedef struct CFE_MissionLib_SoftwareBus_Interface CFE_SbIntfDbObject_t;

/**
* Core Flight Executive configuration information.
*/
Expand Down Expand Up @@ -196,6 +202,34 @@ typedef const struct
CFE_ConfigName_t * CoreModuleList; /**< List of CFE core support module names that are statically linked */
CFE_ConfigName_t
*StaticAppList; /**< List of additional CFS Applications that are statically linked into this binary */

/**
* Normal read-only EDS Database object
*
* This EDS DB object pointer is always initialized to be non-null.
* It is qualified as "const" and used for all EDS query requests.
*/
const CFE_EdsDbObject_t *EdsDb;

/**
* Dynamic EDS Database object
*
* This provides a writable (non-const) pointer to the same EDS object as above,
* but only when when dynamic EDS link mode is selected. It will be set NULL
* when static EDS link mode is selected.
*
* This can checked by runtime code to determine the EDS link mode. If it is
* NULL this means the EDS DB is fixed/static and no runtime registration is needed.
* If this pointer is non-null then the EDS DB is dynamic and runtime registration
* is needed.
*/
CFE_EdsDbObject_t *DynamicEdsDb;

/**
* Software bus interface EDS object (MsgId mappings)
*/
const CFE_SbIntfDbObject_t *SbIntfDb;

} Target_ConfigData;

/**
Expand Down
4 changes: 4 additions & 0 deletions modules/config/fsw/src/cfe_config_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ void CFE_Config_SetupBasicBuildInfo(void)
KeyVal = CFE_Config_FindTargetKeyValue(GLOBAL_CONFIGDATA.ModuleVersionList, "MISSION");
CFE_Config_SetString(CFE_CONFIGID_MISSION_SRCVER, KeyVal);

/* Global mission EDS runtime DB */
CFE_Config_SetObjPointer(CFE_CONFIGID_MISSION_EDS_DB, GLOBAL_CONFIGDATA.EdsDb);
CFE_Config_SetObjPointer(CFE_CONFIGID_MISSION_SBINTF_DB, GLOBAL_CONFIGDATA.SbIntfDb);

/* propagate the version numbers from version.h */
CFE_Config_SetValue(CFE_CONFIGID_CORE_VERSION_MAJOR, CFE_MAJOR_VERSION);
CFE_Config_SetValue(CFE_CONFIGID_CORE_VERSION_MINOR, CFE_MINOR_VERSION);
Expand Down
2 changes: 2 additions & 0 deletions modules/config/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(GENERATED_IDNAME_MAP_LIST)
list(APPEND CFE_CONFIG_IDS
MISSION_NAME
MISSION_SRCVER
MISSION_EDS_DB
MISSION_SBINTF_DB

CORE_VERSION_MAJOR
CORE_VERSION_MINOR
Expand Down
6 changes: 0 additions & 6 deletions modules/evs/fsw/src/cfe_evs_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ CFE_EVS_Global_t CFE_EVS_Global;
/* Defines */
#define CFE_EVS_PANIC_DELAY 500 /**< \brief Task delay before PSP panic */

/*
** Local function prototypes.
*/
void CFE_EVS_ProcessGroundCommand(CFE_SB_Buffer_t *SBBufPtr, CFE_SB_MsgId_t MsgId);
bool CFE_EVS_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, size_t ExpectedLength);

/* Function Definitions */

/*----------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ void Test_Init(void)
{
CFE_EVS_EnablePortsCmd_t bitmaskcmd;
CFE_EVS_EnableAppEventTypeCmd_t appbitcmd;
CFE_SB_MsgId_t msgid = CFE_SB_INVALID_MSG_ID;

UtPrintf("Begin Test Init");

Expand Down Expand Up @@ -307,7 +306,7 @@ void Test_Init(void)
UT_InitData_EVS();

/* Set unexpected message ID */
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false);
UT_SetupBasicMsgDispatch(&UT_TPID_CFE_EVS_INVALID_MID, 0, true);

UT_EVS_DoGenericCheckEvents(CFE_EVS_TaskMain, &UT_EVS_EventBuf);
CFE_UtAssert_SYSLOG(EVS_SYSLOG_MSGS[8]);
Expand Down

0 comments on commit 64f9a63

Please sign in to comment.