Skip to content

Commit 3c4b9cf

Browse files
committed
Fix #972, Reorganize CFE core into separate modules
Significant reorganization of the CFE core directory and header file structure. All modules become separate subdirectories under fsw/modules. Additionally, the interfaces to CFE core (public and internal) are also separated into modules. CMake "interface libraries" and related constructs are used to manage the include paths to all the separate modules.
1 parent 274c150 commit 3c4b9cf

File tree

240 files changed

+9620
-953
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

240 files changed

+9620
-953
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
5151
# (this is not required, and the directory can be empty/nonexistent)
5252
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH})
5353

54-
# The minimum CMake version is chosen because 2.6.4 is what is
55-
# included by default with RHEL/Centos 5.x
56-
cmake_minimum_required(VERSION 2.6.4)
54+
# The minimum CMake version is chosen because v3.5.1 is what is
55+
# available by default with Ubuntu 16.04 LTS at the time of development
56+
# RHEL/CentOS users should install the "cmake3" package from EPEL repo
57+
cmake_minimum_required(VERSION 3.5)
5758

5859
# This top-level file does not define ANY targets directly but we know
5960
# that the subdirectories will at least use the "C" language, so

cmake/arch_build.cmake

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ endfunction(initialize_globals)
6262
function(add_psp_module MOD_NAME MOD_SRC_FILES)
6363

6464
# Include the PSP shared directory so it can get to cfe_psp_module.h
65-
include_directories(${MISSION_SOURCE_DIR}/psp/fsw/shared/inc)
6665
add_definitions(-D_CFE_PSP_MODULE_)
6766

6867
# Create the module
@@ -89,6 +88,7 @@ function(add_cfe_app APP_NAME APP_SRC_FILES)
8988

9089
# Create the app module
9190
add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN})
91+
target_link_libraries(${APP_NAME} cfe_app_intf)
9292

9393
# An "install" step is only needed for dynamic/runtime loaded apps
9494
if (APP_DYNAMIC_TARGET_LIST)
@@ -105,11 +105,6 @@ endfunction(add_cfe_app)
105105
#
106106
function(add_cfe_tables APP_NAME TBL_SRC_FILES)
107107

108-
# The table source must be compiled using the same "include_directories"
109-
# as any other target, but it uses the "add_custom_command" so there is
110-
# no automatic way to do this (at least in the older cmakes)
111-
get_current_cflags(TBL_CFLAGS ${CMAKE_C_FLAGS})
112-
113108
# Create the intermediate table objects using the target compiler,
114109
# then use "elf2cfetbl" to convert to a .tbl file
115110
set(TBL_LIST)
@@ -148,6 +143,9 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
148143
message("NOTE: Selected ${TBL_SRC} as source for ${TBLWE}")
149144
endif()
150145

146+
add_library(${TGT}_${TBLWE}-obj OBJECT ${TBL_SRC})
147+
target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE cfe_app_intf)
148+
151149
# IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches
152150
# the input file name but with a different extension (.o -> .tbl)
153151
# The actual output filename is embedded in the source file (.c), however
@@ -156,9 +154,9 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
156154
# current content of a dependency (rightfully so).
157155
add_custom_command(
158156
OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl"
159-
COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC}
160-
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBLWE}.o
161-
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBL_SRC}
157+
#COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC}
158+
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl $<TARGET_OBJECTS:${TGT}_${TBLWE}-obj>
159+
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj
162160
WORKING_DIRECTORY ${TABLE_DESTDIR}
163161
)
164162
# Create the install targets for all the tables
@@ -254,6 +252,38 @@ function(cfs_app_do_install APP_NAME)
254252

255253
endfunction(cfs_app_do_install)
256254

255+
##################################################################
256+
#
257+
# FUNCTION: cfs_app_check_intf
258+
#
259+
# Adds a special target that checks the structure of header files
260+
# in the public interface for this module. A synthetic .c source file
261+
# is created which has a "#include" of each individual header, which
262+
# then compiled as part of the validation. The intent is to confirm
263+
# that each header is valid in a standalone fashion and have no
264+
# implicit prerequisites.
265+
#
266+
function(cfs_app_check_intf MODULE_NAME)
267+
set(${MODULE_NAME}_hdrcheck_SOURCES)
268+
foreach(HDR ${ARGN})
269+
configure_file(${CFE_SOURCE_DIR}/cmake/check_header.c.in ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
270+
list(APPEND ${MODULE_NAME}_hdrcheck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
271+
endforeach(HDR ${ARGN})
272+
add_library(${MODULE_NAME}_headercheck OBJECT ${${MODULE_NAME}_hdrcheck_SOURCES})
273+
274+
# This causes the check to compile with the same set of defines and include dirs as specified
275+
# in the "INTERFACE" properties of the actual module
276+
target_link_libraries(${MODULE_NAME}_headercheck PRIVATE
277+
cfe_app_intf
278+
${DEP}
279+
)
280+
281+
# Build this as part of the synthetic "check-headers" target
282+
add_dependencies(check-headers ${MODULE_NAME}_headercheck)
283+
endfunction(cfs_app_check_intf)
284+
285+
286+
257287

258288
##################################################################
259289
#
@@ -329,6 +359,7 @@ function(process_arch SYSVAR)
329359

330360
# Generate a list of targets that share this system architecture
331361
set(INSTALL_TARGET_LIST ${TGTSYS_${SYSVAR}})
362+
message("INSTALL_TARGET_LIST=${INSTALL_TARGET_LIST}")
332363

333364
# Assume use of an OSAL BSP of the same name as the CFE PSP
334365
# This can be overridden by the PSP-specific build_options but normally this is expected.
@@ -350,33 +381,17 @@ function(process_arch SYSVAR)
350381
include_directories(${MISSION_BINARY_DIR}/inc)
351382
include_directories(${CMAKE_BINARY_DIR}/inc)
352383

384+
# Add a custom target for "headercheck" - this is a special target confirms that
385+
# checks the sanity of headers within the public interface of modules
386+
add_custom_target(check-headers)
387+
353388
# Configure OSAL target first, as it also determines important compiler flags
354389
add_subdirectory("${osal_MISSION_DIR}" osal)
355390

356391
# The OSAL displays its selected OS, so it is logical to display the selected PSP
357392
# This can help with debugging if things go wrong.
358393
message(STATUS "PSP Selection: ${CFE_SYSTEM_PSPNAME}")
359394

360-
# Add all widely-used public headers to the include path chain
361-
include_directories(${MISSION_SOURCE_DIR}/osal/src/os/inc)
362-
include_directories(${MISSION_SOURCE_DIR}/psp/fsw/inc)
363-
include_directories(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core/src/inc)
364-
include_directories(${MISSION_SOURCE_DIR}/cfe/cmake/target/inc)
365-
366-
# propagate any OSAL interface compile definitions and include directories to this build
367-
# This is set as a directory property here at the top level so it will apply to all code.
368-
# This includes MODULE libraries that do not directly/statically link with OSAL but still
369-
# should be compiled with these flags.
370-
get_target_property(OSAL_COMPILE_DEFINITIONS osal INTERFACE_COMPILE_DEFINITIONS)
371-
get_target_property(OSAL_INCLUDE_DIRECTORIES osal INTERFACE_INCLUDE_DIRECTORIES)
372-
373-
if (OSAL_COMPILE_DEFINITIONS)
374-
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "${OSAL_COMPILE_DEFINITIONS}")
375-
endif (OSAL_COMPILE_DEFINITIONS)
376-
if (OSAL_INCLUDE_DIRECTORIES)
377-
include_directories(${OSAL_INCLUDE_DIRECTORIES})
378-
endif (OSAL_INCLUDE_DIRECTORIES)
379-
380395
# Append the PSP and OSAL selections to the Doxyfile so it will be included
381396
# in the generated documentation automatically.
382397
# Also extract the "-D" options within CFLAGS and inform Doxygen about these

cmake/check_header.c.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include "@HDR@"
2+
3+
/* A no-op function so this compilation unit is not empty */
4+
void CheckHeader(void) {}

cmake/global_functions.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,21 +278,25 @@ endfunction(read_targetconfig)
278278
#
279279
function(get_current_cflags OUTPUT_LIST)
280280

281+
message(FATAL_ERROR "BROKEN!")
282+
281283
# Start by converting the supplied string to a list
282284
set(FLAGLIST)
283285
foreach (FLGSTR ${ARGN})
284286
string(REGEX REPLACE " +" ";" TEMPFLG ${FLGSTR})
285287
list(APPEND FLAGLIST ${TEMPFLG})
286288
endforeach (FLGSTR ${ARGN})
287289

288-
# Append any compile definitions from the directory properties
289-
get_directory_property(CURRENT_DEFS COMPILE_DEFINITIONS)
290-
foreach(DEF ${CURRENT_DEFS})
290+
# Append any compile definitions from the CFE API
291+
get_target_property(CURRENT_DEFS cfe_app INTERFACE_COMPILE_DEFINITIONS)
292+
message("DEFS=${CURRENT_DEFS}")
293+
foreach(DEF $<TARGET_PROPERTY:cfe_app,INTERFACE_COMPILE_DEFINITIONS>)
291294
list(APPEND FLAGLIST "-D${DEF}")
292295
endforeach(DEF ${CURRENT_DEFS})
293296

294-
# Append any include directories from the directory properties
295-
get_directory_property(CURRENT_INCDIRS INCLUDE_DIRECTORIES)
297+
# Append any include directories from the CFE API
298+
get_target_property(CURRENT_INCDIRS cfe_app INTERFACE_INCLUDE_DIRECTORIES)
299+
message("INCDIRS=${CURRENT_INCDIRS}")
296300
foreach(INC ${CURRENT_INCDIRS})
297301
list(APPEND FLAGLIST "-I${INC}")
298302
endforeach(INC ${CURRENT_INCDIRS})

cmake/mission_build.cmake

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ function(generate_build_version_templates)
161161

162162
endfunction(generate_build_version_templates)
163163

164-
165164
##################################################################
166165
#
167166
# FUNCTION: prepare
@@ -249,7 +248,7 @@ function(prepare)
249248

250249
foreach(APP ${MISSION_DEPS})
251250
# OSAL is handled specially, as only part of it is used
252-
if (NOT APP STREQUAL "osal" AND NOT APP STREQUAL "cfe-core")
251+
if (NOT APP STREQUAL "osal")
253252
if (EXISTS "${${APP}_MISSION_DIR}/docs/${APP}.doxyfile.in")
254253
# If the module provides its own doxyfile, then include it directly
255254
# This allows for app-specific fine-tuning of the sources, based on its own source tree
@@ -283,11 +282,19 @@ function(prepare)
283282
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h")
284283

285284
# The user guide should include the doxygen from the _public_ API files from CFE + OSAL
285+
# NOTE: the userguide is built against the headers of the default core apps. Even if
286+
# an alternate version of the module is in use, it should adhere to the same interface.
286287
file(GLOB MISSION_USERGUIDE_HEADERFILES
287-
"${cfe-core_MISSION_DIR}/src/inc/*.h"
288+
"${es_MISSION_DIR}/fsw/inc/*.h"
289+
"${evs_MISSION_DIR}/fsw/inc/*.h"
290+
"${fs_MISSION_DIR}/fsw/inc/*.h"
291+
"${sb_MISSION_DIR}/fsw/inc/*.h"
292+
"${tbl_MISSION_DIR}/fsw/inc/*.h"
293+
"${time_MISSION_DIR}/fsw/inc/*.h"
288294
"${osal_MISSION_DIR}/src/os/inc/*.h"
295+
"${psp_MISSION_DIR}/psp/fsw/inc/*.h"
289296
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h"
290-
"${MISSION_SOURCE_DIR}/psp/fsw/inc/*.h")
297+
)
291298
string(REPLACE ";" " \\\n" MISSION_USERGUIDE_HEADERFILES "${MISSION_USERGUIDE_HEADERFILES}")
292299

293300
# OSAL API GUIDE include PUBLIC API
@@ -312,7 +319,7 @@ function(prepare)
312319

313320
add_custom_target(osalguide
314321
doxygen osalguide.doxyfile
315-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")
322+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")
316323

317324
# Pull in any application-specific mission-scope configuration
318325
# This may include user configuration files such as cfe_mission_cfg.h,
@@ -360,6 +367,18 @@ function(prepare)
360367
generate_build_version_templates()
361368

362369
# Generate the tools for the native (host) arch
370+
# Add all public include dirs for core components to include path for tools
371+
include_directories(
372+
${cfe_app_intf_MISSION_DIR}/fsw/inc
373+
#${es_MISSION_DIR}/fsw/inc
374+
#${evs_MISSION_DIR}/fsw/inc
375+
#${fs_MISSION_DIR}/fsw/inc
376+
#${sb_MISSION_DIR}/fsw/inc
377+
#${tbl_MISSION_DIR}/fsw/inc
378+
#${time_MISSION_DIR}/fsw/inc
379+
${osal_MISSION_DIR}/src/os/inc
380+
${psp_MISSION_DIR}/psp/fsw/inc
381+
)
363382
add_subdirectory(${MISSION_SOURCE_DIR}/tools tools)
364383

365384
# Add a dependency on the table generator tool as this is required for table builds

cmake/mission_defaults.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,16 @@
1010
# The "MISSION_CORE_MODULES" will be built and statically linked as part
1111
# of the CFE core executable on every target. These can be used to amend
1212
# or override parts of the CFE core on a mission-specific basis.
13+
# The "intf" modules are headers only, and define the interface(s) between components
1314
set(MISSION_CORE_MODULES
14-
"cfe-core"
15+
"cfe_app_intf"
16+
"cfe_internal_intf"
17+
"es"
18+
"evs"
19+
"fs"
20+
"sb"
21+
"tbl"
22+
"time"
1523
"osal"
1624
"psp"
1725
"msg"
@@ -45,7 +53,6 @@ set(MISSION_MODULE_SEARCH_PATH
4553
# a variable named "<component>_SEARCH_PATH". This is
4654
# used for locating cfe-core and osal which are not part
4755
# of the standard search path.
48-
set(cfe-core_SEARCH_PATH "cfe/fsw")
4956
set(osal_SEARCH_PATH ".")
5057
set(psp_SEARCH_PATH ".")
5158

cmake/target/src/target_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "cfe_platform_cfg.h"
3838
#include "cfe_es.h"
3939
#include "cfe_time.h"
40-
#include "private/cfe_es_resetdata_typedef.h"
40+
#include "cfe_es_resetdata_typedef.h"
4141
#include "cfe_version.h" /* for CFE_VERSION_STRING */
4242
#include "osapi-version.h" /* for OS_VERSION_STRING */
4343

0 commit comments

Comments
 (0)