CMake: Move more Qt-specific SBOM PURL functions to the right file
The Qt specific functions belong in the QtPublicSbomQtEntityHelpers.cmake file, not QtPublicSbomPurlHelpers.cmake. Amends f1ac316191c010b1389f6f3549c9f0b4424b9936 Pick-to: 6.8 6.9 Task-number: QTBUG-122899 Change-Id: If5dd77672306c520404b294a6b5bde4f0e6ab8bc Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
a55db2cbee
commit
e7cdf9d438
@ -11,59 +11,6 @@ macro(_qt_internal_sbom_parse_purl_variant_options prefix arguments_var_name)
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
endmacro()
|
||||
|
||||
# Returns a vcs url where for purls where qt entities of the current repo are hosted.
|
||||
function(_qt_internal_sbom_get_qt_entity_vcs_url target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
REPO_NAME
|
||||
VERSION
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
if(NOT arg_REPO_NAME)
|
||||
message(FATAL_ERROR "REPO_NAME must be set")
|
||||
endif()
|
||||
|
||||
if(NOT arg_OUT_VAR)
|
||||
message(FATAL_ERROR "OUT_VAR must be set")
|
||||
endif()
|
||||
|
||||
set(version_part "")
|
||||
if(arg_VERSION)
|
||||
set(version_part "@${arg_VERSION}")
|
||||
endif()
|
||||
|
||||
set(vcs_url "https://code.qt.io/qt/${arg_REPO_NAME}.git${version_part}")
|
||||
set(${arg_OUT_VAR} "${vcs_url}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Returns a relative path to the source where the target was created, to be embedded into a
|
||||
# mirror purl as a subpath.
|
||||
function(_qt_internal_sbom_get_qt_entity_repo_source_dir target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
if(NOT arg_OUT_VAR)
|
||||
message(FATAL_ERROR "OUT_VAR must be set")
|
||||
endif()
|
||||
|
||||
get_target_property(repo_source_dir "${target}" SOURCE_DIR)
|
||||
|
||||
# Get the path relative to the PROJECT_SOURCE_DIR
|
||||
file(RELATIVE_PATH relative_repo_source_dir "${PROJECT_SOURCE_DIR}" "${repo_source_dir}")
|
||||
|
||||
set(sub_path "${relative_repo_source_dir}")
|
||||
set(${arg_OUT_VAR} "${sub_path}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Handles purl arguments specified to functions like qt_internal_add_sbom.
|
||||
# Currently accepts arguments for 3 variants of purls, each of which will generate a separate purl.
|
||||
# If no arguments are specified, for qt entity types, default values will be chosen.
|
||||
@ -223,86 +170,6 @@ function(_qt_internal_sbom_handle_purl_values target)
|
||||
set(${arg_OUT_VAR} "${project_package_options}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Gets a list of arguments to pass to _qt_internal_sbom_assemble_purl when handling a Qt entity
|
||||
# type. The purl for Qt entity types have Qt-specific defaults, but can be overridden per purl
|
||||
# component.
|
||||
# The arguments are saved in OUT_VAR.
|
||||
function(_qt_internal_sbom_get_qt_entity_purl_args target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
NAME
|
||||
REPO_NAME
|
||||
SUPPLIER
|
||||
VERSION
|
||||
PURL_VARIANT
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
|
||||
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
|
||||
list(APPEND opt_args ${purl_opt_args})
|
||||
list(APPEND single_args ${purl_single_args})
|
||||
list(APPEND multi_args ${purl_multi_args})
|
||||
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
set(supported_purl_variants QT MIRROR)
|
||||
if(NOT arg_PURL_VARIANT IN_LIST supported_purl_variants)
|
||||
message(FATAL_ERROR "PURL_VARIANT unknown: ${arg_PURL_VARIANT}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_VARIANT STREQUAL "QT")
|
||||
set(purl_type "generic")
|
||||
set(purl_namespace "${arg_SUPPLIER}")
|
||||
set(purl_name "${arg_NAME}")
|
||||
set(purl_version "${arg_VERSION}")
|
||||
elseif(arg_PURL_VARIANT STREQUAL "MIRROR")
|
||||
set(purl_type "github")
|
||||
set(purl_namespace "qt")
|
||||
set(purl_name "${arg_REPO_NAME}")
|
||||
set(purl_version "${arg_VERSION}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_TYPE)
|
||||
set(purl_type "${arg_PURL_TYPE}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_NAMESPACE)
|
||||
set(purl_namespace "${arg_PURL_NAMESPACE}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_NAME)
|
||||
set(purl_name "${arg_PURL_NAME}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_VERSION)
|
||||
set(purl_version "${arg_PURL_VERSION}")
|
||||
endif()
|
||||
|
||||
set(purl_version_option "")
|
||||
if(purl_version)
|
||||
set(purl_version_option PURL_VERSION "${purl_version}")
|
||||
endif()
|
||||
|
||||
set(purl_args
|
||||
PURL_TYPE "${purl_type}"
|
||||
PURL_NAMESPACE "${purl_namespace}"
|
||||
PURL_NAME "${purl_name}"
|
||||
${purl_version_option}
|
||||
)
|
||||
|
||||
if(arg_PURL_QUALIFIERS)
|
||||
list(APPEND purl_args PURL_QUALIFIERS "${arg_PURL_QUALIFIERS}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_SUBPATH)
|
||||
list(APPEND purl_args PURL_SUBPATH "${arg_PURL_SUBPATH}")
|
||||
endif()
|
||||
|
||||
set(${arg_OUT_VAR} "${purl_args}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Assembles an external reference purl identifier.
|
||||
# PURL_TYPE and PURL_NAME are required.
|
||||
# Stores the result in the OUT_VAR.
|
||||
|
@ -231,6 +231,139 @@ macro(_qt_internal_sbom_forward_purl_handling_options args_var_name)
|
||||
)
|
||||
endmacro()
|
||||
|
||||
# Returns a vcs url where for purls where qt entities of the current repo are hosted.
|
||||
function(_qt_internal_sbom_get_qt_entity_vcs_url target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
REPO_NAME
|
||||
VERSION
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
if(NOT arg_REPO_NAME)
|
||||
message(FATAL_ERROR "REPO_NAME must be set")
|
||||
endif()
|
||||
|
||||
if(NOT arg_OUT_VAR)
|
||||
message(FATAL_ERROR "OUT_VAR must be set")
|
||||
endif()
|
||||
|
||||
set(version_part "")
|
||||
if(arg_VERSION)
|
||||
set(version_part "@${arg_VERSION}")
|
||||
endif()
|
||||
|
||||
set(vcs_url "https://code.qt.io/qt/${arg_REPO_NAME}.git${version_part}")
|
||||
set(${arg_OUT_VAR} "${vcs_url}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Returns a relative path to the source where the target was created, to be embedded into a
|
||||
# mirror purl as a subpath.
|
||||
function(_qt_internal_sbom_get_qt_entity_repo_source_dir target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
if(NOT arg_OUT_VAR)
|
||||
message(FATAL_ERROR "OUT_VAR must be set")
|
||||
endif()
|
||||
|
||||
get_target_property(repo_source_dir "${target}" SOURCE_DIR)
|
||||
|
||||
# Get the path relative to the PROJECT_SOURCE_DIR
|
||||
file(RELATIVE_PATH relative_repo_source_dir "${PROJECT_SOURCE_DIR}" "${repo_source_dir}")
|
||||
|
||||
set(sub_path "${relative_repo_source_dir}")
|
||||
set(${arg_OUT_VAR} "${sub_path}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Gets a list of arguments to pass to _qt_internal_sbom_assemble_purl when handling a Qt entity
|
||||
# type. The purl for Qt entity types have Qt-specific defaults, but can be overridden per purl
|
||||
# component.
|
||||
# The arguments are saved in OUT_VAR.
|
||||
function(_qt_internal_sbom_get_qt_entity_purl_args target)
|
||||
set(opt_args "")
|
||||
set(single_args
|
||||
NAME
|
||||
REPO_NAME
|
||||
SUPPLIER
|
||||
VERSION
|
||||
PURL_VARIANT
|
||||
OUT_VAR
|
||||
)
|
||||
set(multi_args "")
|
||||
|
||||
_qt_internal_get_sbom_purl_parsing_options(purl_opt_args purl_single_args purl_multi_args)
|
||||
list(APPEND opt_args ${purl_opt_args})
|
||||
list(APPEND single_args ${purl_single_args})
|
||||
list(APPEND multi_args ${purl_multi_args})
|
||||
|
||||
cmake_parse_arguments(PARSE_ARGV 1 arg "${opt_args}" "${single_args}" "${multi_args}")
|
||||
_qt_internal_validate_all_args_are_parsed(arg)
|
||||
|
||||
set(supported_purl_variants QT MIRROR)
|
||||
if(NOT arg_PURL_VARIANT IN_LIST supported_purl_variants)
|
||||
message(FATAL_ERROR "PURL_VARIANT unknown: ${arg_PURL_VARIANT}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_VARIANT STREQUAL "QT")
|
||||
set(purl_type "generic")
|
||||
set(purl_namespace "${arg_SUPPLIER}")
|
||||
set(purl_name "${arg_NAME}")
|
||||
set(purl_version "${arg_VERSION}")
|
||||
elseif(arg_PURL_VARIANT STREQUAL "MIRROR")
|
||||
set(purl_type "github")
|
||||
set(purl_namespace "qt")
|
||||
set(purl_name "${arg_REPO_NAME}")
|
||||
set(purl_version "${arg_VERSION}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_TYPE)
|
||||
set(purl_type "${arg_PURL_TYPE}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_NAMESPACE)
|
||||
set(purl_namespace "${arg_PURL_NAMESPACE}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_NAME)
|
||||
set(purl_name "${arg_PURL_NAME}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_VERSION)
|
||||
set(purl_version "${arg_PURL_VERSION}")
|
||||
endif()
|
||||
|
||||
set(purl_version_option "")
|
||||
if(purl_version)
|
||||
set(purl_version_option PURL_VERSION "${purl_version}")
|
||||
endif()
|
||||
|
||||
set(purl_args
|
||||
PURL_TYPE "${purl_type}"
|
||||
PURL_NAMESPACE "${purl_namespace}"
|
||||
PURL_NAME "${purl_name}"
|
||||
${purl_version_option}
|
||||
)
|
||||
|
||||
if(arg_PURL_QUALIFIERS)
|
||||
list(APPEND purl_args PURL_QUALIFIERS "${arg_PURL_QUALIFIERS}")
|
||||
endif()
|
||||
|
||||
if(arg_PURL_SUBPATH)
|
||||
list(APPEND purl_args PURL_SUBPATH "${arg_PURL_SUBPATH}")
|
||||
endif()
|
||||
|
||||
set(${arg_OUT_VAR} "${purl_args}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Helper function to decide which purl variants to add for a qt entity.
|
||||
function(_qt_internal_sbom_handle_qt_entity_purl_variants)
|
||||
_qt_internal_get_sbom_purl_handling_options(opt_args single_args multi_args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user