Skip to content

Commit

Permalink
Correct style issues found by CI
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Dec 11, 2024
1 parent a9dbd9d commit 3d3647b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
19 changes: 10 additions & 9 deletions rapids-cmake/cpm/detail/convert_patch_json.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ rapids_cpm_convert_patch_json
)
#]=======================================================================]
function(rapids_cpm_convert_patch_json )
function(rapids_cpm_convert_patch_json)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.conver_path_json")

set(options)
Expand All @@ -50,12 +50,13 @@ function(rapids_cpm_convert_patch_json )
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}")
set(file
"${CMAKE_BINARY_DIR}/rapids-cmake/patches/${_RAPIDS_PACKAGE_NAME}/embedded_patch_${_RAPIDS_INDEX}.${type}")

# Transfrom from a list of strings to a single file
string(JSON content_length LENGTH "${json_content}")
math(EXPR content_length "${content_length} - 1")
set(file_content )
unset(file_content)
foreach(index RANGE ${content_length})
string(JSON line GET "${json_content}" ${index})
string(APPEND file_content "${line}\n")
Expand All @@ -64,25 +65,25 @@ function(rapids_cpm_convert_patch_json )

set(${_RAPIDS_FILE_VAR} "${file}" PARENT_SCOPE)
elseif(_RAPIDS_FROM_FILE_TO_JSON)
#extract contents from `file`
# extract contents from `file`
file(STRINGS "${${_RAPIDS_FILE_VAR}}" file_content)
list(LENGTH file_content content_length)

#Get the file extension
# 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
# 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 [=[{
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)
Expand Down
3 changes: 2 additions & 1 deletion rapids-cmake/cpm/detail/generate_patch_command.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ function(rapids_cpm_generate_patch_command package_name version patch_command)
# 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})
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)
Expand Down
3 changes: 2 additions & 1 deletion rapids-cmake/cpm/detail/load_preset_versions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +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 "${_rapids_preset_version_file}")
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()
Expand Down
16 changes: 8 additions & 8 deletions rapids-cmake/cpm/detail/pinning_write_file.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ function(rapids_cpm_pinning_transform_patches package_name patches_array_var out

# 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)
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()
Expand All @@ -140,11 +139,11 @@ function(rapids_cpm_pinning_transform_patches package_name patches_array_var out

# 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
# 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 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()
Expand Down Expand Up @@ -179,7 +178,7 @@ Parameters:
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
# 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
Expand Down Expand Up @@ -252,7 +251,7 @@ function(rapids_cpm_pinning_add_json_entry package_name json_var)
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")
list(APPEND json_exclusion_list "patch" "proprietary_binary")
endif()

set(data_list override_json_data json_data)
Expand All @@ -272,7 +271,8 @@ function(rapids_cpm_pinning_add_json_entry package_name json_var)
string(JSON existing_value ERROR_VARIABLE dont_have GET "${pinned_json_entry}" ${member})
if(dont_have AND (NOT member IN_LIST exclusions))
string(JSON value GET "${data}" ${member})
rapids_cpm_pinning_create_and_set_member(${package_name} pinned_json_entry ${member} ${value})
rapids_cpm_pinning_create_and_set_member(${package_name} pinned_json_entry ${member}
${value})
endif()
endforeach()
endforeach()
Expand Down

0 comments on commit 3d3647b

Please sign in to comment.