Skip to content

Commit

Permalink
Fix #261, add psp_module_api interface target
Browse files Browse the repository at this point in the history
Adds a new target for PSP modules and use this to propagate the compile
definitions and include directories for all PSP code.
  • Loading branch information
jphickey committed Mar 9, 2021
1 parent 215807e commit 147ac40
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 31 deletions.
31 changes: 14 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,37 @@ if (NOT CFE_SYSTEM_PSPNAME)
endif()

set(CFE_PSP_TARGETNAME "${CFE_SYSTEM_PSPNAME}")
add_definitions(-D_CFE_PSP_)
add_definitions(-D_CFE_PSP_) # macro to indicate PSP scope

# The "psp_module_api" defines the interface between internal PSP components
add_library(psp_module_api INTERFACE)
target_compile_definitions(psp_module_api INTERFACE
$<TARGET_PROPERTY:osal,INTERFACE_COMPILE_DEFINITIONS> # use defs from OSAL
)
target_include_directories(psp_module_api INTERFACE
fsw/inc # public API
fsw/shared/inc # all PSP shared headers
${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig
$<TARGET_PROPERTY:osal,INTERFACE_INCLUDE_DIRECTORIES> # use headers from OSAL
)


# The PSP is currently built in two parts, consisting of a fully platform-specific
# module combined with a shared component which is built for multiple targets.
# The "shared" component is compiled using headers from the platform-specific module
# so it is still ultimately a platform-specific binary, and it all gets wrapped into
# a single PSP static library target.
include_directories(
fsw/inc
fsw/shared/inc # all local stuff
${CFE_SOURCE_DIR}/cmake/target/inc # for sysconfig
$<TARGET_PROPERTY:osal,INTERFACE_INCLUDE_DIRECTORIES> # headers from OSAL
)

add_subdirectory(fsw/${CFE_PSP_TARGETNAME} ${CFE_PSP_TARGETNAME}-impl)
target_compile_definitions(psp-${CFE_PSP_TARGETNAME}-impl PUBLIC
$<TARGET_PROPERTY:osal,INTERFACE_COMPILE_DEFINITIONS> # defs from OSAL
)

add_subdirectory(fsw/shared ${CFE_PSP_TARGETNAME}-shared)
target_compile_definitions(psp-${CFE_PSP_TARGETNAME}-shared PUBLIC
$<TARGET_PROPERTY:osal,INTERFACE_COMPILE_DEFINITIONS> # defs from OSAL
)

add_library(psp-${CFE_PSP_TARGETNAME} STATIC
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-shared>
$<TARGET_OBJECTS:psp-${CFE_PSP_TARGETNAME}-impl>
)

target_include_directories(psp-${CFE_PSP_TARGETNAME} INTERFACE
fsw/inc
)


if (ENABLE_UNIT_TESTS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/ut-stubs)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit-test-coverage)
Expand Down
8 changes: 4 additions & 4 deletions fsw/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the mcp750-vxworks implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -18,5 +16,7 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_watchdog.c)

src/cfe_psp_watchdog.c
)
target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc)
target_link_libraries(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE psp_module_api)
1 change: 1 addition & 0 deletions fsw/modules/eeprom_stub/cfe_psp_eeprom_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ CFE_PSP_MODULE_DECLARE_SIMPLE(eeprom_stub);
void eeprom_stub_Init(uint32 PspModuleId)
{
/* Nothing to init */
printf("CFE_PSP: Using stub implementation for EEPROM\n");
}

int32 CFE_PSP_EepromWrite32(cpuaddr MemoryAddress, uint32 uint32Value)
Expand Down
7 changes: 4 additions & 3 deletions fsw/pc-linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the pc-linux implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -25,4 +23,7 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
# Code outside the pc-linux PSP should _not_ depend on this.
target_compile_definitions(psp-${CFE_SYSTEM_PSPNAME}-impl PRIVATE
_GNU_SOURCE
)
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc)
target_link_libraries(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE psp_module_api)
7 changes: 4 additions & 3 deletions fsw/pc-rtems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
# This contains the fully platform-specific code to
# run CFE on this target.

include_directories(inc)

# Build the pc-rtems implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_exception.c
Expand All @@ -18,5 +16,8 @@ add_library(psp-${CFE_PSP_TARGETNAME}-impl OBJECT
src/cfe_psp_start.c
src/cfe_psp_support.c
src/cfe_psp_timer.c
src/cfe_psp_watchdog.c)
src/cfe_psp_watchdog.c
)
target_include_directories(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE inc)
target_link_libraries(psp-${CFE_PSP_TARGETNAME}-impl PRIVATE psp_module_api)

8 changes: 5 additions & 3 deletions fsw/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@
# Note this shared PSP code is currently built against headers provided by the
# target implementation. This makes it implementation-specific even though
# the same source code is used with multiple targets.
include_directories("${CFEPSP_SOURCE_DIR}/fsw/${CFE_PSP_TARGETNAME}/inc")
include_directories(inc)

# Build the shared implementation as a library
add_library(psp-${CFE_PSP_TARGETNAME}-shared OBJECT
src/cfe_psp_configdata.c
src/cfe_psp_eeprom.c
src/cfe_psp_exceptionstorage.c
src/cfe_psp_memrange.c
src/cfe_psp_memutils.c
src/cfe_psp_module.c
src/cfe_psp_port.c
src/cfe_psp_ram.c
)

target_include_directories(psp-${CFE_PSP_TARGETNAME}-shared PRIVATE
$<TARGET_PROPERTY:psp-${CFE_PSP_TARGETNAME}-impl,INCLUDE_DIRECTORIES>
)
target_link_libraries(psp-${CFE_PSP_TARGETNAME}-shared PRIVATE psp_module_api)
1 change: 1 addition & 0 deletions unit-test-coverage/mcp750-vxworks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ add_executable(coverage-${CFE_PSP_TARGETNAME}-testrunner
target_link_libraries(coverage-${CFE_PSP_TARGETNAME}-testrunner
${UT_COVERAGE_LINK_FLAGS}
ut-adaptor-${CFE_PSP_TARGETNAME}
psp_module_api
ut_psp_cfe_stubs
ut_psp_libc_stubs
ut_osapi_stubs
Expand Down
5 changes: 5 additions & 0 deletions unit-test-coverage/mcp750-vxworks/adaptors/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ target_include_directories(ut-adaptor-${CFE_PSP_TARGETNAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc
${PSPCOVERAGE_SOURCE_DIR}/shared/adaptors/inc
)

target_link_libraries(ut-adaptor-${CFE_PSP_TARGETNAME} PRIVATE
psp_module_api
ut_assert
)
10 changes: 10 additions & 0 deletions unit-test-coverage/ut-stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ add_library(ut_psp_libc_stubs STATIC EXCLUDE_FROM_ALL
target_include_directories(ut_libc_stubs PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/inc
)

target_link_libraries(ut_psp_libc_stubs PRIVATE
psp_module_api
ut_assert
)

add_library(ut_psp_cfe_stubs STATIC EXCLUDE_FROM_ALL
src/cfe-configdata-stubs.c
)

target_link_libraries(ut_psp_cfe_stubs PRIVATE
psp_module_api
ut_assert
)
5 changes: 4 additions & 1 deletion ut-stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
include_directories(${osal_MISSION_DIR}/ut_assert/inc)
add_library(ut_psp-${CFE_PSP_TARGETNAME}_stubs ut_psp_stubs.c)
target_link_libraries(ut_psp-${CFE_PSP_TARGETNAME}_stubs PRIVATE
psp_module_api
ut_assert
)

0 comments on commit 147ac40

Please sign in to comment.