Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2564, add config tool for platform-specific settings #2565

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
cp ./cfe/cmake/Makefile.sample Makefile
cp -r ./cfe/cmake/sample_defs sample_defs
make prep
make -C build mission-prebuild

# Build the code
- name: Build
Expand Down
44 changes: 38 additions & 6 deletions cmake/mission_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,38 @@ function(export_variable_cache USER_VARLIST)

endfunction(export_variable_cache)

##################################################################
#
# FUNCTION: decode_targetsystem
#
#
function(decode_targetsystem TARGETSYSTEM)
# The "BUILD_CONFIG" is a list of items to uniquely identify this build
# The first element in the list is the toolchain name, followed by config name(s)

set(ONE_VAL_ARGS OUTPUT_ARCH_BINARY_DIR OUTPUT_ARCH_TOOLCHAIN_NAME OUTPUT_ARCH_CONFIG_NAME)
cmake_parse_arguments(DT "" "${ONE_VAL_ARGS}" "" ${ARGN})

set(BUILD_CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}})
list(GET BUILD_CONFIG 0 ARCH_TOOLCHAIN_NAME)
list(REMOVE_AT BUILD_CONFIG 0)
# convert to a string which is safe for a directory name
string(REGEX REPLACE "[^A-Za-z0-9]" "_" ARCH_CONFIG_NAME "${BUILD_CONFIG}")

# Export values to parent
if (DT_OUTPUT_ARCH_BINARY_DIR)
set(${DT_OUTPUT_ARCH_BINARY_DIR} "${CMAKE_BINARY_DIR}/${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}" PARENT_SCOPE)
endif()
if (DT_OUTPUT_ARCH_TOOLCHAIN_NAME)
set(${DT_OUTPUT_ARCH_TOOLCHAIN_NAME} "${ARCH_TOOLCHAIN_NAME}" PARENT_SCOPE)
endif()
if (DT_OUTPUT_ARCH_CONFIG_NAME)
set(${DT_OUTPUT_ARCH_CONFIG_NAME} "${ARCH_CONFIG_NAME}" PARENT_SCOPE)
endif()

endfunction(decode_targetsystem)


##################################################################
#
# FUNCTION: prepare
Expand Down Expand Up @@ -536,12 +568,12 @@ function(process_arch TARGETSYSTEM)

# The "BUILD_CONFIG" is a list of items to uniquely identify this build
# The first element in the list is the toolchain name, followed by config name(s)
set(BUILD_CONFIG ${BUILD_CONFIG_${TARGETSYSTEM}})
list(GET BUILD_CONFIG 0 ARCH_TOOLCHAIN_NAME)
list(REMOVE_AT BUILD_CONFIG 0)
# convert to a string which is safe for a directory name
string(REGEX REPLACE "[^A-Za-z0-9]" "_" ARCH_CONFIG_NAME "${BUILD_CONFIG}")
set(ARCH_BINARY_DIR "${CMAKE_BINARY_DIR}/${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}")
decode_targetsystem(${TARGETSYSTEM}
OUTPUT_ARCH_BINARY_DIR ARCH_BINARY_DIR
OUTPUT_ARCH_TOOLCHAIN_NAME ARCH_TOOLCHAIN_NAME
OUTPUT_ARCH_CONFIG_NAME ARCH_CONFIG_NAME
)

file(MAKE_DIRECTORY "${ARCH_BINARY_DIR}")

message(STATUS "Configuring for system arch: ${ARCH_TOOLCHAIN_NAME}/${ARCH_CONFIG_NAME}")
Expand Down
23 changes: 19 additions & 4 deletions modules/config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,27 @@ set(config_SOURCES
)
add_library(config STATIC
${config_SOURCES}
${MISSION_BINARY_DIR}/src/cfe_config_map.c
${MISSION_BINARY_DIR}/src/cfe_configid_nametable.c
${CMAKE_BINARY_DIR}/src/cfe_platformcfg_tables.c
)

# need to include the "src" dir explicitly here, in order to compile
# the generated tables under ${MISSION_BINARY_DIR}
target_include_directories(config PRIVATE fsw/src)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/src/cfe_platformcfg_tables.c
COMMAND ${CMAKE_COMMAND}
-D LIST_FILE=${MISSION_BINARY_DIR}/src/cfeconfig_platformdata_${TARGETSYSTEM}.list
-D CONTENT_FILE=${MISSION_BINARY_DIR}/src/cfeconfig_platformdata_${TARGETSYSTEM}.c
-D OUTPUT_FILE=${CMAKE_BINARY_DIR}/src/cfe_platformcfg_tables.c
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/create_cfe_platform_cfg.cmake
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/cmake
DEPENDS
${MISSION_BINARY_DIR}/src/cfeconfig_platformdata_${TARGETSYSTEM}.c
${MISSION_BINARY_DIR}/src/cfeconfig_platformdata_${TARGETSYSTEM}.list
${CMAKE_CURRENT_SOURCE_DIR}/cmake/create_cfe_platform_cfg.cmake
${CMAKE_CURRENT_SOURCE_DIR}/cmake/cfe_platform_cfg.c.in
)

target_include_directories(config PUBLIC fsw/inc)
target_link_libraries(config PRIVATE core_private)

# Add unit test coverage subdirectory
Expand Down
14 changes: 8 additions & 6 deletions modules/config/cmake/cfe_config_ids.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#include "cfe_config_api_typedefs.h"
#include "cfe_resourceid.h"
#include "cfe_core_resourceid_basevalues.h"
#include "cfe_configid_offset.h"

/* Value offsets from base (needed for macros; do not use directly) */
enum CFE_ConfigIdOffset
{
@GENERATED_ENUM_OFFSET_LIST@
CFE_ConfigIdOffset_MAX
};
/*
* Macro to convert to a properly-typed config ID
* The symbol used in this macro must correlate to an offset in the enum
*/

#define CFE_CONFIGID_OFFSET_TO_RESID(x) CFE_ResourceId_FromInteger(CFE_CONFIGID_BASE + CFE_CONFIGID_OFFSETNAME(x))
#define CFE_CONFIGID_FROM_OFFSET(x) CFE_CONFIGID_C(CFE_CONFIGID_OFFSET_TO_RESID(x))

/*
* Set of actual CONFIGID constants -
Expand Down
8 changes: 0 additions & 8 deletions modules/config/cmake/cfe_config_map.c.in

This file was deleted.

11 changes: 11 additions & 0 deletions modules/config/cmake/cfe_configid_nametable.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* This file is auto-generated from CMake build system. Do not manually edit! */
#include "cfe_configid_offset.h"
#include "cfe_config_nametable.h"

#define CFE_CONFIGID_DEFINE(x) [CFE_CONFIGID_OFFSETNAME(x)] = { #x },

/* Map of configuration key IDs to printable names */
const CFE_Config_IdNameEntry_t CFE_CONFIGID_NAMETABLE[CFE_ConfigIdOffset_MAX] =
{
@GENERATED_ID_MACRO_LIST@
};
19 changes: 19 additions & 0 deletions modules/config/cmake/cfe_configid_offset.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* This file is auto-generated from CMake build system. Do not manually edit! */
#ifndef CFE_CONFIGID_OFFSET_H
#define CFE_CONFIGID_OFFSET_H

#define CFE_CONFIGID_OFFSETNAME(x) CFE_ConfigIdOffset_ ## x

#undef CFE_CONFIGID_DEFINE
#define CFE_CONFIGID_DEFINE(x) CFE_CONFIGID_OFFSETNAME(x),

/* Value offsets from base (needed for macros; do not use directly) */
typedef enum CFE_ConfigIdOffset_Enum
{
@GENERATED_ID_MACRO_LIST@
CFE_ConfigIdOffset_MAX
} CFE_ConfigIdOffset_Enum_t;

#undef CFE_CONFIGID_DEFINE

#endif /* CFE_CONFIGID_OFFSET_H */
21 changes: 21 additions & 0 deletions modules/config/cmake/cfe_platform_cfg.c.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <common_types.h>
#include <cfe_platform_cfg.h>

#include "cfe_config_core_internal.h"
#include "cfe_config_ids.h"
#include "cfe_config_set.h"

#define ARRAY_NAME(a) CFE_CONFIG_ ## a ## _CONTENT
#define ARRAY_LEN(a) (sizeof(ARRAY_NAME(a)) / sizeof(ARRAY_NAME(a)[0]))

#define CFE_PLATFORMCFG_ENTRY(x) {\
static const CFE_Config_ArrayValue_t ARR_ ## x = { ARRAY_LEN(x), ARRAY_NAME(x) };\
CFE_Config_SetArrayValue(CFE_CONFIGID_FROM_OFFSET(x), &ARR_ ## x);\
}

@PLATCFG_CONTENT@

void CFE_Config_SetupPlatformConfigInfo(void)
{
@PLATCFG_LIST@
}
5 changes: 5 additions & 0 deletions modules/config/cmake/create_cfe_platform_cfg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

file(READ ${LIST_FILE} PLATCFG_LIST)
file(READ ${CONTENT_FILE} PLATCFG_CONTENT)

configure_file(cfe_platform_cfg.c.in ${OUTPUT_FILE} @ONLY)
37 changes: 37 additions & 0 deletions modules/config/config_ids_base.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
##########################################################
#
# CFE Configuration key names - base set
#
# These configuration keys are set via the FSW code
# as part of the basic init routine. They will be set
# to the same values on all CPUs.
#
##########################################################

# Append the set of version description config keys
list(APPEND CFE_CONFIG_IDS
MISSION_NAME
MISSION_SRCVER
MISSION_EDS_DB
MISSION_SBINTF_DB

CORE_VERSION_MAJOR
CORE_VERSION_MINOR
CORE_VERSION_REVISION
CORE_VERSION_MISSION_REV
CORE_VERSION_BUILDNUM
CORE_VERSION_BASELINE
CORE_VERSION_DESCRIPTION

CORE_BUILDINFO_DATE
CORE_BUILDINFO_USER
CORE_BUILDINFO_HOST
)

# Generate config ID for source version of modules that are included in the build
# NOTE: the presence in this list does not necesarily mean it will have a value at runtime,
# which may be the case for dynamic apps which are not loaded, for instance.
foreach(DEP ${MISSION_CORE_INTERFACES} ${MISSION_APPS} ${MISSION_CORE_MODULES} ${MISSION_PSPMODULES})
string(TOUPPER "${DEP}" DEPNAME)
list(APPEND CFE_CONFIG_IDS MOD_SRCVER_${DEPNAME})
endforeach()
34 changes: 34 additions & 0 deletions modules/config/fsw/inc/cfe_config_external.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
*
* Initialization for CFE configuration registry, external items
*
* These are generated from the build system, they are not directly set
*/

#ifndef CFE_CONFIG_EXTERNAL_H
#define CFE_CONFIG_EXTERNAL_H

#include "cfe_config_api_typedefs.h"

void CFE_Config_SetupPlatformConfigInfo(void);

#endif /* CFE_CONFIG_EXTERNAL_H */
35 changes: 35 additions & 0 deletions modules/config/fsw/inc/cfe_config_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
*
* Function declarations for items implemented in init.c
*/

#ifndef CFE_CONFIG_INIT_H
#define CFE_CONFIG_INIT_H

#include "cfe_config_api_typedefs.h"

#include "cfe_config_ids.h"

void CFE_Config_SetupBasicBuildInfo(void);
int32 CFE_Config_Init(void);

#endif /* CFE_CONFIG_INIT_H */
39 changes: 39 additions & 0 deletions modules/config/fsw/inc/cfe_config_lookup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/************************************************************************
* NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes”
*
* Copyright (c) 2020 United States Government as represented by the
* Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
************************************************************************/

/**
* @file
*
* Function declarations for items implemented in lookup.c
*/

#ifndef CFE_CONFIG_LOOKUP_H
#define CFE_CONFIG_LOOKUP_H

/*
** Includes
*/
#include "cfe_config_api_typedefs.h"
#include "cfe_config_table.h"

/**
* @brief Gets the value record associated with a config ID
*/
CFE_Config_ValueEntry_t *CFE_Config_LocateConfigRecordByID(CFE_ConfigId_t ConfigId);

#endif /* CFE_CONFIG_LOOKUP_H */
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
* This file contains the CFE configuration registry global data definitions.
*/

#ifndef CFE_CONFIG_MAP_H
#define CFE_CONFIG_MAP_H
#ifndef CFE_CONFIG_NAMETABLE_H
#define CFE_CONFIG_NAMETABLE_H

/*
** Includes
*/
#include "common_types.h"
#include "cfe_config_ids.h"
#include "cfe_configid_offset.h"

typedef struct CFE_Config_IdNameEntry
{
const char *Name;
} CFE_Config_IdNameEntry_t;

extern const CFE_Config_IdNameEntry_t CFE_CONFIG_IDNAME_MAP[];
extern const CFE_Config_IdNameEntry_t CFE_CONFIGID_NAMETABLE[];

#endif /* CFE_CONFIG_MAP_H */
Loading
Loading