Skip to content

Commit 23424cc

Browse files
authored
Merge pull request #210 from Morwenn/develop
Release 1.13.2
2 parents aeb535f + e5f57ca commit 23424cc

File tree

11 files changed

+147
-42
lines changed

11 files changed

+147
-42
lines changed

.github/workflows/build-msvc.yml

+10-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ jobs:
2828
strategy:
2929
fail-fast: false
3030
matrix:
31-
build_type: [Debug, Release]
31+
config:
32+
- build_type: Release
33+
- build_type: Debug
34+
- build_type: Debug
35+
build_tools: '-T ClangCL'
3236

3337
steps:
3438
- uses: actions/checkout@v3
@@ -38,17 +42,17 @@ jobs:
3842
working-directory: ${{runner.workspace}}
3943
run: |
4044
cmake -H${{github.event.repository.name}} -Bbuild `
41-
-DCMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} `
42-
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} `
43-
-G"Visual Studio 16 2019" -A x64 `
45+
-DCMAKE_CONFIGURATION_TYPES=${{matrix.config.build_type}} `
46+
-DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} `
47+
-G"Visual Studio 16 2019" -A x64 ${{matrix.config.build_tools}} `
4448
-DCPPSORT_BUILD_EXAMPLES=ON
4549
4650
- name: Build the test suite
4751
working-directory: ${{runner.workspace}}/build
48-
run: cmake --build . --config ${{matrix.build_type}} -j 2
52+
run: cmake --build . --config ${{matrix.config.build_type}}
4953

5054
- name: Run the test suite
5155
env:
5256
CTEST_OUTPUT_ON_FAILURE: 1
5357
working-directory: ${{runner.workspace}}/build
54-
run: ctest -C ${{matrix.build_type}} --no-tests=error
58+
run: ctest -C ${{matrix.config.build_type}} --no-tests=error

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.8.0)
55

66
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
77

8-
project(cpp-sort VERSION 1.13.1 LANGUAGES CXX)
8+
project(cpp-sort VERSION 1.13.2 LANGUAGES CXX)
99

1010
include(CMakePackageConfigHelpers)
1111
include(GNUInstallDirs)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![cpp-sort logo](docs/images/cpp-sort-logo.svg)
22

3-
[![Latest Release](https://img.shields.io/badge/release-1.13.1-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.13.1)
4-
[![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)
3+
[![Latest Release](https://img.shields.io/badge/release-1.13.2-blue.svg)](https://github.com/Morwenn/cpp-sort/releases/tag/1.13.2)
4+
[![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)
55
[![Code Coverage](https://codecov.io/gh/Morwenn/cpp-sort/branch/develop/graph/badge.svg)](https://codecov.io/gh/Morwenn/cpp-sort)
66
[![Pitchfork Layout](https://img.shields.io/badge/standard-PFL-orange.svg)](https://github.com/vector-of-bool/pitchfork)
77

conanfile.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
# Copyright (c) 2018-2022 Morwenn
44
# SPDX-License-Identifier: MIT
55

6-
from conans import CMake, ConanFile
6+
import os.path
77

8-
required_conan_version = ">=1.33.0"
8+
from conan import ConanFile
9+
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
10+
from conan.tools.files import copy
11+
from conans import tools
12+
13+
required_conan_version = ">=1.50.0"
914

1015

1116
class CppSortConan(ConanFile):
1217
name = "cpp-sort"
13-
version = "1.13.1"
18+
version = "1.13.2"
1419
description = "Additional sorting algorithms & related tools"
1520
topics = "conan", "cpp-sort", "sorting", "algorithms"
1621
url = "https://github.com/Morwenn/cpp-sort"
@@ -29,26 +34,32 @@ class CppSortConan(ConanFile):
2934
settings = "os", "compiler", "build_type", "arch"
3035

3136
def validate(self):
32-
if self.settings.get_safe("compiler.cppstd"):
37+
if self.info.settings.get_safe("compiler.cppstd"):
3338
tools.check_min_cppstd(self, 14)
3439

40+
def layout(self):
41+
cmake_layout(self)
42+
43+
def generate(self):
44+
tc = CMakeToolchain(self)
45+
tc.variables["BUILD_TESTING"] = "OFF"
46+
tc.generate()
47+
3548
def package(self):
3649
# Install with CMake
3750
cmake = CMake(self)
38-
cmake.definitions["BUILD_TESTING"] = "OFF"
3951
cmake.configure()
4052
cmake.install()
41-
cmake.patch_config_paths()
4253

4354
# Copy license files
4455
for file in ["LICENSE.txt", "NOTICE.txt"]:
45-
self.copy(file, dst="licenses")
56+
copy(self, file, self.recipe_folder, os.path.join(self.package_folder, "licenses"), keep_path=False)
4657

4758
def package_info(self):
4859
self.cpp_info.names["cmake_find_package"] = "cpp-sort"
4960
self.cpp_info.names["cmake_find_package_multi"] = "cpp-sort"
50-
if self.settings.compiler == "Visual Studio":
61+
if self.info.settings.compiler == "Visual Studio":
5162
self.cpp_info.cxxflags = ["/permissive-"]
5263

5364
def package_id(self):
54-
self.info.header_only()
65+
self.info.clear() # Header-only

docs/Home.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![cpp-sort logo](images/cpp-sort-logo.svg)
22

3-
Welcome to the **cpp-sort 1.13.1** documentation!
3+
Welcome to the **cpp-sort 1.13.2** documentation!
44

55
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.
66

docs/Tooling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ Some of those options also exist without the `CPPSORT_` prefix, but they are dep
5656
conan search cpp-sort --remote=conan-center
5757
```
5858

59-
And then install any version to your local cache as follows (here with version 1.13.1):
59+
And then install any version to your local cache as follows (here with version 1.13.2):
6060

6161
```sh
62-
conan install cpp-sort/1.13.1
62+
conan install cpp-sort/1.13.2
6363
```
6464

6565
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.

include/cpp-sort/detail/config.h

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
/*
2-
* Copyright (c) 2016-2021 Morwenn
2+
* Copyright (c) 2016-2022 Morwenn
33
* SPDX-License-Identifier: MIT
44
*/
55
#ifndef CPPSORT_DETAIL_CONFIG_H_
66
#define CPPSORT_DETAIL_CONFIG_H_
77

8+
////////////////////////////////////////////////////////////
9+
// Make <version> available when possible
10+
11+
// config.h is what should be included to get configuration
12+
// information, which includes standard library feature-test
13+
// macros when available
14+
15+
#if __has_include(<version>)
16+
# include <version>
17+
#endif
18+
819
////////////////////////////////////////////////////////////
920
// Check for __has_* macros
1021

@@ -35,20 +46,16 @@
3546
// be used reliably, so we have to fall back to checking
3647
// compiler and standard versions
3748

38-
#if defined(__GNUC__)
49+
#if defined(__cpp_lib_ranges)
50+
# define CPPSORT_STD_IDENTITY_AVAILABLE 1
51+
#elif defined(__GNUC__)
3952
# if __GNUC__ > 9 && __cplusplus > 201703L
4053
# define CPPSORT_STD_IDENTITY_AVAILABLE 1
4154
# else
4255
# define CPPSORT_STD_IDENTITY_AVAILABLE 0
4356
# endif
44-
#elif defined(__clang__)
45-
# define CPPSORT_STD_IDENTITY_AVAILABLE 0
4657
#else
47-
# if defined(__cpp_lib_ranges)
48-
# define CPPSORT_STD_IDENTITY_AVAILABLE 1
49-
# else
50-
# define CPPSORT_STD_IDENTITY_AVAILABLE 0
51-
# endif
58+
# define CPPSORT_STD_IDENTITY_AVAILABLE 0
5259
#endif
5360

5461
////////////////////////////////////////////////////////////

include/cpp-sort/detail/type_traits.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,9 @@ namespace detail
263263
// available:
264264
// * libstdc++ is instrumented in gnu++ mode only
265265
// * libc++ is always instrumented
266+
// * Microsoft STL is never instrumented
266267

267-
#if defined(__SIZEOF_INT128__) && defined(__GLIBCXX__)
268+
#if defined(__SIZEOF_INT128__) && !defined(_LIBCPP_VERSION)
268269
template<typename T>
269270
struct is_integral:
270271
std::is_integral<T>::type

include/cpp-sort/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#define CPPSORT_VERSION_MAJOR 1
1111
#define CPPSORT_VERSION_MINOR 13
12-
#define CPPSORT_VERSION_PATCH 1
12+
#define CPPSORT_VERSION_PATCH 2
1313

1414
#endif // CPPSORT_VERSION_H_

tools/release-checklist.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@ List of actions to perform when releasing a new cpp-sort version.
1414
- [ ] Check `NOTICE.txt` and `README.md` conformance for stolen code.
1515
- [ ] Make sure that tests pass and examples build.
1616
- [ ] Regenerate the benchmarks as needed.
17-
- [ ] Replace occurrences of the version number:
18-
- [ ] CMakeLists.txt (1)
19-
- [ ] conanfile.py (1)
20-
- [ ] README.md (4)
21-
- [ ] version.h
22-
- [ ] Home.md in the documentation (1)
23-
- [ ] Tooling.md/Conan in the documentation (2)
17+
- [ ] Bump the version number with tools/update-version.py.
2418
- [ ] Verify that the Conan recipe works.
2519
- [ ] Try to open `docs` with the latest version of Gollum.
2620
- [ ] Find a name for the new version.
@@ -35,6 +29,3 @@ List of actions to perform when releasing a new cpp-sort version.
3529
- [ ] Check that the documentation was correctly uploaded.
3630
- [ ] Add the new version to Conan Center Index.
3731
- [ ] Brag about it where relevant.
38-
- [ ] Merge master into 2.0.0-develop branch.
39-
- [ ] Fix merge issues.
40-
- [ ] Improve as needed with C++17 and C++20 features.

tools/update-version.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Copyright (c) 2022 Morwenn
4+
# SPDX-License-Identifier: MIT
5+
6+
import argparse
7+
import datetime
8+
import fileinput
9+
import re
10+
import textwrap
11+
from pathlib import Path
12+
13+
14+
def read_version_number(version_file_path: Path) -> str:
15+
parts = {}
16+
with version_file_path.open(encoding='utf-8') as fd:
17+
for line in fd:
18+
if res := re.search("#define CPPSORT_VERSION_(?P<kind>[A-Z]+) (?P<value>\d+)\n", line):
19+
kind, value = res.groups()
20+
parts[kind] = value
21+
return f"{parts['MAJOR']}.{parts['MINOR']}.{parts['PATCH']}"
22+
23+
24+
def write_version_h(version_file_path: Path, version: str) -> None:
25+
major, minor, patch = version.split('.')
26+
year = datetime.datetime.now().year
27+
28+
text = textwrap.dedent(f"""
29+
/*
30+
* Copyright (c) 2018-{year} Morwenn
31+
* SPDX-License-Identifier: MIT
32+
*/
33+
#ifndef CPPSORT_VERSION_H_
34+
#define CPPSORT_VERSION_H_
35+
36+
// Semantic versioning macros
37+
38+
#define CPPSORT_VERSION_MAJOR {major}
39+
#define CPPSORT_VERSION_MINOR {minor}
40+
#define CPPSORT_VERSION_PATCH {patch}
41+
42+
#endif // CPPSORT_VERSION_H_
43+
""")
44+
45+
with version_file_path.open('w', encoding='utf-8') as fd:
46+
fd.write(text[1:])
47+
48+
49+
def replace_version_number(paths: list[Path], old_version: str, new_version: str) -> None:
50+
copyright_regex = "# Copyright \(c\) (?P<first_year>\d{4})-\d{4} Morwenn"
51+
current_year = datetime.datetime.now().year
52+
53+
with fileinput.FileInput(files=paths, inplace=True) as input:
54+
for line in input:
55+
if res := re.search(copyright_regex, line):
56+
print(f"# Copyright (c) {res.group('first_year')}-{current_year} Morwenn")
57+
else:
58+
print(line.replace(old_version, new_version), end='')
59+
60+
61+
def main():
62+
# Declare and parse arguments
63+
parser = argparse.ArgumentParser(description="Script to update relevant files with a new version number")
64+
parser.add_argument("new_version", help="new library version")
65+
parser.add_argument("--root", help="root of the library", default=Path(__file__).parents[1])
66+
args = parser.parse_args()
67+
68+
root = Path(args.root)
69+
version_file = root / 'include' / 'cpp-sort' / 'version.h'
70+
71+
# Isolate old and new version numbers
72+
old_version = read_version_number(version_file)
73+
new_version = args.new_version
74+
print(old_version, new_version)
75+
76+
# TODO: error if new version < old version unless --force/-f
77+
78+
# Replace the version number in appropriate files
79+
write_version_h(version_file, new_version)
80+
paths = [
81+
root / 'conanfile.py',
82+
root / 'CMakeLists.txt',
83+
root / 'README.md',
84+
root / 'docs' / 'Home.md',
85+
root / 'docs' / 'Tooling.md',
86+
]
87+
replace_version_number(paths, old_version, new_version)
88+
89+
90+
if __name__ == '__main__':
91+
main()

0 commit comments

Comments
 (0)