Skip to content

Commit

Permalink
Fix nasa#2315, uniqueness of tbl target names
Browse files Browse the repository at this point in the history
If the passed-in table name does not use a qualifier suffix, then
generate one by computing a hash of the context information.  This
ensures that the generated intermediate target names will be unique.
  • Loading branch information
jphickey committed May 2, 2023
1 parent 7479d22 commit b16a4c0
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmake/arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ function(add_cfe_tables TABLE_FQNAME TBL_DEFAULT_SRC_FILES)

get_filename_component(APP_NAME ${TABLE_FQNAME} NAME_WE)

# The passed-in name allows for a qualifier (in the form of APP_NAME.QUALIFIER) to get
# uniqueness in the generated target names. If there is no qualifier, then there
# will potentially be a target name conflict. To avoid this, generate a hash of the
# context of this call - the current directory, app/tgt names, and source files. This
# should be unique but also produce the same hash when CMake is re-run. The hash
# can then be used as a qualifier.
if (TABLE_FQNAME STREQUAL APP_NAME)
string(SHA1 CONTEXT_HASH
"${CMAKE_CURRENT_LIST_DIR}+${TGTNAME}+${APP_NAME}+${TBL_DEFAULT_SRC_FILES};${ARGN}"
)
set(TABLE_FQNAME "${APP_NAME}.t${CONTEXT_HASH}")
endif()

# If "TGTNAME" is set, then use it directly
set(TABLE_TGTLIST ${TGTNAME})
set(TABLE_TEMPLATE "${CFE_SOURCE_DIR}/cmake/tables/table_rule_template.d.in")
Expand Down

0 comments on commit b16a4c0

Please sign in to comment.