-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when override of a default package uses the incorrect case (#708)
It is a common mistake to presume that all entries in a package override json should use lower case names, since the vast majority of default packages are all lower case. This causes silent 'failures' when the override doesn't work. We now normalize all package data internally so that overrides for `ABC`, `abc`, and `Abc` all map to the same package. In addition we have added information tracking the proper name of bundled packages. This allows us to warn when an override uses the non correct package name, and treat it like the proper name. Authors: - Robert Maynard (https://github.com/robertmaynard) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) URL: #708
- Loading branch information
1 parent
03ec7ef
commit 8c26daa
Showing
7 changed files
with
199 additions
and
33 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
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
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
68 changes: 68 additions & 0 deletions
68
testing/cpm/cpm_package_override-defaults-with-different-casing-warning.cmake
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,68 @@ | ||
#============================================================================= | ||
# Copyright (c) 2024, 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. | ||
#============================================================================= | ||
# rapids-cmake will output as `AUTHOR_WARNING` so we need to hijack | ||
# message to verify we see output we expect | ||
set(rmm_string "RAPIDS-CMake is assuming the override rMm is meant for the rmm package") | ||
set(gtest_string "RAPIDS-CMake is assuming the override gtest is meant for the GTest package") | ||
|
||
function(message mode content ) | ||
if(mode STREQUAL "AUTHOR_WARNING") | ||
if(content MATCHES "${rmm_string}") | ||
message(STATUS "==rmm warned==") | ||
set_property(GLOBAL PROPERTY rapids_cmake_rmm_warned TRUE) | ||
elseif(content MATCHES "${gtest_string}") | ||
message(STATUS "==gtest warned==") | ||
set_property(GLOBAL PROPERTY rapids_cmake_gtest_warned TRUE) | ||
endif() | ||
else() | ||
_message(${ARGV}) | ||
endif() | ||
endfunction() | ||
|
||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/package_override.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
# Need to write out an override file | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json | ||
[=[ | ||
{ | ||
"packages": { | ||
"rMm": { | ||
"git_url": "new_rmm_url", | ||
"git_shallow": "OFF", | ||
"exclude_from_all": "ON" | ||
}, | ||
"gtest": { | ||
"version": "3.00.A1" | ||
} | ||
} | ||
} | ||
]=]) | ||
|
||
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json) | ||
include("${rapids-cmake-dir}/cpm/detail/package_details.cmake") | ||
|
||
# Verify that we got our warnings | ||
get_property(rmm_warned GLOBAL PROPERTY rapids_cmake_rmm_warned) | ||
get_property(gtest_warned GLOBAL PROPERTY rapids_cmake_gtest_warned) | ||
if(NOT rmm_warned) | ||
message(FATAL_ERROR "Failed to warn about improper rmm casing") | ||
endif() | ||
if(NOT gtest_warned) | ||
message(FATAL_ERROR "Failed to warn about improper gtest casing") | ||
endif() |
67 changes: 67 additions & 0 deletions
67
testing/cpm/cpm_package_override-defaults-with-different-casing.cmake
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,67 @@ | ||
#============================================================================= | ||
# Copyright (c) 2024, 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(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/package_override.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
# Need to write out an override file | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/override.json | ||
[=[ | ||
{ | ||
"packages": { | ||
"rMm": { | ||
"git_url": "new_rmm_url", | ||
"git_shallow": "OFF", | ||
"exclude_from_all": "ON" | ||
}, | ||
"gtest": { | ||
"version": "3.00.A1" | ||
} | ||
} | ||
} | ||
]=]) | ||
|
||
rapids_cpm_package_override(${CMAKE_CURRENT_BINARY_DIR}/override.json) | ||
|
||
rapids_cpm_package_details(GTest version repository tag shallow exclude) | ||
if(NOT version STREQUAL "3.00.A1") | ||
message(FATAL_ERROR "custom version field was removed. ${version} was found instead") | ||
endif() | ||
if(NOT tag MATCHES "3.00.A1") | ||
message(FATAL_ERROR "custom version field not used when computing git_tag value. ${tag} was found instead") | ||
endif() | ||
if(NOT exclude MATCHES "OFF") | ||
message(FATAL_ERROR "default value of exclude not found. ${exclude} was found instead") | ||
endif() | ||
if(CPM_DOWNLOAD_ALL) | ||
message(FATAL_ERROR "CPM_DOWNLOAD_ALL should be false by default when an override exists that doesn't modify url or tag") | ||
endif() | ||
|
||
rapids_cpm_package_details(rmm version repository tag shallow exclude) | ||
if(NOT repository MATCHES "new_rmm_url") | ||
message(FATAL_ERROR "custom url field was not used. ${repository} was found instead") | ||
endif() | ||
if(NOT shallow MATCHES "OFF") | ||
message(FATAL_ERROR "override should not change git_shallow value. ${shallow} was found instead") | ||
endif() | ||
if(NOT exclude MATCHES "ON") | ||
message(FATAL_ERROR "override should have changed exclude value. ${exclude} was found instead") | ||
endif() | ||
if(NOT CPM_DOWNLOAD_ALL) | ||
message(FATAL_ERROR "CPM_DOWNLOAD_ALL should be set to true when an override exists with a custom repository") | ||
endif() |