Skip to content

Commit 9bc7bfd

Browse files
authored
Merge pull request #1203 from jphickey/fix-972-directory-structure
Fix #972, reorganize directory structure
2 parents 178fbad + 03c2942 commit 9bc7bfd

File tree

253 files changed

+3430
-3929
lines changed

Some content is hidden

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

253 files changed

+3430
-3929
lines changed

.github/workflows/codeql-build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ jobs:
4848
# Build the code
4949
- name: Build
5050
run: |
51-
make cfe-core
52-
make native/default_cpu1/cfe-core/unit-test/
53-
make native/default_cpu1/cfe-core/ut-stubs/
51+
make -C build/native/default_cpu1 core_api core_private es evs fs msg resourceid sb sbr tbl time
5452
5553
- name: Perform CodeQL Analysis
5654
uses: github/codeql-action/analyze@v1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cppcheck_common_opts="--force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive"
4+
5+
# When checking time, only the "server" config option is enabled for now.
6+
# Otherwise cppcheck attempts to check with both branches enabled and generates false errors
7+
cppcheck_time_opts="-UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER"
8+
9+
for mod in ${*}
10+
do
11+
cppcheck ${cppcheck_common_opts} $(eval echo \$cppcheck_${mod}_opts) ./modules/${mod}/fsw
12+
done
13+

.github/workflows/static-analysis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ jobs:
3838
- name: cfe strict cppcheck
3939
if: ${{matrix.cppcheck =='cfe'}}
4040
run: |
41-
cppcheck --force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive ./fsw/cfe-core/src ./modules 2> ./${{matrix.cppcheck}}_cppcheck_err.txt
41+
all_fsw_modules="core_api core_private es evs fs msg resourceid sb sbr tbl time"
42+
/bin/bash ./.github/workflows/run_fsw_cppcheck.sh ${all_fsw_modules} 2> ${{matrix.cppcheck}}_cppcheck_err.txt
4243
4344
- name: Archive Static Analysis Artifacts
4445
uses: actions/upload-artifact@v2

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: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ endfunction(initialize_globals)
7070
#
7171
function(add_psp_module MOD_NAME MOD_SRC_FILES)
7272

73-
# Include the PSP shared directory so it can get to cfe_psp_module.h
74-
include_directories(${MISSION_SOURCE_DIR}/psp/fsw/shared/inc)
75-
add_definitions(-D_CFE_PSP_MODULE_)
76-
7773
# Create the module
7874
add_library(${MOD_NAME} STATIC ${MOD_SRC_FILES} ${ARGN})
75+
target_link_libraries(${MOD_NAME} PRIVATE psp_module_api)
76+
77+
target_compile_definitions(${MOD_NAME} PRIVATE
78+
_CFE_PSP_MODULE_
79+
)
7980

8081
endfunction(add_psp_module)
8182

@@ -98,6 +99,7 @@ function(add_cfe_app APP_NAME APP_SRC_FILES)
9899

99100
# Create the app module
100101
add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN})
102+
target_link_libraries(${APP_NAME} core_api)
101103

102104
# An "install" step is only needed for dynamic/runtime loaded apps
103105
if (APP_DYNAMIC_TARGET_LIST)
@@ -149,7 +151,6 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
149151
# The table source must be compiled using the same "include_directories"
150152
# as any other target, but it uses the "add_custom_command" so there is
151153
# no automatic way to do this (at least in the older cmakes)
152-
get_current_cflags(TBL_CFLAGS ${CMAKE_C_FLAGS})
153154

154155
# Create the intermediate table objects using the target compiler,
155156
# then use "elf2cfetbl" to convert to a .tbl file
@@ -189,6 +190,9 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
189190
message("NOTE: Selected ${TBL_SRC} as source for ${TBLWE}")
190191
endif()
191192

193+
add_library(${TGT}_${TBLWE}-obj OBJECT ${TBL_SRC})
194+
target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE core_api)
195+
192196
# IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches
193197
# the input file name but with a different extension (.o -> .tbl)
194198
# The actual output filename is embedded in the source file (.c), however
@@ -197,9 +201,8 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
197201
# current content of a dependency (rightfully so).
198202
add_custom_command(
199203
OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl"
200-
COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC}
201-
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBLWE}.o
202-
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBL_SRC}
204+
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl $<TARGET_OBJECTS:${TGT}_${TBLWE}-obj>
205+
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj
203206
WORKING_DIRECTORY ${TABLE_DESTDIR}
204207
)
205208
# Create the install targets for all the tables
@@ -308,7 +311,7 @@ function(add_cfe_coverage_test MODULE_NAME UNIT_NAME TESTCASE_SRC UT_SRCS)
308311
# as well as the UT assert framework
309312
target_link_libraries(${RUNNER_TARGET}
310313
${UT_COVERAGE_LINK_FLAGS}
311-
ut_cfe-core_stubs
314+
ut_core_api_stubs
312315
ut_assert
313316
)
314317

@@ -442,6 +445,38 @@ function(cfs_app_do_install APP_NAME)
442445

443446
endfunction(cfs_app_do_install)
444447

448+
##################################################################
449+
#
450+
# FUNCTION: cfs_app_check_intf
451+
#
452+
# Adds a special target that checks the structure of header files
453+
# in the public interface for this module. A synthetic .c source file
454+
# is created which has a "#include" of each individual header, which
455+
# then compiled as part of the validation. The intent is to confirm
456+
# that each header is valid in a standalone fashion and have no
457+
# implicit prerequisites.
458+
#
459+
function(cfs_app_check_intf MODULE_NAME)
460+
set(${MODULE_NAME}_hdrcheck_SOURCES)
461+
foreach(HDR ${ARGN})
462+
configure_file(${CFE_SOURCE_DIR}/cmake/check_header.c.in ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
463+
list(APPEND ${MODULE_NAME}_hdrcheck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
464+
endforeach(HDR ${ARGN})
465+
add_library(${MODULE_NAME}_headercheck OBJECT ${${MODULE_NAME}_hdrcheck_SOURCES})
466+
467+
# This causes the check to compile with the same set of defines and include dirs as specified
468+
# in the "INTERFACE" properties of the actual module
469+
target_link_libraries(${MODULE_NAME}_headercheck PRIVATE
470+
core_api
471+
${DEP}
472+
)
473+
474+
# Build this as part of the synthetic "check-headers" target
475+
add_dependencies(check-headers ${MODULE_NAME}_headercheck)
476+
endfunction(cfs_app_check_intf)
477+
478+
479+
445480

446481
##################################################################
447482
#
@@ -538,33 +573,17 @@ function(process_arch SYSVAR)
538573
include_directories(${MISSION_BINARY_DIR}/inc)
539574
include_directories(${CMAKE_BINARY_DIR}/inc)
540575

576+
# Add a custom target for "headercheck" - this is a special target confirms that
577+
# checks the sanity of headers within the public interface of modules
578+
add_custom_target(check-headers)
579+
541580
# Configure OSAL target first, as it also determines important compiler flags
542581
add_subdirectory("${osal_MISSION_DIR}" osal)
543582

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

548-
# Add all widely-used public headers to the include path chain
549-
include_directories(${MISSION_SOURCE_DIR}/osal/src/os/inc)
550-
include_directories(${MISSION_SOURCE_DIR}/psp/fsw/inc)
551-
include_directories(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core/src/inc)
552-
include_directories(${MISSION_SOURCE_DIR}/cfe/cmake/target/inc)
553-
554-
# propagate any OSAL interface compile definitions and include directories to this build
555-
# This is set as a directory property here at the top level so it will apply to all code.
556-
# This includes MODULE libraries that do not directly/statically link with OSAL but still
557-
# should be compiled with these flags.
558-
get_target_property(OSAL_COMPILE_DEFINITIONS osal INTERFACE_COMPILE_DEFINITIONS)
559-
get_target_property(OSAL_INCLUDE_DIRECTORIES osal INTERFACE_INCLUDE_DIRECTORIES)
560-
561-
if (OSAL_COMPILE_DEFINITIONS)
562-
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "${OSAL_COMPILE_DEFINITIONS}")
563-
endif (OSAL_COMPILE_DEFINITIONS)
564-
if (OSAL_INCLUDE_DIRECTORIES)
565-
include_directories(${OSAL_INCLUDE_DIRECTORIES})
566-
endif (OSAL_INCLUDE_DIRECTORIES)
567-
568587
# Append the PSP and OSAL selections to the Doxyfile so it will be included
569588
# in the generated documentation automatically.
570589
# 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: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -264,39 +264,3 @@ function(read_targetconfig)
264264
endforeach(SYSVAR ${TGTSYS_LIST})
265265

266266
endfunction(read_targetconfig)
267-
268-
##################################################################
269-
#
270-
# FUNCTION: get_current_cflags
271-
#
272-
# Convert the input string, which is a simple text string of compiler flags such
273-
# as CMAKE_C_FLAGS or CMAKE_CXX_FLAGS, and convert it to a list of individual options
274-
#
275-
# In addition, the "-I" options from include_directories() and -D options from
276-
# add_definitions() will be added to the output list. The contents of these will be
277-
# obtained via the properities of the current source directory.
278-
#
279-
function(get_current_cflags OUTPUT_LIST)
280-
281-
# Start by converting the supplied string to a list
282-
set(FLAGLIST)
283-
foreach (FLGSTR ${ARGN})
284-
string(REGEX REPLACE " +" ";" TEMPFLG ${FLGSTR})
285-
list(APPEND FLAGLIST ${TEMPFLG})
286-
endforeach (FLGSTR ${ARGN})
287-
288-
# Append any compile definitions from the directory properties
289-
get_directory_property(CURRENT_DEFS COMPILE_DEFINITIONS)
290-
foreach(DEF ${CURRENT_DEFS})
291-
list(APPEND FLAGLIST "-D${DEF}")
292-
endforeach(DEF ${CURRENT_DEFS})
293-
294-
# Append any include directories from the directory properties
295-
get_directory_property(CURRENT_INCDIRS INCLUDE_DIRECTORIES)
296-
foreach(INC ${CURRENT_INCDIRS})
297-
list(APPEND FLAGLIST "-I${INC}")
298-
endforeach(INC ${CURRENT_INCDIRS})
299-
300-
set(${OUTPUT_LIST} ${FLAGLIST} PARENT_SCOPE)
301-
302-
endfunction(get_current_cflags OUTPUT_LIST INPUT_FLAGS)

cmake/mission_build.cmake

Lines changed: 27 additions & 7 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
@@ -281,13 +280,22 @@ function(prepare)
281280
# have the documentation associated with each macro definition.
282281
configure_file("${osal_MISSION_DIR}/osconfig.h.in"
283282
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h")
284-
283+
285284
# The user guide should include the doxygen from the _public_ API files from CFE + OSAL
286-
file(GLOB MISSION_USERGUIDE_HEADERFILES
287-
"${cfe-core_MISSION_DIR}/src/inc/*.h"
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.
287+
set(SUBMODULE_HEADER_PATHS
288288
"${osal_MISSION_DIR}/src/os/inc/*.h"
289+
"${psp_MISSION_DIR}/psp/fsw/inc/*.h"
290+
)
291+
foreach(MODULE core_api es evs fs msg sb tbl time)
292+
list(APPEND SUBMODULE_HEADER_PATHS "${${MODULE}_MISSION_DIR}/fsw/inc/*.h")
293+
endforeach()
294+
file(GLOB MISSION_USERGUIDE_HEADERFILES
295+
${SUBMODULE_HEADER_PATHS}
289296
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h"
290-
"${MISSION_SOURCE_DIR}/psp/fsw/inc/*.h")
297+
)
298+
291299
string(REPLACE ";" " \\\n" MISSION_USERGUIDE_HEADERFILES "${MISSION_USERGUIDE_HEADERFILES}")
292300

293301
# OSAL API GUIDE include PUBLIC API
@@ -312,7 +320,7 @@ function(prepare)
312320

313321
add_custom_target(osalguide
314322
doxygen osalguide.doxyfile
315-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")
323+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")
316324

317325
# Pull in any application-specific mission-scope configuration
318326
# This may include user configuration files such as cfe_mission_cfg.h,
@@ -360,6 +368,18 @@ function(prepare)
360368
generate_build_version_templates()
361369

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

365385
# 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+
"core_api"
16+
"core_private"
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/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ string(CONCAT GENERATED_FILE_TRAILER
3434
set(GENERATED_EXTERNS)
3535
set(GENERATED_KEYVALS)
3636
foreach(PSPMOD ${${TGTNAME}_PSP_MODULELIST})
37-
list(APPEND GENERATED_EXTERNS "extern char CFE_PSP_${PSPMOD}_API;\n")
37+
list(APPEND GENERATED_EXTERNS "extern char CFE_PSP_${PSPMOD}_API\;\n")
3838
list(APPEND GENERATED_KEYVALS "{ .Name = \"${PSPMOD}\", .Api = &CFE_PSP_${PSPMOD}_API },\n")
3939
endforeach(PSPMOD ${${TGTNAME}_PSP_MODULELIST})
4040

0 commit comments

Comments
 (0)