Skip to content

Commit

Permalink
Merge pull request #1203 from jphickey/fix-972-directory-structure
Browse files Browse the repository at this point in the history
Fix #972, reorganize directory structure
  • Loading branch information
astrogeco authored Mar 11, 2021
2 parents 178fbad + 03c2942 commit 9bc7bfd
Show file tree
Hide file tree
Showing 253 changed files with 3,430 additions and 3,929 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ jobs:
# Build the code
- name: Build
run: |
make cfe-core
make native/default_cpu1/cfe-core/unit-test/
make native/default_cpu1/cfe-core/ut-stubs/
make -C build/native/default_cpu1 core_api core_private es evs fs msg resourceid sb sbr tbl time
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
13 changes: 13 additions & 0 deletions .github/workflows/run_fsw_cppcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

cppcheck_common_opts="--force --inline-suppr --std=c99 --language=c --enable=warning,performance,portability,style --suppress=variableScope --inconclusive"

# When checking time, only the "server" config option is enabled for now.
# Otherwise cppcheck attempts to check with both branches enabled and generates false errors
cppcheck_time_opts="-UCFE_PLATFORM_TIME_CFG_CLIENT -DCFE_PLATFORM_TIME_CFG_SERVER"

for mod in ${*}
do
cppcheck ${cppcheck_common_opts} $(eval echo \$cppcheck_${mod}_opts) ./modules/${mod}/fsw
done

3 changes: 2 additions & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
- name: cfe strict cppcheck
if: ${{matrix.cppcheck =='cfe'}}
run: |
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
all_fsw_modules="core_api core_private es evs fs msg resourceid sb sbr tbl time"
/bin/bash ./.github/workflows/run_fsw_cppcheck.sh ${all_fsw_modules} 2> ${{matrix.cppcheck}}_cppcheck_err.txt
- name: Archive Static Analysis Artifacts
uses: actions/upload-artifact@v2
Expand Down
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
# (this is not required, and the directory can be empty/nonexistent)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH})

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

# This top-level file does not define ANY targets directly but we know
# that the subdirectories will at least use the "C" language, so
Expand Down
77 changes: 48 additions & 29 deletions cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ endfunction(initialize_globals)
#
function(add_psp_module MOD_NAME MOD_SRC_FILES)

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

# Create the module
add_library(${MOD_NAME} STATIC ${MOD_SRC_FILES} ${ARGN})
target_link_libraries(${MOD_NAME} PRIVATE psp_module_api)

target_compile_definitions(${MOD_NAME} PRIVATE
_CFE_PSP_MODULE_
)

endfunction(add_psp_module)

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

# Create the app module
add_library(${APP_NAME} ${APPTYPE} ${APP_SRC_FILES} ${ARGN})
target_link_libraries(${APP_NAME} core_api)

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

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

add_library(${TGT}_${TBLWE}-obj OBJECT ${TBL_SRC})
target_link_libraries(${TGT}_${TBLWE}-obj PRIVATE core_api)

# IMPORTANT: This rule assumes that the output filename of elf2cfetbl matches
# the input file name but with a different extension (.o -> .tbl)
# The actual output filename is embedded in the source file (.c), however
Expand All @@ -197,9 +201,8 @@ function(add_cfe_tables APP_NAME TBL_SRC_FILES)
# current content of a dependency (rightfully so).
add_custom_command(
OUTPUT "${TABLE_DESTDIR}/${TBLWE}.tbl"
COMMAND ${CMAKE_C_COMPILER} ${TBL_CFLAGS} -c -o ${TBLWE}.o ${TBL_SRC}
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBLWE}.o
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TBL_SRC}
COMMAND ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl $<TARGET_OBJECTS:${TGT}_${TBLWE}-obj>
DEPENDS ${MISSION_BINARY_DIR}/tools/elf2cfetbl/elf2cfetbl ${TGT}_${TBLWE}-obj
WORKING_DIRECTORY ${TABLE_DESTDIR}
)
# Create the install targets for all the tables
Expand Down Expand Up @@ -308,7 +311,7 @@ function(add_cfe_coverage_test MODULE_NAME UNIT_NAME TESTCASE_SRC UT_SRCS)
# as well as the UT assert framework
target_link_libraries(${RUNNER_TARGET}
${UT_COVERAGE_LINK_FLAGS}
ut_cfe-core_stubs
ut_core_api_stubs
ut_assert
)

Expand Down Expand Up @@ -442,6 +445,38 @@ function(cfs_app_do_install APP_NAME)

endfunction(cfs_app_do_install)

##################################################################
#
# FUNCTION: cfs_app_check_intf
#
# Adds a special target that checks the structure of header files
# in the public interface for this module. A synthetic .c source file
# is created which has a "#include" of each individual header, which
# then compiled as part of the validation. The intent is to confirm
# that each header is valid in a standalone fashion and have no
# implicit prerequisites.
#
function(cfs_app_check_intf MODULE_NAME)
set(${MODULE_NAME}_hdrcheck_SOURCES)
foreach(HDR ${ARGN})
configure_file(${CFE_SOURCE_DIR}/cmake/check_header.c.in ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
list(APPEND ${MODULE_NAME}_hdrcheck_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/src/check_${HDR}.c)
endforeach(HDR ${ARGN})
add_library(${MODULE_NAME}_headercheck OBJECT ${${MODULE_NAME}_hdrcheck_SOURCES})

# This causes the check to compile with the same set of defines and include dirs as specified
# in the "INTERFACE" properties of the actual module
target_link_libraries(${MODULE_NAME}_headercheck PRIVATE
core_api
${DEP}
)

# Build this as part of the synthetic "check-headers" target
add_dependencies(check-headers ${MODULE_NAME}_headercheck)
endfunction(cfs_app_check_intf)




##################################################################
#
Expand Down Expand Up @@ -538,33 +573,17 @@ function(process_arch SYSVAR)
include_directories(${MISSION_BINARY_DIR}/inc)
include_directories(${CMAKE_BINARY_DIR}/inc)

# Add a custom target for "headercheck" - this is a special target confirms that
# checks the sanity of headers within the public interface of modules
add_custom_target(check-headers)

# Configure OSAL target first, as it also determines important compiler flags
add_subdirectory("${osal_MISSION_DIR}" osal)

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

# Add all widely-used public headers to the include path chain
include_directories(${MISSION_SOURCE_DIR}/osal/src/os/inc)
include_directories(${MISSION_SOURCE_DIR}/psp/fsw/inc)
include_directories(${MISSION_SOURCE_DIR}/cfe/fsw/cfe-core/src/inc)
include_directories(${MISSION_SOURCE_DIR}/cfe/cmake/target/inc)

# propagate any OSAL interface compile definitions and include directories to this build
# This is set as a directory property here at the top level so it will apply to all code.
# This includes MODULE libraries that do not directly/statically link with OSAL but still
# should be compiled with these flags.
get_target_property(OSAL_COMPILE_DEFINITIONS osal INTERFACE_COMPILE_DEFINITIONS)
get_target_property(OSAL_INCLUDE_DIRECTORIES osal INTERFACE_INCLUDE_DIRECTORIES)

if (OSAL_COMPILE_DEFINITIONS)
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS "${OSAL_COMPILE_DEFINITIONS}")
endif (OSAL_COMPILE_DEFINITIONS)
if (OSAL_INCLUDE_DIRECTORIES)
include_directories(${OSAL_INCLUDE_DIRECTORIES})
endif (OSAL_INCLUDE_DIRECTORIES)

# Append the PSP and OSAL selections to the Doxyfile so it will be included
# in the generated documentation automatically.
# Also extract the "-D" options within CFLAGS and inform Doxygen about these
Expand Down
4 changes: 4 additions & 0 deletions cmake/check_header.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "@HDR@"

/* A no-op function so this compilation unit is not empty */
void CheckHeader(void) {}
36 changes: 0 additions & 36 deletions cmake/global_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -264,39 +264,3 @@ function(read_targetconfig)
endforeach(SYSVAR ${TGTSYS_LIST})

endfunction(read_targetconfig)

##################################################################
#
# FUNCTION: get_current_cflags
#
# Convert the input string, which is a simple text string of compiler flags such
# as CMAKE_C_FLAGS or CMAKE_CXX_FLAGS, and convert it to a list of individual options
#
# In addition, the "-I" options from include_directories() and -D options from
# add_definitions() will be added to the output list. The contents of these will be
# obtained via the properities of the current source directory.
#
function(get_current_cflags OUTPUT_LIST)

# Start by converting the supplied string to a list
set(FLAGLIST)
foreach (FLGSTR ${ARGN})
string(REGEX REPLACE " +" ";" TEMPFLG ${FLGSTR})
list(APPEND FLAGLIST ${TEMPFLG})
endforeach (FLGSTR ${ARGN})

# Append any compile definitions from the directory properties
get_directory_property(CURRENT_DEFS COMPILE_DEFINITIONS)
foreach(DEF ${CURRENT_DEFS})
list(APPEND FLAGLIST "-D${DEF}")
endforeach(DEF ${CURRENT_DEFS})

# Append any include directories from the directory properties
get_directory_property(CURRENT_INCDIRS INCLUDE_DIRECTORIES)
foreach(INC ${CURRENT_INCDIRS})
list(APPEND FLAGLIST "-I${INC}")
endforeach(INC ${CURRENT_INCDIRS})

set(${OUTPUT_LIST} ${FLAGLIST} PARENT_SCOPE)

endfunction(get_current_cflags OUTPUT_LIST INPUT_FLAGS)
34 changes: 27 additions & 7 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ function(generate_build_version_templates)

endfunction(generate_build_version_templates)


##################################################################
#
# FUNCTION: prepare
Expand Down Expand Up @@ -249,7 +248,7 @@ function(prepare)

foreach(APP ${MISSION_DEPS})
# OSAL is handled specially, as only part of it is used
if (NOT APP STREQUAL "osal" AND NOT APP STREQUAL "cfe-core")
if (NOT APP STREQUAL "osal")
if (EXISTS "${${APP}_MISSION_DIR}/docs/${APP}.doxyfile.in")
# If the module provides its own doxyfile, then include it directly
# This allows for app-specific fine-tuning of the sources, based on its own source tree
Expand Down Expand Up @@ -281,13 +280,22 @@ function(prepare)
# have the documentation associated with each macro definition.
configure_file("${osal_MISSION_DIR}/osconfig.h.in"
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h")

# The user guide should include the doxygen from the _public_ API files from CFE + OSAL
file(GLOB MISSION_USERGUIDE_HEADERFILES
"${cfe-core_MISSION_DIR}/src/inc/*.h"
# NOTE: the userguide is built against the headers of the default core apps. Even if
# an alternate version of the module is in use, it should adhere to the same interface.
set(SUBMODULE_HEADER_PATHS
"${osal_MISSION_DIR}/src/os/inc/*.h"
"${psp_MISSION_DIR}/psp/fsw/inc/*.h"
)
foreach(MODULE core_api es evs fs msg sb tbl time)
list(APPEND SUBMODULE_HEADER_PATHS "${${MODULE}_MISSION_DIR}/fsw/inc/*.h")
endforeach()
file(GLOB MISSION_USERGUIDE_HEADERFILES
${SUBMODULE_HEADER_PATHS}
"${CMAKE_BINARY_DIR}/doc/osconfig-example.h"
"${MISSION_SOURCE_DIR}/psp/fsw/inc/*.h")
)

string(REPLACE ";" " \\\n" MISSION_USERGUIDE_HEADERFILES "${MISSION_USERGUIDE_HEADERFILES}")

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

add_custom_target(osalguide
doxygen osalguide.doxyfile
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/doc")

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

# Generate the tools for the native (host) arch
# Add all public include dirs for core components to include path for tools
include_directories(
${core_api_MISSION_DIR}/fsw/inc
#${es_MISSION_DIR}/fsw/inc
#${evs_MISSION_DIR}/fsw/inc
#${fs_MISSION_DIR}/fsw/inc
#${sb_MISSION_DIR}/fsw/inc
#${tbl_MISSION_DIR}/fsw/inc
#${time_MISSION_DIR}/fsw/inc
${osal_MISSION_DIR}/src/os/inc
${psp_MISSION_DIR}/psp/fsw/inc
)
add_subdirectory(${MISSION_SOURCE_DIR}/tools tools)

# Add a dependency on the table generator tool as this is required for table builds
Expand Down
11 changes: 9 additions & 2 deletions cmake/mission_defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,16 @@
# The "MISSION_CORE_MODULES" will be built and statically linked as part
# of the CFE core executable on every target. These can be used to amend
# or override parts of the CFE core on a mission-specific basis.
# The "intf" modules are headers only, and define the interface(s) between components
set(MISSION_CORE_MODULES
"cfe-core"
"core_api"
"core_private"
"es"
"evs"
"fs"
"sb"
"tbl"
"time"
"osal"
"psp"
"msg"
Expand Down Expand Up @@ -45,7 +53,6 @@ set(MISSION_MODULE_SEARCH_PATH
# a variable named "<component>_SEARCH_PATH". This is
# used for locating cfe-core and osal which are not part
# of the standard search path.
set(cfe-core_SEARCH_PATH "cfe/fsw")
set(osal_SEARCH_PATH ".")
set(psp_SEARCH_PATH ".")

Expand Down
2 changes: 1 addition & 1 deletion cmake/target/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ string(CONCAT GENERATED_FILE_TRAILER
set(GENERATED_EXTERNS)
set(GENERATED_KEYVALS)
foreach(PSPMOD ${${TGTNAME}_PSP_MODULELIST})
list(APPEND GENERATED_EXTERNS "extern char CFE_PSP_${PSPMOD}_API;\n")
list(APPEND GENERATED_EXTERNS "extern char CFE_PSP_${PSPMOD}_API\;\n")
list(APPEND GENERATED_KEYVALS "{ .Name = \"${PSPMOD}\", .Api = &CFE_PSP_${PSPMOD}_API },\n")
endforeach(PSPMOD ${${TGTNAME}_PSP_MODULELIST})

Expand Down
2 changes: 1 addition & 1 deletion cmake/target/src/target_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#include "cfe_platform_cfg.h"
#include "cfe_es.h"
#include "cfe_time.h"
#include "private/cfe_es_resetdata_typedef.h"
#include "cfe_es_resetdata_typedef.h"
#include "cfe_version.h" /* for CFE_VERSION_STRING */
#include "osapi-version.h" /* for OS_VERSION_STRING */

Expand Down
Loading

0 comments on commit 9bc7bfd

Please sign in to comment.