From 36939de6814bd84234fe1b06aaa08fec605fc658 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 27 Jan 2025 12:03:12 -0500 Subject: [PATCH] Fea/support embedded patch content (#728) rapids-cmake versions.json files now support embedded patch files. This feature is leveraged by rapids-cmake generated pinned `versions.json` to make the file full relocatable. Fixes https://github.com/rapidsai/rapids-cmake/issues/718 Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/rapids-cmake/pull/728 --- docs/cpm.rst | 25 +++-- docs/packages/patches_inline.json | 33 +++++++ .../cpm/detail/convert_patch_json.cmake | 96 +++++++++++++++++++ .../cpm/detail/generate_patch_command.cmake | 12 ++- .../cpm/detail/load_preset_versions.cmake | 8 +- .../cpm/detail/pinning_write_file.cmake | 89 ++++++++++++++++- testing/cpm/CMakeLists.txt | 1 + .../CMakeLists.txt | 64 +++++++++++++ .../override.json | 64 +++++++++++++ .../verify/CMakeLists.txt | 32 ++++++- .../cpm_generate_pins-simple/CMakeLists.txt | 10 +- testing/cpm/verify_generated_pins.cmake | 4 +- 12 files changed, 415 insertions(+), 23 deletions(-) create mode 100644 docs/packages/patches_inline.json create mode 100644 rapids-cmake/cpm/detail/convert_patch_json.cmake create mode 100644 testing/cpm/cpm_find-patch-command-embedded/CMakeLists.txt create mode 100644 testing/cpm/cpm_find-patch-command-embedded/override.json diff --git a/docs/cpm.rst b/docs/cpm.rst index 32df24f2..0880bafe 100644 --- a/docs/cpm.rst +++ b/docs/cpm.rst @@ -197,19 +197,32 @@ as needed. The existence of a patch entry in the package definition being used will cause the `always_download` value always to be true. - .. literalinclude:: /packages/patches.json - :language: json - Each dictionary in the array of patches contains the following fields: ``file`` - A required string representing the git diff ( .diff ) or patch ( .patch ) to apply. - Absolute and relative paths are supported. Relative paths are - evaluated in relation to the ``rapids-cmake/cpm/patches`` directory. + + .. literalinclude:: /packages/patches.json + :language: json + + Mutually exclusive string field with `inline_patch`. Only one of these fields may be provided. + + Absolute or relative path to the git diff ( .diff ) or patch ( .patch ) to apply. + Relative paths are evaluated in relation to the ``rapids-cmake/cpm/patches`` directory. Supports the following placeholders: - ``${current_json_dir}`` will be evaluated to the absolute path to the directory holding the current json file + ``inline_patch`` + + .. literalinclude:: /packages/patches_inline.json + :language: json + + Mutually exclusive dictionary field with `file`. Only one of these fields may be provided. + + Required keys for `inline_patch` are: + * `type` the format of the patch, either `diff` ( git diff ) or `patch` ( git format-patch ). + * `content` the lines of the patch file represented as an array of strings ( each element is a line ). + ``issue`` A required string that explains the need for the patch. Preference is for the string to also contain the URL to the upstream issue or PR that diff --git a/docs/packages/patches_inline.json b/docs/packages/patches_inline.json new file mode 100644 index 00000000..fa9a579f --- /dev/null +++ b/docs/packages/patches_inline.json @@ -0,0 +1,33 @@ +{ + "patches": [ + { + "inline_patch": { + "type": "patch", + "content": [ + "From deacd3fafd7fcfee954ae3044ae3ab60d36a9f3a Mon Sep 17 00:00:00 2001", + "From: Robert Maynard ", + "Date: Wed, 31 Jan 2024 15:00:47 -0500", + "Subject: [PATCH 1/2] Move GIT SHA1", + "", + "---", + " git_file_1.txt | 1 +", + " 1 file changed, 1 insertion(+)", + " create mode 100644 git_file_1.txt", + "", + "diff --git a/git_file_1.txt b/git_file_1.txt", + "new file mode 100644", + "index 00000000..b242c360", + "--- /dev/null", + "+++ b/git_file_1.txt", + "@@ -0,0 +1 @@", + "+added file", + "--", + "2.43.0", + "" + ] + }, + "issue": "Example of an inline patch", + "fixed_in": "" + } + ] +} diff --git a/rapids-cmake/cpm/detail/convert_patch_json.cmake b/rapids-cmake/cpm/detail/convert_patch_json.cmake new file mode 100644 index 00000000..d844beca --- /dev/null +++ b/rapids-cmake/cpm/detail/convert_patch_json.cmake @@ -0,0 +1,96 @@ +#============================================================================= +# Copyright (c) 2024-2025, NVIDIA CORPORATION. +# +# 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. +#============================================================================= +include_guard(GLOBAL) + +#[=======================================================================[.rst: +rapids_cpm_convert_patch_json +------------------------------- + +.. versionadded:: v25.02.00 + + +.. code-block:: cmake + + rapids_cpm_convert_patch_json( (FROM_JSON_TO_FILE|FROM_FILE_TO_JSON) + + FILE_VAR + # required for FROM_JSON_TO_FILE + ) + +#]=======================================================================] +function(rapids_cpm_convert_patch_json) + list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.conver_path_json") + + set(options) + set(one_value FROM_JSON_TO_FILE FROM_FILE_TO_JSON FILE_VAR PACKAGE_NAME INDEX) + set(multi_value) + cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) + + if(NOT _RAPIDS_FILE_VAR) + message(FATAL_ERROR "rapids_cpm_convert_patch_json required field of `FILE_VAR` is missing") + endif() + + if(_RAPIDS_FROM_JSON_TO_FILE) + set(json "${${_RAPIDS_FROM_JSON_TO_FILE}}") + + string(JSON type GET "${json}" "type") + string(JSON json_content GET "${json}" "content") + + # Figure out the file path + set(file + "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${_RAPIDS_PACKAGE_NAME}/embedded_patch_${_RAPIDS_INDEX}.${type}" + ) + + # Transform from a list of strings to a single file + string(JSON content_length LENGTH "${json_content}") + math(EXPR content_length "${content_length} - 1") + unset(file_content) + # cmake-lint: disable=E1120 + foreach(index RANGE ${content_length}) + string(JSON line GET "${json_content}" ${index}) + string(APPEND file_content "${line}\n") + endforeach() + file(WRITE "${file}" "${file_content}") + + set(${_RAPIDS_FILE_VAR} "${file}" PARENT_SCOPE) + elseif(_RAPIDS_FROM_FILE_TO_JSON) + # extract contents from `file` + file(STRINGS "${${_RAPIDS_FILE_VAR}}" file_content) + list(LENGTH file_content content_length) + + # Get the file extension + cmake_path(GET ${_RAPIDS_FILE_VAR} EXTENSION LAST_ONLY patch_ext) + string(SUBSTRING "${patch_ext}" 1 -1 patch_ext) + + # add each line as a json array element + set(inline_patch [=[ [ ] ]=]) + foreach(line IN LISTS file_content) + string(JSON inline_patch SET "${inline_patch}" ${content_length} "\"${line}\"") + endforeach() + + set(json_content + [=[{ + "type" : "", + "content" : [] + }]=]) + string(JSON json_content SET "${json_content}" "type" "\"${patch_ext}\"") + string(JSON json_content SET "${json_content}" "content" "${inline_patch}") + set(${_RAPIDS_FROM_FILE_TO_JSON} "${json_content}" PARENT_SCOPE) + else() + message(FATAL_ERROR "rapids_cpm_convert_patch_json unsupported mode: ${mode}") + endif() + +endfunction() diff --git a/rapids-cmake/cpm/detail/generate_patch_command.cmake b/rapids-cmake/cpm/detail/generate_patch_command.cmake index ee067bbf..e6567748 100644 --- a/rapids-cmake/cpm/detail/generate_patch_command.cmake +++ b/rapids-cmake/cpm/detail/generate_patch_command.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -88,7 +88,16 @@ function(rapids_cpm_generate_patch_command package_name version patch_command) rapids_cpm_json_get_value(${patch_data} fixed_in) if(NOT fixed_in OR version VERSION_LESS fixed_in) rapids_cpm_json_get_value(${patch_data} file) + rapids_cpm_json_get_value(${patch_data} inline_patch) rapids_cpm_json_get_value(${patch_data} issue) + + # Convert any embedded patch to a file. + if(inline_patch) + include("${rapids-cmake-dir}/cpm/detail/convert_patch_json.cmake") + rapids_cpm_convert_patch_json(FROM_JSON_TO_FILE inline_patch FILE_VAR file PACKAGE_NAME + ${package_name} INDEX ${index}) + endif() + if(file AND issue) cmake_language(EVAL CODE "set(file ${file})") cmake_path(IS_RELATIVE file is_relative) @@ -103,6 +112,7 @@ function(rapids_cpm_generate_patch_command package_name version patch_command) list(APPEND patch_required_to_apply "${required}") endif() unset(file) + unset(inline_patch) unset(issue) endif() endforeach() diff --git a/rapids-cmake/cpm/detail/load_preset_versions.cmake b/rapids-cmake/cpm/detail/load_preset_versions.cmake index 95e81e83..e16410f9 100644 --- a/rapids-cmake/cpm/detail/load_preset_versions.cmake +++ b/rapids-cmake/cpm/detail/load_preset_versions.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2021-2024, NVIDIA CORPORATION. +# Copyright (c) 2021-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,7 +49,7 @@ function(rapids_cpm_load_preset_versions) endif() if(NOT EXISTS "${_rapids_preset_version_file}") - message(FATAL_ERROR "rapids_cpm can't load '${filepath}' to find package version information, verify it exists" + message(FATAL_ERROR "rapids_cpm can't load '${_rapids_preset_version_file}' to find package version information, verify it exists" ) endif() @@ -85,8 +85,8 @@ function(rapids_cpm_load_preset_versions) ) else() set_property(GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_json "${data}") - set_property(GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_json_file "${filepath}") - + set_property(GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_json_file + "${_rapids_preset_version_file}") set_property(GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_proper_name "${package_name}") endif() endforeach() diff --git a/rapids-cmake/cpm/detail/pinning_write_file.cmake b/rapids-cmake/cpm/detail/pinning_write_file.cmake index 8b423c0d..59877720 100644 --- a/rapids-cmake/cpm/detail/pinning_write_file.cmake +++ b/rapids-cmake/cpm/detail/pinning_write_file.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -93,6 +93,65 @@ function(rapids_cpm_pinning_extract_source_git_info package git_url_var git_sha_ endfunction() +#[=======================================================================[.rst: +rapids_cpm_pinning_transform_patches +------------------------------------ + +.. versionadded:: v25.02.00 + +Transform the `patches` value json string to not reference any files +on disk but instead embed the patches contents directly in the json + +Parameters: + +``value_var`` + Variable name of the json object of the patch content to transform + +#]=======================================================================] +function(rapids_cpm_pinning_transform_patches package_name patches_array_var output_var) + + include("${rapids-cmake-dir}/cpm/detail/convert_patch_json.cmake") + + # We need to get the `files` key and transform it + set(json_data "${${patches_array_var}}") + string(JSON patch_count LENGTH "${json_data}") + if(patch_count GREATER_EQUAL 1) + + # Setup state so that we can eval `current_json_dir` placeholder + string(TOLOWER "${package_name}" normalized_pkg_name) + get_property(json_path GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_override_json_file) + if(NOT json_path) + get_property(json_path GLOBAL PROPERTY rapids_cpm_${normalized_pkg_name}_json_file) + endif() + cmake_path(GET json_path PARENT_PATH current_json_dir) + + math(EXPR patch_count "${patch_count} - 1") + # cmake-lint: disable=E1120 + foreach(index RANGE ${patch_count}) + string(JSON patch_data GET "${json_data}" ${index}) + string(JSON file_path ERROR_VARIABLE have_error GET "${patch_data}" file) + cmake_language(EVAL CODE "set(file_path ${file_path})") + if(file_path) + # Eval the file to transform `current_json_dir` + cmake_path(IS_RELATIVE file_path is_relative) + if(is_relative) + string(PREPEND file_path "${rapids-cmake-dir}/cpm/patches/") + endif() + + # Read the file and transform to string + rapids_cpm_convert_patch_json(FROM_FILE_TO_JSON as_json FILE_VAR file_path) + # Remove the the file entry and replace it with the correct inline json format + string(JSON patch_data ERROR_VARIABLE have_error REMOVE "${patch_data}" file) + set(json_key "inline_patch") + string(JSON patch_data ERROR_VARIABLE have_error SET "${patch_data}" "${json_key}" + "${as_json}") + string(JSON json_data SET "${json_data}" ${index} "${patch_data}") + endif() + endforeach() + endif() + set(${output_var} "${json_data}" PARENT_SCOPE) +endfunction() + #[=======================================================================[.rst: rapids_cpm_pinning_create_and_set_member ---------------------------------------- @@ -105,6 +164,9 @@ new value. Parameters: +``package_name`` + Name of the project that this json object is associated to. + ``json_var`` Variable name of the json object to both read and write too. @@ -114,8 +176,12 @@ Parameters: Holds the var that should be written to the json object #]=======================================================================] -function(rapids_cpm_pinning_create_and_set_member json_var key value) +function(rapids_cpm_pinning_create_and_set_member package_name json_var key value) + if(key MATCHES "patches") + # Transform inplace the value to only have inline patches + rapids_cpm_pinning_transform_patches(${package_name} value value) + endif() # Identify special values types that shouldn't be treated as a string # https://gitlab.kitware.com/cmake/cmake/-/issues/25716 if(value MATCHES "(^true$|^false$|^null$|^\\{|^\\[)") @@ -181,7 +247,19 @@ function(rapids_cpm_pinning_add_json_entry package_name json_var) include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") get_default_json(${package_name} json_data) get_override_json(${package_name} override_json_data) - foreach(data IN LISTS override_json_data json_data) + + set(override_exclusion_list "") + set(json_exclusion_list "") + # patch and proprietary_binary can't propagate if an override exists + if(override_json_data) + list(APPEND json_exclusion_list "patch" "proprietary_binary") + endif() + + set(data_list override_json_data json_data) + set(exclusion_list override_exclusion_list json_exclusion_list) + foreach(data_var exclusion_var IN ZIP_LISTS data_list exclusion_list) + set(data "${${data_var}}") + set(exclusions "${${exclusion_var}}") if(NOT data) # Need to handle both json_data and the override being empty continue() @@ -192,9 +270,10 @@ function(rapids_cpm_pinning_add_json_entry package_name json_var) foreach(index RANGE ${entry_count}) string(JSON member MEMBER "${data}" ${index}) string(JSON existing_value ERROR_VARIABLE dont_have GET "${pinned_json_entry}" ${member}) - if(dont_have) + if(dont_have AND (NOT member IN_LIST exclusions)) string(JSON value GET "${data}" ${member}) - rapids_cpm_pinning_create_and_set_member(pinned_json_entry ${member} ${value}) + rapids_cpm_pinning_create_and_set_member(${package_name} pinned_json_entry ${member} + ${value}) endif() endforeach() endforeach() diff --git a/testing/cpm/CMakeLists.txt b/testing/cpm/CMakeLists.txt index cf1c3783..f1df42cf 100644 --- a/testing/cpm/CMakeLists.txt +++ b/testing/cpm/CMakeLists.txt @@ -28,6 +28,7 @@ add_cmake_config_test( cpm_find-existing-target-to-export-sets ) add_cmake_config_test( cpm_find-gtest-no-gmock ) add_cmake_config_test( cpm_find-options-escaped ) add_cmake_config_test( cpm_find-patch-command NO_CPM_CACHE ) +add_cmake_config_test( cpm_find-patch-command-embedded NO_CPM_CACHE ) add_cmake_config_test( cpm_find-patch-command-required NO_CPM_CACHE ) add_cmake_config_test( cpm_find-patch-command-required-fails NO_CPM_CACHE SHOULD_FAIL "rapids-cmake [fmt]: failed to apply patch") add_cmake_config_test( cpm_find-restore-cpm-vars ) diff --git a/testing/cpm/cpm_find-patch-command-embedded/CMakeLists.txt b/testing/cpm/cpm_find-patch-command-embedded/CMakeLists.txt new file mode 100644 index 00000000..99803bb8 --- /dev/null +++ b/testing/cpm/cpm_find-patch-command-embedded/CMakeLists.txt @@ -0,0 +1,64 @@ +#============================================================================= +# Copyright (c) 2024-2025, NVIDIA CORPORATION. +# +# 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. +#============================================================================= +cmake_minimum_required(VERSION 3.26.4) +project(rapids-cpm_find-patch-command-project LANGUAGES CXX) + +include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") +rapids_cpm_package_details(fmt version repository tag shallow exclude) + +set(deps_dir "${CMAKE_CURRENT_BINARY_DIR}/_fmt_dep") +if(NOT EXISTS "${deps_dir}") + file(MAKE_DIRECTORY "${deps_dir}") + find_package(Git) + execute_process( + COMMAND ${GIT_EXECUTABLE} clone --depth 1 --branch "${tag}" "${repository}" + WORKING_DIRECTORY "${deps_dir}") +endif() + +set(fmt_dir "${deps_dir}/fmt") +list(APPEND CMAKE_PREFIX_PATH "${fmt_dir}") + +include(${rapids-cmake-dir}/cpm/init.cmake) +rapids_cpm_init() + +include(${rapids-cmake-dir}/cpm/package_override.cmake) +rapids_cpm_package_override(${CMAKE_CURRENT_SOURCE_DIR}/override.json) + +include(${rapids-cmake-dir}/cpm/fmt.cmake) +rapids_cpm_fmt() + +if(NOT "${fmt_ADDED}") + message(FATAL_ERROR "The found repo was used rather than downloading and patching a new version") +endif() + +# Verify that the two files that we inserted into the fmt source tree exist +# Which proves the patches in the override are properly applied +if(NOT EXISTS "${fmt_SOURCE_DIR}/git_file_1.txt") + message(FATAL_ERROR "failed to apply fmt first patch") +endif() + +if(NOT EXISTS "${fmt_SOURCE_DIR}/git_file_2.txt") + message(FATAL_ERROR "failed to apply fmt second patch") +endif() + +execute_process( + COMMAND ${GIT_EXECUTABLE} diff --quiet ${tag} + RESULT_VARIABLE REPO_IS_PATCHED + WORKING_DIRECTORY "${fmt_SOURCE_DIR}") + +if(NOT ${REPO_IS_PATCHED}) + message(FATAL_ERROR "The repo was downloaded to ${fmt_SOURCE_DIR} but not patched.") +endif() diff --git a/testing/cpm/cpm_find-patch-command-embedded/override.json b/testing/cpm/cpm_find-patch-command-embedded/override.json new file mode 100644 index 00000000..64509a6c --- /dev/null +++ b/testing/cpm/cpm_find-patch-command-embedded/override.json @@ -0,0 +1,64 @@ +{ + "packages": { + "fmt": { + "patches": [ + { + "inline_patch": { + "type": "patch", + "content": [ + "From deacd3fafd7fcfee954ae3044ae3ab60d36a9f3a Mon Sep 17 00:00:00 2001", + "From: Robert Maynard ", + "Date: Wed, 31 Jan 2024 15:00:47 -0500", + "Subject: [PATCH 1/2] Move GIT SHA1", + "", + "---", + " git_file_1.txt | 1 +", + " 1 file changed, 1 insertion(+)", + " create mode 100644 git_file_1.txt", + "", + "diff --git a/git_file_1.txt b/git_file_1.txt", + "new file mode 100644", + "index 00000000..b242c360", + "--- /dev/null", + "+++ b/git_file_1.txt", + "@@ -0,0 +1 @@", + "+added file", + "--", + "2.43.0", + "" + ] + }, + "issue": "Move git sha1", + "fixed_in": "" + }, + { + "inline_patch": { + "type": "patch", + "content": [ + "From 3588e151030a30661b310a876f7cc450d6ca9201 Mon Sep 17 00:00:00 2001", + "From: Robert Maynard ", + "Date: Wed, 31 Jan 2024 15:01:21 -0500", + "Subject: [PATCH 2/2] Move GIT SHA1 a second time", + "---", + " git_file_2.txt | 1 +", + " 1 file changed, 1 insertion(+)", + " create mode 100644 git_file_2.txt", + "diff --git a/git_file_2.txt b/git_file_2.txt", + "new file mode 100644", + "index 00000000..fa240558", + "--- /dev/null", + "+++ b/git_file_2.txt", + "@@ -0,0 +1 @@", + "+added another file", + "--", + "2.43.0", + "" + ] + }, + "issue": "Move git sha1 a second time", + "fixed_in": "" + } + ] + } + } +} diff --git a/testing/cpm/cpm_generate_pins-format-patches/verify/CMakeLists.txt b/testing/cpm/cpm_generate_pins-format-patches/verify/CMakeLists.txt index 3c41a509..691f8cdc 100644 --- a/testing/cpm/cpm_generate_pins-format-patches/verify/CMakeLists.txt +++ b/testing/cpm/cpm_generate_pins-format-patches/verify/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -33,3 +33,33 @@ endif() if(NOT pin_cuco_tag STREQUAL "f823d30d6b08a60383266db25821074dbdbe5822") message(FATAL_ERROR "pinned cuco tag (${pin_cuco_tag}) doesn't match hardcoded SHA1(f823d30...)") endif() + +# Verify that the json file has the inline patches. + +function(validate_has_inline_patches package_name) + include("${rapids-cmake-dir}/cpm/detail/get_override_json.cmake") + get_override_json(${package_name} json_data) + + string(TOLOWER "${package_name}" normalized_pkg_name) + get_property(override_json_path GLOBAL + PROPERTY rapids_cpm_${normalized_pkg_name}_override_json_file) + string(JSON json_data ERROR_VARIABLE no_override_patch GET "${json_data}" patches) + + # Gather number of patches + string(JSON patch_count LENGTH "${json_data}") + if(patch_count GREATER_EQUAL 1) + math(EXPR patch_count "${patch_count} - 1") + foreach(index RANGE ${patch_count}) + string(JSON patch_data GET "${json_data}" ${index}) + string(JSON value ERROR_VARIABLE have_error GET "${patch_data}" "inline_patch") + if(have_error) + message(FATAL_ERROR "${package_name} patch entry ${patch_count} wasn't an inline patch") + endif() + endforeach() + else() + message(FATAL_ERROR "Was expecting patches to exist, but none found for ${package_name}") + endif() +endfunction() + +validate_has_inline_patches(rmm) +validate_has_inline_patches(cuco) diff --git a/testing/cpm/cpm_generate_pins-simple/CMakeLists.txt b/testing/cpm/cpm_generate_pins-simple/CMakeLists.txt index 9cb6ea33..44b72cbe 100644 --- a/testing/cpm/cpm_generate_pins-simple/CMakeLists.txt +++ b/testing/cpm/cpm_generate_pins-simple/CMakeLists.txt @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,17 +17,19 @@ cmake_minimum_required(VERSION 3.26.4) project(rapids-test-project LANGUAGES CXX) include(${rapids-cmake-dir}/cpm/init.cmake) +include(${rapids-cmake-dir}/cpm/fmt.cmake) include(${rapids-cmake-dir}/cpm/rmm.cmake) rapids_cpm_init(GENERATE_PINNED_VERSIONS) -rapids_cpm_rmm() +rapids_cpm_fmt(DOWNLOAD_ONLY ON) +rapids_cpm_rmm(DOWNLOAD_ONLY ON) # only check projects that were downloaded by CPM (ignore those already in the build environment) -foreach(proj IN ITEMS rmm fmt spdlog) +foreach(proj IN ITEMS rmm fmt) if(${proj}_SOURCE_DIR) list(APPEND projects-to-verify ${proj}) endif() endforeach() include("${rapids-cmake-testing-dir}/cpm/verify_generated_pins.cmake") -verify_generated_pins(verify_pins PROJECTS rmm fmt spdlog) +verify_generated_pins(verify_pins PROJECTS rmm fmt) diff --git a/testing/cpm/verify_generated_pins.cmake b/testing/cpm/verify_generated_pins.cmake index 014f1234..147c7ba5 100644 --- a/testing/cpm/verify_generated_pins.cmake +++ b/testing/cpm/verify_generated_pins.cmake @@ -1,5 +1,5 @@ #============================================================================= -# Copyright (c) 2024, NVIDIA CORPORATION. +# Copyright (c) 2024-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ function(verify_generated_pins target_name) foreach(proj IN LISTS _RAPIDS_PROJECTS) if(NOT CPM_PACKAGE_${proj}_SOURCE_DIR) - message(FATAL_ERROR "Attempting to verify a project that was not cloned as part of this build") + message(FATAL_ERROR "Attempting to verify a project ( ${proj} ) that was not cloned as part of this build") endif() endforeach()