From 8cb3e72bbfa66f15639fbe316eaa5345034eb6bd Mon Sep 17 00:00:00 2001 From: Morwenn Date: Tue, 4 Oct 2022 11:33:01 +0200 Subject: [PATCH 1/7] Make conanfile.py more compatible with Conan 2.0 --- conanfile.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/conanfile.py b/conanfile.py index 0f6b6af2..8f502397 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,9 +3,14 @@ # Copyright (c) 2018-2022 Morwenn # SPDX-License-Identifier: MIT -from conans import CMake, ConanFile +import os.path -required_conan_version = ">=1.33.0" +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.files import copy +from conans import tools + +required_conan_version = ">=1.50.0" class CppSortConan(ConanFile): @@ -29,26 +34,32 @@ class CppSortConan(ConanFile): settings = "os", "compiler", "build_type", "arch" def validate(self): - if self.settings.get_safe("compiler.cppstd"): + if self.info.settings.get_safe("compiler.cppstd"): tools.check_min_cppstd(self, 14) + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["BUILD_TESTING"] = "OFF" + tc.generate() + def package(self): # Install with CMake cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = "OFF" cmake.configure() cmake.install() - cmake.patch_config_paths() # Copy license files for file in ["LICENSE.txt", "NOTICE.txt"]: - self.copy(file, dst="licenses") + copy(self, file, self.recipe_folder, os.path.join(self.package_folder, "licenses"), keep_path=False) def package_info(self): self.cpp_info.names["cmake_find_package"] = "cpp-sort" self.cpp_info.names["cmake_find_package_multi"] = "cpp-sort" - if self.settings.compiler == "Visual Studio": + if self.info.settings.compiler == "Visual Studio": self.cpp_info.cxxflags = ["/permissive-"] def package_id(self): - self.info.header_only() + self.info.clear() # Header-only From f2079a7950db8798fe4aca76f9c54e5b2c9cb166 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Tue, 4 Oct 2022 11:33:34 +0200 Subject: [PATCH 2/7] Remove obsolete bullets from release checklist --- tools/release-checklist.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/release-checklist.md b/tools/release-checklist.md index eb845996..764fcd3e 100644 --- a/tools/release-checklist.md +++ b/tools/release-checklist.md @@ -35,6 +35,3 @@ List of actions to perform when releasing a new cpp-sort version. - [ ] Check that the documentation was correctly uploaded. - [ ] Add the new version to Conan Center Index. - [ ] Brag about it where relevant. -- [ ] Merge master into 2.0.0-develop branch. -- [ ] Fix merge issues. -- [ ] Improve as needed with C++17 and C++20 features. From 3b65a697c73a1987d58457e4c94c4386949770a8 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Thu, 6 Oct 2022 00:58:52 +0200 Subject: [PATCH 3/7] Fix __int128_t handling with clang-cl (#208) So far cpp-sort that any standard library that had __SIZEOF_INT128__ defined was either libc++ or libstdc++. However it turned out that clang-cl provides that type but targets the Microsoft STL, so our internal family of is_integral traits had to be updated to take that new information into account. --- include/cpp-sort/detail/type_traits.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cpp-sort/detail/type_traits.h b/include/cpp-sort/detail/type_traits.h index 82cb1d5f..18e6d3d7 100644 --- a/include/cpp-sort/detail/type_traits.h +++ b/include/cpp-sort/detail/type_traits.h @@ -263,8 +263,9 @@ namespace detail // available: // * libstdc++ is instrumented in gnu++ mode only // * libc++ is always instrumented + // * Microsoft STL is never instrumented -#if defined(__SIZEOF_INT128__) && defined(__GLIBCXX__) +#if defined(__SIZEOF_INT128__) && !defined(_LIBCPP_VERSION) template struct is_integral: std::is_integral::type From 89b56538bb888fab45895ebc3d354300d0545cb7 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Thu, 6 Oct 2022 15:18:28 +0200 Subject: [PATCH 4/7] Add CI jobs for clang-cl --- .github/workflows/build-msvc.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-msvc.yml b/.github/workflows/build-msvc.yml index bd374932..c685cb03 100644 --- a/.github/workflows/build-msvc.yml +++ b/.github/workflows/build-msvc.yml @@ -28,7 +28,11 @@ jobs: strategy: fail-fast: false matrix: - build_type: [Debug, Release] + config: + - build_type: Release + - build_type: Debug + - build_type: Debug + build_tools: '-T ClangCL' steps: - uses: actions/checkout@v3 @@ -38,17 +42,17 @@ jobs: working-directory: ${{runner.workspace}} run: | cmake -H${{github.event.repository.name}} -Bbuild ` - -DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} ` - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` - -G"Visual Studio 16 2019" -A x64 ` + -DCMAKE_CONFIGURATION_TYPES=${{matrix.config.build_type}} ` + -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} ` + -G"Visual Studio 16 2019" -A x64 ${{matrix.config.build_tools}} ` -DCPPSORT_BUILD_EXAMPLES=ON - name: Build the test suite working-directory: ${{runner.workspace}}/build - run: cmake --build . --config ${{matrix.build_type}} -j 2 + run: cmake --build . --config ${{matrix.config.build_type}} - name: Run the test suite env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - run: ctest -C ${{matrix.build_type}} --no-tests=error + run: ctest -C ${{matrix.config.build_type}} --no-tests=error From c47bf2e88ae46d89b7d1ccffa899a91a6e4587f6 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Fri, 7 Oct 2022 19:50:07 +0200 Subject: [PATCH 5/7] Better std::identity detection for clang-cl --- include/cpp-sort/detail/config.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/include/cpp-sort/detail/config.h b/include/cpp-sort/detail/config.h index 25c8e5d4..53249423 100644 --- a/include/cpp-sort/detail/config.h +++ b/include/cpp-sort/detail/config.h @@ -1,10 +1,21 @@ /* - * Copyright (c) 2016-2021 Morwenn + * Copyright (c) 2016-2022 Morwenn * SPDX-License-Identifier: MIT */ #ifndef CPPSORT_DETAIL_CONFIG_H_ #define CPPSORT_DETAIL_CONFIG_H_ +//////////////////////////////////////////////////////////// +// Make available when possible + +// config.h is what should be included to get configuration +// information, which includes standard library feature-test +// macros when available + +#if __has_include() +# include +#endif + //////////////////////////////////////////////////////////// // Check for __has_* macros @@ -35,20 +46,16 @@ // be used reliably, so we have to fall back to checking // compiler and standard versions -#if defined(__GNUC__) +#if defined(__cpp_lib_ranges) +# define CPPSORT_STD_IDENTITY_AVAILABLE 1 +#elif defined(__GNUC__) # if __GNUC__ > 9 && __cplusplus > 201703L # define CPPSORT_STD_IDENTITY_AVAILABLE 1 # else # define CPPSORT_STD_IDENTITY_AVAILABLE 0 # endif -#elif defined(__clang__) -# define CPPSORT_STD_IDENTITY_AVAILABLE 0 #else -# if defined(__cpp_lib_ranges) -# define CPPSORT_STD_IDENTITY_AVAILABLE 1 -# else -# define CPPSORT_STD_IDENTITY_AVAILABLE 0 -# endif +# define CPPSORT_STD_IDENTITY_AVAILABLE 0 #endif //////////////////////////////////////////////////////////// From 95c51497a4568de7ff9ff66dbac1657d65f133f4 Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sat, 8 Oct 2022 14:00:45 +0200 Subject: [PATCH 6/7] Add a Python script to update the library's version number --- tools/release-checklist.md | 8 +--- tools/update-version.py | 91 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 tools/update-version.py diff --git a/tools/release-checklist.md b/tools/release-checklist.md index 764fcd3e..74b61c31 100644 --- a/tools/release-checklist.md +++ b/tools/release-checklist.md @@ -14,13 +14,7 @@ List of actions to perform when releasing a new cpp-sort version. - [ ] Check `NOTICE.txt` and `README.md` conformance for stolen code. - [ ] Make sure that tests pass and examples build. - [ ] Regenerate the benchmarks as needed. -- [ ] Replace occurrences of the version number: - - [ ] CMakeLists.txt (1) - - [ ] conanfile.py (1) - - [ ] README.md (4) - - [ ] version.h - - [ ] Home.md in the documentation (1) - - [ ] Tooling.md/Conan in the documentation (2) +- [ ] Bump the version number with tools/update-version.py. - [ ] Verify that the Conan recipe works. - [ ] Try to open `docs` with the latest version of Gollum. - [ ] Find a name for the new version. diff --git a/tools/update-version.py b/tools/update-version.py new file mode 100644 index 00000000..d03cd01a --- /dev/null +++ b/tools/update-version.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2022 Morwenn +# SPDX-License-Identifier: MIT + +import argparse +import datetime +import fileinput +import re +import textwrap +from pathlib import Path + + +def read_version_number(version_file_path: Path) -> str: + parts = {} + with version_file_path.open(encoding='utf-8') as fd: + for line in fd: + if res := re.search("#define CPPSORT_VERSION_(?P[A-Z]+) (?P\d+)\n", line): + kind, value = res.groups() + parts[kind] = value + return f"{parts['MAJOR']}.{parts['MINOR']}.{parts['PATCH']}" + + +def write_version_h(version_file_path: Path, version: str) -> None: + major, minor, patch = version.split('.') + year = datetime.datetime.now().year + + text = textwrap.dedent(f""" + /* + * Copyright (c) 2018-{year} Morwenn + * SPDX-License-Identifier: MIT + */ + #ifndef CPPSORT_VERSION_H_ + #define CPPSORT_VERSION_H_ + + // Semantic versioning macros + + #define CPPSORT_VERSION_MAJOR {major} + #define CPPSORT_VERSION_MINOR {minor} + #define CPPSORT_VERSION_PATCH {patch} + + #endif // CPPSORT_VERSION_H_ + """) + + with version_file_path.open('w', encoding='utf-8') as fd: + fd.write(text[1:]) + + +def replace_version_number(paths: list[Path], old_version: str, new_version: str) -> None: + copyright_regex = "# Copyright \(c\) (?P\d{4})-\d{4} Morwenn" + current_year = datetime.datetime.now().year + + with fileinput.FileInput(files=paths, inplace=True) as input: + for line in input: + if res := re.search(copyright_regex, line): + print(f"# Copyright (c) {res.group('first_year')}-{current_year} Morwenn") + else: + print(line.replace(old_version, new_version), end='') + + +def main(): + # Declare and parse arguments + parser = argparse.ArgumentParser(description="Script to update relevant files with a new version number") + parser.add_argument("new_version", help="new library version") + parser.add_argument("--root", help="root of the library", default=Path(__file__).parents[1]) + args = parser.parse_args() + + root = Path(args.root) + version_file = root / 'include' / 'cpp-sort' / 'version.h' + + # Isolate old and new version numbers + old_version = read_version_number(version_file) + new_version = args.new_version + print(old_version, new_version) + + # TODO: error if new version < old version unless --force/-f + + # Replace the version number in appropriate files + write_version_h(version_file, new_version) + paths = [ + root / 'conanfile.py', + root / 'CMakeLists.txt', + root / 'README.md', + root / 'docs' / 'Home.md', + root / 'docs' / 'Tooling.md', + ] + replace_version_number(paths, old_version, new_version) + + +if __name__ == '__main__': + main() \ No newline at end of file From e5f57ca59f3c0d164fcd6e39aeec6f9d383629ad Mon Sep 17 00:00:00 2001 From: Morwenn Date: Sat, 8 Oct 2022 14:02:43 +0200 Subject: [PATCH 7/7] Preparing release 1.13.2 --- CMakeLists.txt | 2 +- README.md | 4 ++-- conanfile.py | 2 +- docs/Home.md | 2 +- docs/Tooling.md | 4 ++-- include/cpp-sort/version.h | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b257c18..d5b6fb8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.8.0) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -project(cpp-sort VERSION 1.13.1 LANGUAGES CXX) +project(cpp-sort VERSION 1.13.2 LANGUAGES CXX) include(CMakePackageConfigHelpers) include(GNUInstallDirs) diff --git a/README.md b/README.md index 9194a663..dedd83d9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![cpp-sort logo](docs/images/cpp-sort-logo.svg) -[![Latest Release](https://img.shields.io/badge/release-1.13.1-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.13.1) -[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.13.1-blue.svg)](https://conan.io/center/cpp-sort?version=1.13.1) +[![Latest Release](https://img.shields.io/badge/release-1.13.2-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.13.2) +[![Conan Package](https://img.shields.io/badge/conan-cpp--sort%2F1.13.2-blue.svg)](https://conan.io/center/cpp-sort?version=1.13.2) [![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort) [![Pitchfork Layout](https://img.shields.io/badge/standard-PFL-orange.svg)](https://github.com/vector-of-bool/pitchfork) diff --git a/conanfile.py b/conanfile.py index 8f502397..d9e7f44f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,7 @@ class CppSortConan(ConanFile): name = "cpp-sort" - version = "1.13.1" + version = "1.13.2" description = "Additional sorting algorithms & related tools" topics = "conan", "cpp-sort", "sorting", "algorithms" url = "https://github.com/Morwenn/cpp-sort" diff --git a/docs/Home.md b/docs/Home.md index 6718c570..fac1ed50 100644 --- a/docs/Home.md +++ b/docs/Home.md @@ -1,6 +1,6 @@ ![cpp-sort logo](images/cpp-sort-logo.svg) -Welcome to the **cpp-sort 1.13.1** documentation! +Welcome to the **cpp-sort 1.13.2** documentation! You probably read the introduction in the README, so I won't repeat it here. This wiki contains documentation about the library: basic documentation about the many sorting tools and how to use them, documentation about the additional utilities provided by the library and even some detailed tutorials if you ever want to write your own sorters or sorter adapters. This main page explains a few general things that didn't quite fit in other parts of the documentation. diff --git a/docs/Tooling.md b/docs/Tooling.md index 20d61eb4..c53c52cf 100644 --- a/docs/Tooling.md +++ b/docs/Tooling.md @@ -56,10 +56,10 @@ Some of those options also exist without the `CPPSORT_` prefix, but they are dep conan search cpp-sort --remote=conan-center ``` -And then install any version to your local cache as follows (here with version 1.13.1): +And then install any version to your local cache as follows (here with version 1.13.2): ```sh -conan install cpp-sort/1.13.1 +conan install cpp-sort/1.13.2 ``` The packages downloaded from conan-center are minimal and only contain the files required to use **cpp-sort** as a library: the headers, CMake files and licensing information. If you need anything else you have to build your own package with the `conanfile.py` available in this repository. diff --git a/include/cpp-sort/version.h b/include/cpp-sort/version.h index 0c348e35..5689d63a 100644 --- a/include/cpp-sort/version.h +++ b/include/cpp-sort/version.h @@ -9,6 +9,6 @@ #define CPPSORT_VERSION_MAJOR 1 #define CPPSORT_VERSION_MINOR 13 -#define CPPSORT_VERSION_PATCH 1 +#define CPPSORT_VERSION_PATCH 2 #endif // CPPSORT_VERSION_H_