-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #1170, refactor target config objects
Rework the dynamic content so it is generated entirely via a CMake "configure_file()" command into a C source file (.c) that can be built as normal. This removes the need for inline `#include` statements to pull in data fragments to fill in the data.
- Loading branch information
Showing
9 changed files
with
618 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
################################################################## | ||
# | ||
# cFS version metadata collection script | ||
# | ||
# This small script runs at build time (as opposed to prep time) | ||
# and is intended to extract information about the current | ||
# build environment - this may change after initial makefile creation | ||
# | ||
################################################################## | ||
|
||
# All 3 of these may be passed via environment variables to force a particular | ||
# date, user, or hostname i.e. if hoping to reproduce an exact binary of a prior build | ||
# They are free-form strings, will be built/linked into the final CONFIGDATA object. | ||
|
||
# Get the current date and time | ||
set(BUILDDATE $ENV{BUILDDATE}) | ||
if (NOT BUILDDATE) | ||
execute_process( | ||
COMMAND date "+%Y%m%d%H%M" | ||
OUTPUT_VARIABLE BUILDDATE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif(NOT BUILDDATE) | ||
|
||
# Get the build host | ||
set(BUILDHOST $ENV{HOSTNAME}) | ||
if (NOT BUILDHOST) | ||
execute_process( | ||
COMMAND hostname | ||
OUTPUT_VARIABLE BUILDHOST | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif (NOT BUILDHOST) | ||
|
||
# Get the user ID | ||
set(BUILDUSER $ENV{USER}) | ||
if (NOT BUILDUSER) | ||
execute_process( | ||
COMMAND whoami | ||
OUTPUT_VARIABLE BUILDUSER | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif (NOT BUILDUSER) | ||
|
||
# Use configure_file() command to generate the final output file because this can detect | ||
# and only update it if it changes. | ||
set(CFE_KEYVALUE_TABLE_NAME "CFE_BUILD_ENV_TABLE") | ||
configure_file(${BIN}/cfe_build_env.in ${BIN}/src/cfe_build_env_table.c @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
################################################################## | ||
# | ||
# cFS version metadata collection script | ||
# | ||
# This small script runs at build time (as opposed to prep time) | ||
# and is intended to extract version metadata from the current source | ||
# tree. It is done each time that the code is built, since the | ||
# metadata could change at any time (i.e. a different branch could | ||
# be checked out, or additional changes committed) | ||
# | ||
# Currently only git is supported as a version control source, however | ||
# it could be extended to others by adding the appropriate command | ||
# | ||
################################################################## | ||
|
||
set(GIT_EXECUTABLE git) | ||
|
||
function(get_version DEP) | ||
if (DEP STREQUAL "MISSION") | ||
set(NAME ${MISSION_NAME}) | ||
set(DIR ${MISSION_SOURCE_DIR}) | ||
else() | ||
if(EXISTS ${${DEP}_MISSION_DIR}/version_info.cmake) | ||
include(${${DEP}_MISSION_DIR}/version_info.cmake) | ||
else() | ||
set(NAME ${DEP}) | ||
endif() | ||
set(DIR ${${DEP}_MISSION_DIR}) | ||
endif() | ||
message("inside get_version for ${DEP}") | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty | ||
WORKING_DIRECTORY ${DIR} | ||
OUTPUT_VARIABLE GIT_DESC_OUTPUT | ||
RESULT_VARIABLE GIT_RESULT | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
|
||
# Export output to parent scope | ||
set(${DEP}_NAME "${NAME}" PARENT_SCOPE) | ||
|
||
# If result was successful, then string-ify it, otherwise use NULL | ||
if (GIT_RESULT EQUAL 0) | ||
set(${DEP}_VERSION "\"git:${GIT_DESC_OUTPUT}\"" PARENT_SCOPE) | ||
else() | ||
set(${DEP}_VERSION "NULL" PARENT_SCOPE) | ||
endif() | ||
|
||
endfunction() | ||
|
||
|
||
# First read in any variables that are passed in from the parent process | ||
# There may be many of these and they may not all be passable via -D options | ||
file(STRINGS "${BIN}/mission_vars.cache" PARENTVARS) | ||
set(VARNAME) | ||
foreach(PV ${PARENTVARS}) | ||
if (VARNAME) | ||
set(${VARNAME} ${PV}) | ||
set(VARNAME) | ||
else() | ||
set(VARNAME ${PV}) | ||
endif() | ||
endforeach(PV ${PARENTVARS}) | ||
|
||
# Get version for all mission apps/dependencies (they may be different) | ||
foreach(DEP "MISSION" ${MISSION_DEPS}) | ||
get_version(${DEP}) | ||
endforeach() | ||
|
||
|
||
# Use configure_file() command to generate the final output file because this can detect | ||
# and only update it if it changes. | ||
set(CFE_KEYVALUE_TABLE_NAME "CFE_MODULE_VERSION_TABLE") | ||
configure_file(${BIN}/cfe_module_version.in ${BIN}/src/cfe_module_version_table.c @ONLY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.