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 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 0f6b6af2..d9e7f44f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,14 +3,19 @@ # 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): 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" @@ -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 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/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 //////////////////////////////////////////////////////////// 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 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_ diff --git a/tools/release-checklist.md b/tools/release-checklist.md index eb845996..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. @@ -35,6 +29,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. 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