Skip to content

Commit

Permalink
Merge branch 'branch-21.08' into fea/rapids_export_more_robust_versio…
Browse files Browse the repository at this point in the history
…n_support
  • Loading branch information
robertmaynard committed Jul 9, 2021
2 parents 564af1a + 4e4e1e1 commit 53e7e8d
Show file tree
Hide file tree
Showing 27 changed files with 300 additions and 179 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
list(APPEND CMAKE_MODULE_PATH "${rapids-cmake-dir}")
endif()

#install a hook that sets up `rapids-cmake-dir` and `CMAKE_MODULE_PATH`
#all the way up the call-stack
cmake_language(DEFER DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
CALL include "${rapids-cmake-dir}/../init.cmake")
# install a hook that sets up `rapids-cmake-dir` and `CMAKE_MODULE_PATH` all the way up the
# call-stack
cmake_language(DEFER DIRECTORY ${CMAKE_CURRENT_LIST_DIR} CALL include
"${rapids-cmake-dir}/../init.cmake")
11 changes: 11 additions & 0 deletions ci/checks/cmake_config_format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"format": {
"line_width": 100,
"tab_size": 2,
"command_case": "unchanged",
"dangle_parens": false,
"max_subgroups_hwrap": 4,
"min_prefix_chars": 32,
"max_pargs_hwrap": 999
}
}
14 changes: 14 additions & 0 deletions ci/checks/cmake_config_lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"lint": {
"disabled_codes": ["C0301", "C0112"],
"function_pattern": "[0-9A-z_]+",
"macro_pattern": "[0-9A-z_]+",
"global_var_pattern": "[A-z][0-9A-z_]+",
"internal_var_pattern": "rapids[_-][A-z][0-9A-z_]+",
"local_var_pattern": "[A-z][A-z0-9_]+",
"private_var_pattern": "rapids[_-][0-9A-z_]+",
"public_var_pattern": "[A-z][0-9A-z_]+",
"argument_var_pattern": "[A-z][A-z0-9_]+",
"keyword_pattern": "[A-z][0-9A-z_]+"
}
}
14 changes: 14 additions & 0 deletions ci/checks/cmake_config_testing_lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"lint": {
"disabled_codes": ["C0301", "C0111","C0112"],
"function_pattern": "[0-9A-z_]+",
"macro_pattern": "[0-9A-z_]+",
"global_var_pattern": "[A-z][0-9A-z_]+",
"internal_var_pattern": "_[A-z][0-9A-z_]+",
"local_var_pattern": "[A-z][A-z0-9_]+",
"private_var_pattern": "_[0-9A-z_]+",
"public_var_pattern": "[A-z][0-9A-z_]+",
"argument_var_pattern": "[A-z][A-z0-9_]+",
"keyword_pattern": "[A-z][0-9A-z_]+"
}
}
66 changes: 66 additions & 0 deletions ci/checks/style.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,69 @@
#############################
# rapids-cmake Style Tester #
#############################

# Ignore errors and set path
set +e
PATH=/opt/conda/bin:$PATH
LC_ALL=C.UTF-8
LANG=C.UTF-8

# Activate common conda env
. /opt/conda/etc/profile.d/conda.sh
conda activate rapids

# Run cmake-format / cmake-lint and get results/return code
CMAKE_FILES=(`find rapids-cmake/ | grep -E "^.*\.cmake?$|^.*/CMakeLists.txt$"`)
CMAKE_FILES+=("CMakeLists.txt")

CMAKE_FORMATS=()
CMAKE_FORMAT_RETVAL=0

CMAKE_LINTS=()
CMAKE_LINT_RETVAL=0

for cmake_file in "${CMAKE_FILES[@]}"; do
cmake-format --in-place --first-comment-is-literal --config-files ./cmake-format-rapids-cmake.json ./ci/checks/cmake_config_format.json -- ${cmake_file}
TMP_CMAKE_FORMAT=`git diff --color --exit-code -- ${cmake_file}`
TMP_CMAKE_FORMAT_RETVAL=$?
if [ "$TMP_CMAKE_FORMAT_RETVAL" != "0" ]; then
CMAKE_FORMAT_RETVAL=1
CMAKE_FORMATS+=("$TMP_CMAKE_FORMAT")
fi

TMP_CMAKE_LINT=`cmake-lint --config-files ./cmake-format-rapids-cmake.json ./ci/checks/cmake_config_format.json ./ci/checks/cmake_config_lint.json -- ${cmake_file}`
TMP_CMAKE_LINT_RETVAL=$?
if [ "$TMP_CMAKE_LINT_RETVAL" != "0" ]; then
CMAKE_LINT_RETVAL=1
CMAKE_LINTS+=("$TMP_CMAKE_LINT")
fi
done

# Output results if failure otherwise show pass
if [ "$CMAKE_FORMAT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: cmake format check; begin output\n\n"
for CMAKE_FORMAT in "${CMAKE_FORMATS[@]}"; do
echo -e "$CMAKE_FORMAT"
echo -e "\n"
done
echo -e "\n\n>>>> FAILED: cmake format check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: cmake format check\n\n"
fi

if [ "$CMAKE_LINT_RETVAL" != "0" ]; then
echo -e "\n\n>>>> FAILED: cmake lint check; begin output\n\n"
for CMAKE_LINT in "${CMAKE_LINTS[@]}"; do
echo -e "$CMAKE_LINT"
echo -e "\n"
done
echo -e "\n\n>>>> FAILED: cmake lint check; end output\n\n"
else
echo -e "\n\n>>>> PASSED: cmake lint check\n\n"
fi

RETVALS=($CMAKE_FORMAT_RETVAL $CMAKE_LINT_RETVAL)
IFS=$'\n'
RETVAL=`echo "${RETVALS[*]}" | sort -nr | head -n1`

exit $RETVAL
55 changes: 55 additions & 0 deletions ci/release/update-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
########################
# rapids-cmake Version Updater #
########################

## Usage
# bash update-version.sh <type>
# where <type> is either `major`, `minor`, `patch`

set -e

# Grab argument for release type
RELEASE_TYPE=$1

# Get current version and calculate next versions
CURRENT_TAG=`git tag | grep -xE 'v[0-9\.]+' | sort --version-sort | tail -n 1 | tr -d 'v'`
CURRENT_MAJOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[1]}'`
CURRENT_MINOR=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[2]}'`
CURRENT_PATCH=`echo $CURRENT_TAG | awk '{split($0, a, "."); print a[3]}'`
NEXT_MAJOR=$((CURRENT_MAJOR + 1))
NEXT_MINOR=$((CURRENT_MINOR + 1))
NEXT_PATCH=$((CURRENT_PATCH + 1))
NEXT_FULL_TAG=""
NEXT_SHORT_TAG=""

# Determine release type
if [ "$RELEASE_TYPE" == "major" ]; then
NEXT_FULL_TAG="${NEXT_MAJOR}.0.0"
NEXT_SHORT_TAG="${NEXT_MAJOR}.0"
elif [ "$RELEASE_TYPE" == "minor" ]; then
NEXT_FULL_TAG="${CURRENT_MAJOR}.${NEXT_MINOR}.0"
NEXT_SHORT_TAG="${CURRENT_MAJOR}.${NEXT_MINOR}"
elif [ "$RELEASE_TYPE" == "patch" ]; then
NEXT_FULL_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}.${NEXT_PATCH}"
NEXT_SHORT_TAG="${CURRENT_MAJOR}.${CURRENT_MINOR}"
else
echo "Incorrect release type; use 'major', 'minor', or 'patch' as an argument"
exit 1
fi

echo "Preparing '$RELEASE_TYPE' release [$CURRENT_TAG -> $NEXT_FULL_TAG]"

# Inplace sed replace; workaround for Linux and Mac
function sed_runner() {
sed -i.bak ''"$1"'' $2 && rm -f ${2}.bak
}

sed_runner 's/'" VERSION .*"'/'" VERSION ${NEXT_FULL_TAG}"'/g' CMakeLists.txt

sed_runner 's/version=.*/version=\"'"${NEXT_FULL_TAG}"'\",/g' python/setup.py

sed_runner 's/'"PROJECT_NUMBER = .*"'/'"PROJECT_NUMBER = ${NEXT_SHORT_TAG}"'/g' doxygen/Doxyfile

sed_runner 's/'"version =.*"'/'"version = \"${NEXT_SHORT_TAG}\""'/g' python/docs/conf.py
sed_runner 's/'"release =.*"'/'"release = \"${NEXT_FULL_TAG}\""'/g' python/docs/conf.py
6 changes: 3 additions & 3 deletions rapids-cmake/cmake/build_type.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cmake_build_type
-----------------------
Expand Down Expand Up @@ -45,8 +44,9 @@ function(rapids_cmake_build_type default_type)

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(VERBOSE "Setting build type to '${default_type}' since none specified.")
set(CMAKE_BUILD_TYPE "${default_type}" CACHE STRING "Choose the type of build." FORCE)
set(CMAKE_BUILD_TYPE "${default_type}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel"
"RelWithDebInfo")
endif()
endfunction()
1 change: 0 additions & 1 deletion rapids-cmake/cmake/make_global.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cmake_make_global
------------------------
Expand Down
9 changes: 3 additions & 6 deletions rapids-cmake/cmake/parse_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cmake_parse_version
--------------------------
Expand Down Expand Up @@ -74,9 +73,8 @@ function(rapids_cmake_parse_version mode version_value out_variable_name)

list(LENGTH version_as_list len)

# Extract each component and make sure they aren't
# empty before setting. Enforces the rule that
# a value/character must exist between each `.`
# Extract each component and make sure they aren't empty before setting. Enforces the rule that a
# value/character must exist between each `.`
if(mode STREQUAL "MAJOR" AND len GREATER_EQUAL 1)
list(GET version_as_list 0 extracted_component)
if(NOT extracted_component STREQUAL "")
Expand All @@ -98,8 +96,7 @@ function(rapids_cmake_parse_version mode version_value out_variable_name)
elseif(mode STREQUAL "MAJOR_MINOR" AND len GREATER_EQUAL 2)
list(GET version_as_list 0 extracted_major)
list(GET version_as_list 1 extracted_minor)
if(NOT extracted_major STREQUAL "" AND
NOT extracted_minor STREQUAL "")
if(NOT extracted_major STREQUAL "" AND NOT extracted_minor STREQUAL "")
set(${out_variable_name} "${extracted_major}.${extracted_minor}" PARENT_SCOPE)
endif()

Expand Down
43 changes: 22 additions & 21 deletions rapids-cmake/cmake/support_conda_env.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cmake_support_conda_env
------------------------------
Expand Down Expand Up @@ -63,37 +62,39 @@ function(rapids_cmake_support_conda_env target)
if("$ENV{CONDA_BUILD}" STREQUAL "1")
set(in_conda_build True)
elseif(DEFINED ENV{CONDA_PREFIX})
set(in_conda_prefix True)
set(in_conda_prefix True)
endif()

if(in_conda_build OR in_conda_prefix)

if (ARGV1 STREQUAL "MODIFY_PREFIX_PATH")
set(modify_prefix_path TRUE )
if(ARGV1 STREQUAL "MODIFY_PREFIX_PATH")
set(modify_prefix_path TRUE)
endif()

add_library(${target} INTERFACE )
set(prefix_paths )
add_library(${target} INTERFACE)
set(prefix_paths)

if(in_conda_build)
target_include_directories(${target} INTERFACE "$ENV{BUILD_PREFIX}/include" "$ENV{PREFIX}/include")
target_link_directories(${target} INTERFACE "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")
target_include_directories(${target} INTERFACE "$ENV{BUILD_PREFIX}/include"
"$ENV{PREFIX}/include")
target_link_directories(${target} INTERFACE "$ENV{BUILD_PREFIX}/lib" "$ENV{PREFIX}/lib")

if( modify_prefix_path )
list(PREPEND CMAKE_PREFIX_PATH "$ENV{BUILD_PREFIX}" "$ENV{PREFIX}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE)
message(VERBOSE "Conda build detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
endif()
if(modify_prefix_path)
list(PREPEND CMAKE_PREFIX_PATH "$ENV{BUILD_PREFIX}" "$ENV{PREFIX}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE)
message(VERBOSE "Conda build detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
endif()

elseif(in_conda_prefix)
target_include_directories(${target} INTERFACE "$ENV{CONDA_PREFIX}/include")
target_link_directories(${target} INTERFACE "$ENV{CONDA_PREFIX}/lib")

if( modify_prefix_path )
list(PREPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE)
message(VERBOSE "Conda environment detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
endif()
target_include_directories(${target} INTERFACE "$ENV{CONDA_PREFIX}/include")
target_link_directories(${target} INTERFACE "$ENV{CONDA_PREFIX}/lib")

if(modify_prefix_path)
list(PREPEND CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" PARENT_SCOPE)
message(VERBOSE
"Conda environment detected, CMAKE_PREFIX_PATH set to: ${CMAKE_PREFIX_PATH}")
endif()
endif()
endif()
endfunction()
4 changes: 2 additions & 2 deletions rapids-cmake/cmake/write_version_file.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cmake_write_version_file
-------------------------------
Expand Down Expand Up @@ -77,5 +76,6 @@ function(rapids_cmake_write_version_file file_path)
set(RAPIDS_WRITE_PATCH 0)
endif()

configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/version.hpp.in" "${output_path}" @ONLY)
configure_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/template/version.hpp.in" "${output_path}"
@ONLY)
endfunction()
20 changes: 9 additions & 11 deletions rapids-cmake/cpm/find.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ consistency. List all targets used by your project in `GLOBAL_TARGET`.


#]=======================================================================]
function(rapids_cpm_find name version )
function(rapids_cpm_find name version)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.find")
set(options CPM_ARGS)
set(one_value BUILD_EXPORT_SET INSTALL_EXPORT_SET)
Expand All @@ -95,13 +95,7 @@ function(rapids_cpm_find name version )
rapids_cmake_make_global(RAPIDS_GLOBAL_TARGETS)
endif()

#Propagate up variables that CPMFindPackage provide
set("${name}_SOURCE_DIR" "${${name}_SOURCE_DIR}" PARENT_SCOPE)
set("${name}_BINARY_DIR" "${${name}_BINARY_DIR}" PARENT_SCOPE)
set("${name}_ADDED" "${${name}_ADDED}" PARENT_SCOPE)


set(extra_info )
set(extra_info)
if(RAPIDS_GLOBAL_TARGETS)
set(extra_info "GLOBAL_TARGETS")
list(APPEND extra_info ${RAPIDS_GLOBAL_TARGETS})
Expand All @@ -110,14 +104,18 @@ function(rapids_cpm_find name version )
if(RAPIDS_BUILD_EXPORT_SET)
include("${rapids-cmake-dir}/export/cpm.cmake")
rapids_export_cpm(BUILD ${name} ${RAPIDS_BUILD_EXPORT_SET}
CPM_ARGS NAME ${name} VERSION ${version} ${RAPIDS_UNPARSED_ARGUMENTS}
${extra_info}
)
CPM_ARGS NAME ${name} VERSION ${version} ${RAPIDS_UNPARSED_ARGUMENTS}
${extra_info})
endif()

if(RAPIDS_INSTALL_EXPORT_SET)
include("${rapids-cmake-dir}/export/package.cmake")
rapids_export_package(INSTALL ${name} ${RAPIDS_INSTALL_EXPORT_SET} ${extra_info})
endif()

# Propagate up variables that CPMFindPackage provide
set(${name}_SOURCE_DIR "${${name}_SOURCE_DIR}" PARENT_SCOPE)
set(${name}_BINARY_DIR "${${name}_BINARY_DIR}" PARENT_SCOPE)
set(${name}_ADDED "${${name}_ADDED}" PARENT_SCOPE)

endfunction()
10 changes: 4 additions & 6 deletions rapids-cmake/cpm/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#=============================================================================
include_guard(GLOBAL)


#[=======================================================================[.rst:
rapids_cpm_init
-------------------
Expand All @@ -37,7 +36,7 @@ in the build tree of the calling project
Must be called before any invocation of :cmake:command:`rapids_cpm_find`.

#]=======================================================================]
function(rapids_cpm_init )
function(rapids_cpm_init)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.init")
set(CPM_DOWNLOAD_VERSION 7644c3a40fc7889f8dee53ce21e85dc390b883dc) # 0.32.1

Expand All @@ -53,10 +52,9 @@ function(rapids_cpm_init )

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(VERBOSE "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(
DOWNLOAD
https://raw.githubusercontent.com/cpm-cmake/CPM.cmake/${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake
${CPM_DOWNLOAD_LOCATION})
file(DOWNLOAD
https://raw.githubusercontent.com/cpm-cmake/CPM.cmake/${CPM_DOWNLOAD_VERSION}/cmake/CPM.cmake
${CPM_DOWNLOAD_LOCATION})
endif()

include(${CPM_DOWNLOAD_LOCATION})
Expand Down
Loading

0 comments on commit 53e7e8d

Please sign in to comment.