Skip to content

Commit

Permalink
Merge pull request #210 from Morwenn/develop
Browse files Browse the repository at this point in the history
Release 1.13.2
  • Loading branch information
Morwenn committed Oct 9, 2022
2 parents aeb535f + e5f57ca commit 23424cc
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 42 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build-msvc.yml
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions 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)

Expand Down
29 changes: 20 additions & 9 deletions conanfile.py
Expand Up @@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion 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.

Expand Down
4 changes: 2 additions & 2 deletions docs/Tooling.md
Expand Up @@ -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.
Expand Down
25 changes: 16 additions & 9 deletions 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 <version> 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(<version>)
# include <version>
#endif

////////////////////////////////////////////////////////////
// Check for __has_* macros

Expand Down Expand Up @@ -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

////////////////////////////////////////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion include/cpp-sort/detail/type_traits.h
Expand Up @@ -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<typename T>
struct is_integral:
std::is_integral<T>::type
Expand Down
2 changes: 1 addition & 1 deletion include/cpp-sort/version.h
Expand Up @@ -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_
11 changes: 1 addition & 10 deletions tools/release-checklist.md
Expand Up @@ -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.
Expand All @@ -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.
91 changes: 91 additions & 0 deletions 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<kind>[A-Z]+) (?P<value>\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<first_year>\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()

0 comments on commit 23424cc

Please sign in to comment.