diff --git a/.beman-tidy.yaml b/.beman-tidy.yaml index ac91fe3..24d798b 100644 --- a/.beman-tidy.yaml +++ b/.beman-tidy.yaml @@ -5,6 +5,6 @@ # https://github.com/bemanproject/beman-tidy/blob/main/README.md disabled_rules: - - readme.title + # None ignored_paths: # None diff --git a/.exemplar_version b/.exemplar_version new file mode 100644 index 0000000..2367afa --- /dev/null +++ b/.exemplar_version @@ -0,0 +1 @@ +29fd521a15439a3338272cb91c4940f63aa01cc5 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c9a2615..37780dc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -* @ednolan @bretbrownjr @camio @dietmarkuehl @steve-downey @wusatosi +* @aryann,bartholomaios diff --git a/.github/workflows/catch2_exemplar_test.yml b/.github/workflows/catch2_exemplar_test.yml deleted file mode 100644 index 60ee257..0000000 --- a/.github/workflows/catch2_exemplar_test.yml +++ /dev/null @@ -1,29 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: Catch2 Exemplar Test -on: - push: - branches: - - main - pull_request: - -jobs: - catch2-exemplar-test: - runs-on: ubuntu-latest - container: ghcr.io/bemanproject/infra-containers-gcc:latest - name: "Catch2 exemplar smoke test" - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Test catch2 exemplar - run: | - cd cookiecutter - source ./check_cookiecutter.sh - cookiecutter_venv_path=$(mktemp --directory --dry-run) - setup_venv "$cookiecutter_venv_path" - stamp "$PWD" "./catch2_exemplar" "catch2" "true" - cd catch2_exemplar/exemplar - cmake -B build -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake -DCMAKE_CXX_STANDARD=20 -DCMAKE_INSTALL_PREFIX=$PWD/dist - cmake --build build - ctest --test-dir build - cmake --install build diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 6e6615a..b47cead 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -9,7 +9,7 @@ on: pull_request: workflow_dispatch: schedule: - - cron: '30 15 * * 6' + - cron: '30 16 * * 2' concurrency: group: ${{format('{0}:{1}', github.repository, github.ref)}} @@ -48,7 +48,7 @@ jobs: "tests": [ "Debug.Default", "Release.Default", "Release.TSan", "Release.MaxSan", "Debug.Werror", - "Debug.Coverage", "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Debug.Coverage", "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -57,7 +57,7 @@ jobs: "tests": [ { "stdlibs": ["libstdc++"], "tests": [ - "Release.Default", "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Release.Default", "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -73,7 +73,7 @@ jobs: "tests": [ { "stdlibs": ["libstdc++"], "tests": [ - "Release.Default", "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Release.Default", "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -108,7 +108,7 @@ jobs: "tests": [ "Debug.Default", "Release.Default", "Release.TSan", "Release.MaxSan", "Debug.Werror", - "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -117,7 +117,7 @@ jobs: "tests": [ { "stdlibs": ["libstdc++", "libc++"], "tests": [ - "Release.Default", "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Release.Default", "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -176,7 +176,7 @@ jobs: { "stdlibs": ["stl"], "tests": [ "Debug.Default", "Release.Default", "Release.MaxSan", - "Debug.-DBEMAN_EXEMPLAR_USE_MODULES=On" + "Debug.-DBEMAN_STR_SPLIT_USE_MODULES=On" ] } ] @@ -189,7 +189,7 @@ jobs: vcpkg-ci: uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-ci.yml@1.7.2 with: - port_name: beman-exemplar + port_name: beman-str-split feature_combinations: | [ {"features": {}}, diff --git a/.github/workflows/cookiecutter_test.yml b/.github/workflows/cookiecutter_test.yml deleted file mode 100644 index 04cdd05..0000000 --- a/.github/workflows/cookiecutter_test.yml +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: Cookiecutter Test -on: - push: - branches: - - main - pull_request: - -jobs: - cookiecutter-test: - runs-on: ubuntu-latest - name: "Check cookiecutter for consistency" - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: beman cookiecutter consistency check - run: | - ./cookiecutter/check_cookiecutter.sh diff --git a/.github/workflows/pre-commit-update.yml b/.github/workflows/pre-commit-update.yml index 7ab44ac..db1b677 100644 --- a/.github/workflows/pre-commit-update.yml +++ b/.github/workflows/pre-commit-update.yml @@ -5,7 +5,7 @@ name: Weekly pre-commit autoupdate on: workflow_dispatch: schedule: - - cron: "0 16 * * 0" + - cron: "50 13 * * 0" jobs: auto-update-pre-commit: diff --git a/.github/workflows/todo_exemplar_test.yml b/.github/workflows/todo_exemplar_test.yml deleted file mode 100644 index e7b4c33..0000000 --- a/.github/workflows/todo_exemplar_test.yml +++ /dev/null @@ -1,31 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: TODO Exemplar Test -on: - push: - branches: - - main - pull_request: - -jobs: - static-exemplar-test: - runs-on: ubuntu-latest - container: ghcr.io/bemanproject/infra-containers-gcc:latest - name: "TODO exemplar smoke test" - steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Test static exemplar - run: | - cd cookiecutter - source ./check_cookiecutter.sh - cookiecutter_venv_path=$(mktemp --directory --dry-run) - setup_venv "$cookiecutter_venv_path" - stamp "$PWD" "./static_exemplar" "gtest" "false" - cd static_exemplar/exemplar - grep -r 'identity' . && exit 1 - find . -name '*identity*' | grep . && exit 1 - cmake -B build -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake -DCMAKE_CXX_STANDARD=20 -DCMAKE_INSTALL_PREFIX=$PWD/dist - cmake --build build - ctest --test-dir build - cmake --install build diff --git a/.github/workflows/vcpkg-release.yml b/.github/workflows/vcpkg-release.yml index cc10bea..114dfe1 100644 --- a/.github/workflows/vcpkg-release.yml +++ b/.github/workflows/vcpkg-release.yml @@ -8,6 +8,6 @@ jobs: vcpkg-release: uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-release.yml@1.7.2 with: - port_name: beman-exemplar + port_name: beman-str-split secrets: VCPKG_REGISTRY_TOKEN: ${{ secrets.VCPKG_REGISTRY_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b3dc48c..4f63c43 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,4 +40,10 @@ repos: hooks: - id: codespell + # Beman Standard checking via beman-tidy + - repo: https://github.com/bemanproject/beman-tidy + rev: v0.3.1 + hooks: + - id: beman-tidy + exclude: 'cookiecutter/|infra/|port/' diff --git a/CMakeLists.txt b/CMakeLists.txt index 07d744c..2a90806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,35 +5,35 @@ cmake_minimum_required(VERSION 3.30...4.3) include(infra/cmake/enable-experimental-import-std.cmake) project( - beman.exemplar - DESCRIPTION "A Beman Library Exemplar" + beman.str_split + DESCRIPTION "Stand-alone, easy-to-use string split utilities" LANGUAGES CXX - VERSION 2.4.0 + VERSION 0.1.0 ) # [CMAKE.SKIP_TESTS] option( - BEMAN_EXEMPLAR_BUILD_TESTS + BEMAN_STR_SPLIT_BUILD_TESTS "Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." ${PROJECT_IS_TOP_LEVEL} ) # [CMAKE.SKIP_EXAMPLES] option( - BEMAN_EXEMPLAR_BUILD_EXAMPLES + BEMAN_STR_SPLIT_BUILD_EXAMPLES "Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." ${PROJECT_IS_TOP_LEVEL} ) -option(BEMAN_EXEMPLAR_USE_MODULES "Provide beman.exemplar as a C++ module" OFF) +option(BEMAN_STR_SPLIT_USE_MODULES "Provide beman.str_split as a C++ module" OFF) -if(BEMAN_EXEMPLAR_USE_MODULES) +if(BEMAN_STR_SPLIT_USE_MODULES) set(CMAKE_CXX_SCAN_FOR_MODULES ON) endif() configure_file( - "${PROJECT_SOURCE_DIR}/include/beman/exemplar/config_generated.hpp.in" - "${PROJECT_BINARY_DIR}/include/beman/exemplar/config_generated.hpp" + "${PROJECT_SOURCE_DIR}/include/beman/str_split/config_generated.hpp.in" + "${PROJECT_BINARY_DIR}/include/beman/str_split/config_generated.hpp" @ONLY ) @@ -41,16 +41,16 @@ configure_file( include(infra/cmake/beman-install-library.cmake) include(infra/cmake/BuildTelemetryConfig.cmake) -if(BEMAN_EXEMPLAR_USE_MODULES) - add_library(beman.exemplar STATIC) +if(BEMAN_STR_SPLIT_USE_MODULES) + add_library(beman.str_split STATIC) else() - add_library(beman.exemplar INTERFACE) + add_library(beman.str_split INTERFACE) endif() -add_library(beman::exemplar ALIAS beman.exemplar) +add_library(beman::str_split ALIAS beman.str_split) -if(BEMAN_EXEMPLAR_USE_MODULES) +if(BEMAN_STR_SPLIT_USE_MODULES) target_sources( - beman.exemplar + beman.str_split PUBLIC FILE_SET CXX_MODULES FILE_SET HEADERS @@ -58,11 +58,11 @@ if(BEMAN_EXEMPLAR_USE_MODULES) "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" ) - set_target_properties(beman.exemplar PROPERTIES CXX_MODULE_STD ON) - target_compile_features(beman.exemplar PUBLIC cxx_std_23) + set_target_properties(beman.str_split PROPERTIES CXX_MODULE_STD ON) + target_compile_features(beman.str_split PUBLIC cxx_std_23) else() target_sources( - beman.exemplar + beman.str_split PUBLIC FILE_SET HEADERS BASE_DIRS @@ -70,21 +70,21 @@ else() "${CMAKE_CURRENT_BINARY_DIR}/include" ) set_target_properties( - beman.exemplar + beman.str_split PROPERTIES VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} ) endif() -add_subdirectory(include/beman/exemplar) +add_subdirectory(include/beman/str_split) -beman_install_library(beman.exemplar TARGETS beman.exemplar) +beman_install_library(beman.str_split TARGETS beman.str_split) configure_build_telemetry() -if(BEMAN_EXEMPLAR_BUILD_TESTS) +if(BEMAN_STR_SPLIT_BUILD_TESTS) enable_testing() - add_subdirectory(tests/beman/exemplar) + add_subdirectory(tests/beman/str_split) endif() -if(BEMAN_EXEMPLAR_BUILD_EXAMPLES) +if(BEMAN_STR_SPLIT_BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/CMakePresets.json b/CMakePresets.json index aa46219..bd35911 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,7 +7,7 @@ "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { - "CMAKE_CXX_STANDARD": "17", + "CMAKE_CXX_STANDARD": "23", "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./infra/cmake/use-fetch-content.cmake" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 42e2f3d..28ed571 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,7 @@ that this requires GoogleTest to be installed. cmake \ -B build \ -S . \ - -DCMAKE_CXX_STANDARD=17 \ + -DCMAKE_CXX_STANDARD=23 \ # Your extra arguments here. cmake --build build ctest --test-dir build @@ -85,7 +85,7 @@ vcpkg. ### FetchContent Instead of installing the project's dependencies via a package manager, you can optionally -configure beman.exemplar to fetch them automatically via CMake FetchContent. +configure beman.str_split to fetch them automatically via CMake FetchContent. To do so, specify `-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake`. This will @@ -97,7 +97,7 @@ Example commands: cmake \ -B build \ -S . \ - -DCMAKE_CXX_STANDARD=17 \ + -DCMAKE_CXX_STANDARD=23 \ -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake cmake --build build ctest --test-dir build @@ -108,32 +108,32 @@ acquired by FetchContent. ## Project-specific configure arguments -Project-specific options are prefixed with `BEMAN_EXEMPLAR`. +Project-specific options are prefixed with `BEMAN_STR_SPLIT`. You can see the list of available options with: ```bash -cmake -LH -S . -B build | grep "BEMAN_EXEMPLAR" -C 2 +cmake -LH -S . -B build | grep "BEMAN_STR_SPLIT" -C 2 ```
Some project-specific configure arguments -### `BEMAN_EXEMPLAR_BUILD_TESTS` +### `BEMAN_STR_SPLIT_BUILD_TESTS` Enable building tests and test infrastructure. Default: `ON`. Values: `{ ON, OFF }`. -### `BEMAN_EXEMPLAR_BUILD_EXAMPLES` +### `BEMAN_STR_SPLIT_BUILD_EXAMPLES` Enable building examples. Default: `ON`. Values: `{ ON, OFF }`. -### `BEMAN_EXEMPLAR_INSTALL_CONFIG_FILE_PACKAGE` +### `BEMAN_STR_SPLIT_INSTALL_CONFIG_FILE_PACKAGE` Enable installing the CMake config file package. Default: `ON`. Values: `{ ON, OFF }`. -This is required so that users of `beman.exemplar` can use -`find_package(beman.exemplar)` to locate the library. +This is required so that users of `beman.str_split` can use +`find_package(beman.str_split)` to locate the library.
diff --git a/README.md b/README.md index 0399d20..082bc75 100644 --- a/README.md +++ b/README.md @@ -1,125 +1,25 @@ -# How to Use This Template - -To create a new Beman library, first click the "Use this template" dropdown in the -top-right and select "Create a new repository": - -
- -
- -This will create a new repository that's an exact copy of exemplar. The next step is to -customize it for your use case. - -To do so, execute the bash script `stamp.sh`. This script will prompt for parameters like -the new library's name, paper number, and description. Then it will replace your exemplar -copy with a stamped-out template containing these parameters and create a corresponding -git commit and branch: - -``` -$ ./stamp.sh - [1/6] project_name (my_project_name): example_library - [2/6] maintainer (your_github_username): your_username - [3/6] minimum_cpp_build_version (20): - [4/6] paper (PnnnnRr): P9999R9 - [5/6] description (Short project description.): - [6/6] Select unit_test_library - 1 - gtest - 2 - catch2 - Choose from [1/2] (1): -Switched to a new branch 'stamp' -Successfully stamped out exemplar template to the new branch 'stamp'. -Try 'git push origin stamp' to push the branch upstream, -then create a pull request. -``` - -From there, you can simply fill in all the remaining parts of the repository that are -labeled 'todo'. - -What follow is an example of a Beman library README. - -# beman.exemplar: A Beman Library Exemplar +# beman.str_split: Stand-alone, easy-to-use string split utilities -![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg) ![Continuous Integration Tests](https://github.com/bemanproject/exemplar/actions/workflows/ci_tests.yml/badge.svg) ![Lint Check (pre-commit)](https://github.com/bemanproject/exemplar/actions/workflows/pre-commit-check.yml/badge.svg) [![Coverage](https://coveralls.io/repos/github/bemanproject/exemplar/badge.svg?branch=main)](https://coveralls.io/github/bemanproject/exemplar?branch=main) ![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp29.svg) [![Compiler Explorer Example](https://img.shields.io/badge/Try%20it%20on%20Compiler%20Explorer-grey?logo=compilerexplorer&logoColor=67c52a)](https://godbolt.org/z/4qEPK87va) +![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg) ![Continuous Integration Tests](https://github.com/bemanproject/str_split/actions/workflows/ci_tests.yml/badge.svg) ![Lint Check (pre-commit)](https://github.com/bemanproject/str_split/actions/workflows/pre-commit-check.yml/badge.svg) [![Coverage](https://coveralls.io/repos/github/bemanproject/str_split/badge.svg?branch=main)](https://coveralls.io/github/bemanproject/str_split?branch=main) ![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp29.svg) -`beman.exemplar` is a minimal C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md). -This can be used as a template for those intending to write Beman libraries. -It may also find use as a minimal and modern C++ project structure. +`beman.str_split` is (... TODO: description). -**Implements**: `std::identity` proposed in [Standard Library Concepts (P0898R3)](https://wg21.link/P0898R3). +**Implements**: `std::todo` proposed in [TODO (PnnnnRr)](https://wg21.link/PnnnnRr). **Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#under-development-and-not-yet-ready-for-production-use) ## License -`beman.exemplar` is licensed under the Apache License v2.0 with LLVM Exceptions. +`beman.str_split` is licensed under the Apache License v2.0 with LLVM Exceptions. ## Usage -`std::identity` is a function object type whose `operator()` returns its argument unchanged. -`std::identity` serves as the default projection in constrained algorithms. -Its direct usage is usually not needed. - -### Usage: default projection in constrained algorithms - -The following code snippet illustrates how we can achieve a default projection using `beman::exemplar::identity`: - -```cpp -#include - -namespace exe = beman::exemplar; - -// Class with a pair of values. -struct Pair -{ - int n; - std::string s; - - // Output the pair in the form {n, s}. - // Used by the range-printer if no custom projection is provided (default: identity projection). - friend std::ostream &operator<<(std::ostream &os, const Pair &p) - { - return os << "Pair" << '{' << p.n << ", " << p.s << '}'; - } -}; - -// A range-printer that can print projected (modified) elements of a range. -// All the elements of the range are printed in the form {element1, element2, ...}. -// e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three} -// e.g., pairs with custom projection: {1:one, 2:two, 3:three} -template -void print(const std::string_view rem, R &&range, Projection projection = exe::identity>) -{ - std::cout << rem << '{'; - std::ranges::for_each( - range, - [O = 0](const auto &o) mutable - { std::cout << (O++ ? ", " : "") << o; }, - projection); - std::cout << "}\n"; -}; - -int main() -{ - // A vector of pairs to print. - const std::vector pairs = { - {1, "one"}, - {2, "two"}, - {3, "three"}, - }; - - // Print the pairs using the default projection. - print("\tpairs with beman: ", pairs); - - return 0; -} - -``` +TODO Full runnable examples can be found in [`examples/`](examples/). @@ -129,11 +29,11 @@ Full runnable examples can be found in [`examples/`](examples/). This project requires at least the following to build: -* A C++ compiler that conforms to the C++17 standard or greater +* A C++ compiler that conforms to the C++23 standard or greater * CMake 3.30 or later * (Test Only) GoogleTest -You can disable building tests by setting CMake option `BEMAN_EXEMPLAR_BUILD_TESTS` to +You can disable building tests by setting CMake option `BEMAN_STR_SPLIT_BUILD_TESTS` to `OFF` when configuring the project. ### Supported Platforms @@ -154,11 +54,11 @@ You can disable building tests by setting CMake option `BEMAN_EXEMPLAR_BUILD_TES See the [Contributing Guidelines](CONTRIBUTING.md). -## Integrate beman.exemplar into your project +## Integrate beman.str_split into your project ### Build -You can build exemplar using a CMake workflow preset: +You can build str_split using a CMake workflow preset: ```bash cmake --workflow --preset gcc-release @@ -170,23 +70,23 @@ To list available workflow presets, you can invoke: cmake --list-presets=workflow ``` -For details on building beman.exemplar without using a CMake preset, refer to the +For details on building beman.str_split without using a CMake preset, refer to the [Contributing Guidelines](CONTRIBUTING.md). ### Installation #### Vcpkg -The preferred way to install exemplar is via vcpkg. To do so, after installing vcpkg +The preferred way to install str_split is via vcpkg. To do so, after installing vcpkg itself, you need to add support for the Beman project's [vcpkg registry](https://github.com/bemanproject/vcpkg-registry) by configuring a -`vcpkg-configuration.json` file (which exemplar [provides](vcpkg-configuration.json)). +`vcpkg-configuration.json` file (which str_split [provides](vcpkg-configuration.json)). -Then, simply run `vcpkg install beman-exemplar`. +Then, simply run `vcpkg install beman-str-split`. #### Manual -To install beman.exemplar globally after building with the `gcc-release` preset, you can +To install beman.str_split globally after building with the `gcc-release` preset, you can run: ```bash @@ -205,47 +105,47 @@ This will generate the following directory structure: /opt/beman ├── include │ └── beman -│ └── exemplar -│ ├── exemplar.hpp +│ └── str_split +│ ├── str_split.hpp │ └── ... └── lib └── cmake - └── beman.exemplar - ├── beman.exemplar-config-version.cmake - ├── beman.exemplar-config.cmake - └── beman.exemplar-targets.cmake + └── beman.str_split + ├── beman.str_split-config-version.cmake + ├── beman.str_split-config.cmake + └── beman.str_split-targets.cmake ``` ### CMake Configuration -If you installed beman.exemplar to a prefix, you can specify that prefix to your CMake +If you installed beman.str_split to a prefix, you can specify that prefix to your CMake project using `CMAKE_PREFIX_PATH`; for example, `-DCMAKE_PREFIX_PATH=/opt/beman`. -You need to bring in the `beman.exemplar` package to define the `beman::exemplar` CMake +You need to bring in the `beman.str_split` package to define the `beman::str_split` CMake target: ```cmake -find_package(beman.exemplar REQUIRED) +find_package(beman.str_split REQUIRED) ``` -You will then need to add `beman::exemplar` to the link libraries of any libraries or -executables that include `beman.exemplar` headers. +You will then need to add `beman::str_split` to the link libraries of any libraries or +executables that include `beman.str_split` headers. ```cmake -target_link_libraries(yourlib PUBLIC beman::exemplar) +target_link_libraries(yourlib PUBLIC beman::str_split) ``` -### Using beman.exemplar +### Using beman.str_split -To use `beman.exemplar` in your C++ project, -include an appropriate `beman.exemplar` header from your source code. +To use `beman.str_split` in your C++ project, +include an appropriate `beman.str_split` header from your source code. ```c++ -#include +#include ``` > [!NOTE] > -> `beman.exemplar` headers are to be included with the `beman/exemplar/` prefix. +> `beman.str_split` headers are to be included with the `beman/str_split/` prefix. > Altering include search paths to spell the include target another way (e.g. -> `#include `) is unsupported. +> `#include `) is unsupported. diff --git a/cookiecutter/check_cookiecutter.sh b/cookiecutter/check_cookiecutter.sh deleted file mode 100755 index 394cca7..0000000 --- a/cookiecutter/check_cookiecutter.sh +++ /dev/null @@ -1,101 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#!/usr/bin/env bash - -set -euo pipefail - -declare script_dir=$(realpath $(dirname "$BASH_SOURCE")) - -function stamp() { - local cookiecutter_dir="$1" ; shift - local output_dir="$1" ; shift - local unit_test_library="$1" ; shift - local generating_exemplar="$1" ; shift - python3 \ - -m cookiecutter \ - --no-input \ - --output-dir "$output_dir" \ - "$cookiecutter_dir" \ - project_name="exemplar" \ - minimum_cpp_build_version="17" \ - paper="P0898R3" \ - description="A Beman Library Exemplar" \ - unit_test_library="$unit_test_library" \ - _generating_exemplar="$generating_exemplar" \ - _ci_tests_cron="30 15 * * 6" \ - _pre_commit_update_cron="0 16 * * 0" -} - -function check_consistency() { - local out_dir_path - out_dir_path=$(mktemp --directory --dry-run) - cd /tmp - stamp "$script_dir" "$out_dir_path" "gtest" "true" - cp "$script_dir"/../.github/workflows/cookiecutter_test.yml "$out_dir_path"/exemplar/.github/workflows - cp "$script_dir"/../.github/workflows/catch2_exemplar_test.yml "$out_dir_path"/exemplar/.github/workflows - cp "$script_dir"/../.github/workflows/todo_exemplar_test.yml "$out_dir_path"/exemplar/.github/workflows - mkdir "$out_dir_path"/exemplar/images - cp "$script_dir"/../images/use-this-template.png "$out_dir_path"/exemplar/images/use-this-template.png - cp "$script_dir"/../stamp.sh "$out_dir_path"/exemplar/stamp.sh - local diff_path - diff_path=$(mktemp) - diff -r "$script_dir/.." "$out_dir_path/exemplar" \ - | grep -v -e 'cookiecutter$' -e '.git$' > "$diff_path" || true - rm -rf "$out_dir_path" - if [[ $(wc -l "$diff_path" | cut -d' ' -f1) -gt 0 ]] ; then - echo "Discrepancy between exemplar and cookiecutter:" >&2 - cat "$diff_path" - rm "$diff_path" - exit 1 - fi - rm "$diff_path" -} - -function check_templating() { - local out_dir_path - out_dir_path=$(mktemp --directory --dry-run) - cd /tmp - python3 \ - -m cookiecutter \ - --no-input \ - --output-dir "$out_dir_path" \ - "$script_dir" \ - project_name="RLZrmX9NfS" \ - minimum_cpp_build_version="17" \ - paper="P0898R3" \ - description="A Beman Library RLZrmX9NfS" \ - _generating_exemplar="false" \ - _ci_tests_cron="30 15 * * 6" \ - _pre_commit_update_cron="0 16 * * 0" - rm -rf "$out_dir_path/RLZrmX9NfS/infra" - local grep_path - grep_path=$(mktemp) - grep \ - --dereference-recursive --context=5 --color=always \ - -e "exemplar" -e "identity" "$out_dir_path/RLZrmX9NfS" > "$grep_path" || true - rm -rf "$out_dir_path" - if [[ $(wc -l "$grep_path" | cut -d' ' -f1) -gt 0 ]] ; then - echo "Untemplated \"exemplar\" or \"identity\" in cookiecutter:" >&2 - cat "$grep_path" - rm "$grep_path" - exit 1 - fi - rm "$grep_path" -} - -function setup_venv() { - local path="$1" ; shift - python3 -m venv "$cookiecutter_venv_path" - source "$cookiecutter_venv_path/bin/activate" - python3 -m pip install cookiecutter >& /dev/null -} - -function main() { - local cookiecutter_venv_path - cookiecutter_venv_path=$(mktemp --directory --dry-run) - setup_venv "$cookiecutter_venv_path" - check_consistency - check_templating - rm -rf "$cookiecutter_venv_path" -} - -[[ "${BASH_SOURCE[0]}" != "${0}" ]] || main "$@" diff --git a/cookiecutter/cookiecutter.json b/cookiecutter/cookiecutter.json deleted file mode 100644 index bb406fe..0000000 --- a/cookiecutter/cookiecutter.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "project_name": "my_project_name", - "maintainer": "your_github_username", - "minimum_cpp_build_version": "20", - "paper": "PnnnnRr", - "description": "Short project description.", - "unit_test_library": ["gtest", "catch2"], - "_generating_exemplar": false, - "_owner": "bemanproject", - "_ci_tests_cron": "", - "_pre_commit_update_cron": "", - "_copy_without_render": [ - "infra" - ], - "_jinja2_env_vars": {"trim_blocks": true} -} diff --git a/cookiecutter/hooks/post_gen_project.py b/cookiecutter/hooks/post_gen_project.py deleted file mode 100755 index 9965c4c..0000000 --- a/cookiecutter/hooks/post_gen_project.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -import shutil -import subprocess -from pathlib import Path -import os - -project_name = "{{ cookiecutter.project_name }}" -generating_exemplar = "{{ cookiecutter._generating_exemplar }}" == "True" - -if not generating_exemplar: - os.rename("include/beman/" + project_name + "/identity.hpp", "include/beman/" + project_name + "/todo.hpp") - os.rename("examples/identity_direct_usage.cpp", "examples/todo.cpp") - os.remove("examples/identity_as_default_projection.cpp") - os.rename("tests/beman/" + project_name + "/identity.test.cpp", "tests/beman/" + project_name + "/todo.test.cpp") - - # Record the exemplar commit this project was stamped from. - result = subprocess.run( - ["git", "ls-remote", "https://github.com/bemanproject/exemplar.git", "HEAD"], - capture_output=True, - text=True, - check=True, - ) - sha = result.stdout.split()[0] - Path(".exemplar_version").write_text(sha + "\n") diff --git a/cookiecutter/{{cookiecutter.project_name}}/.beman-tidy.yaml b/cookiecutter/{{cookiecutter.project_name}}/.beman-tidy.yaml deleted file mode 100644 index 527ca1e..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.beman-tidy.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This is the config file for beman-tidy, which checks compliance with the Beman Standard (https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md) -# Check documentation for beman-tidy here: -# https://github.com/bemanproject/beman-tidy/blob/main/README.md - -{% if cookiecutter._generating_exemplar %} -disabled_rules: - - readme.title -{% else %} -disabled_rules: - # None -{% endif %} -ignored_paths: - # None diff --git a/cookiecutter/{{cookiecutter.project_name}}/.clang-format b/cookiecutter/{{cookiecutter.project_name}}/.clang-format deleted file mode 100644 index 74f95dc..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.clang-format +++ /dev/null @@ -1,242 +0,0 @@ ---- -Language: Cpp -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignArrayOfStructures: None -AlignConsecutiveAssignments: - Enabled: true - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: true -AlignConsecutiveBitFields: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: false -AlignConsecutiveDeclarations: - Enabled: true - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: true -AlignConsecutiveMacros: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCompound: false - PadOperators: false -AlignConsecutiveShortCaseStatements: - Enabled: false - AcrossEmptyLines: false - AcrossComments: false - AlignCaseColons: false -AlignEscapedNewlines: Left -AlignOperands: Align -AlignTrailingComments: - Kind: Always - OverEmptyLines: 0 -AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: Never -AllowShortCaseLabelsOnASingleLine: false -AllowShortEnumsOnASingleLine: true -AllowShortFunctionsOnASingleLine: All -AllowShortIfStatementsOnASingleLine: Never -AllowShortLambdasOnASingleLine: All -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: Yes -AttributeMacros: - - __capability -BinPackArguments: false -BinPackParameters: false -BitFieldColonSpacing: Both -BraceWrapping: - AfterCaseLabel: false - AfterClass: false - AfterControlStatement: Never - AfterEnum: false - AfterExternBlock: false - AfterFunction: false - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: false - AfterUnion: false - BeforeCatch: false - BeforeElse: false - BeforeLambdaBody: false - BeforeWhile: false - IndentBraces: false - SplitEmptyFunction: true - SplitEmptyRecord: true - SplitEmptyNamespace: true -BreakAfterAttributes: Never -BreakAfterJavaFieldAnnotations: false -BreakArrays: true -BreakBeforeBinaryOperators: None -BreakBeforeConceptDeclarations: Always -BreakBeforeBraces: Custom -BreakBeforeInlineASMColon: OnlyMultiline -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: BeforeColon -BreakInheritanceList: BeforeColon -BreakStringLiterals: true -# Please update .markdownlint.yaml if this line is to be updated -ColumnLimit: 119 -CommentPragmas: '^ IWYU pragma:' -CompactNamespaces: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -EmptyLineAfterAccessModifier: Never -EmptyLineBeforeAccessModifier: LogicalBlock -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: - - foreach - - Q_FOREACH - - BOOST_FOREACH -IfMacros: - - KJ_IF_MAYBE -IncludeBlocks: Preserve -IncludeCategories: - - Regex: '^"(llvm|llvm-c|clang|clang-c)/' - Priority: 2 - SortPriority: 0 - CaseSensitive: false - - Regex: '^(<|"(gtest|isl|json)/)' - Priority: 3 - SortPriority: 0 - CaseSensitive: false - - Regex: '.*' - Priority: 1 - SortPriority: 0 - CaseSensitive: false -IncludeIsMainRegex: '$' -IncludeIsMainSourceRegex: '' -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentCaseLabels: false -IndentExternBlock: AfterExternBlock -IndentGotoLabels: true -IndentPPDirectives: BeforeHash -IndentRequiresClause: true -IndentWidth: 4 -IndentWrappedFunctionNames: false -InsertBraces: false -InsertNewlineAtEOF: false -InsertTrailingCommas: None -IntegerLiteralSeparator: - Binary: 0 - BinaryMinDigits: 0 - Decimal: 0 - DecimalMinDigits: 0 - Hex: 0 - HexMinDigits: 0 -JavaScriptQuotes: Leave -JavaScriptWrapImports: true -KeepEmptyLinesAtTheStartOfBlocks: true -KeepEmptyLinesAtEOF: false -LambdaBodyIndentation: Signature -LineEnding: DeriveLF -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBinPackProtocolList: Auto -ObjCBlockIndentWidth: 4 -ObjCBreakBeforeNestedBlockParam: true -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PackConstructorInitializers: NextLine -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakOpenParenthesis: 0 -PenaltyBreakString: 1000 -PenaltyBreakTemplateDeclaration: 10 -PenaltyExcessCharacter: 1000000 -PenaltyIndentedWhitespace: 0 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Left -PPIndentWidth: -1 -QualifierAlignment: Custom -QualifierOrder: - - inline - - static - - constexpr - - const - - volatile - - type -ReferenceAlignment: Pointer -ReflowComments: true -RemoveBracesLLVM: false -RemoveParentheses: Leave -RemoveSemicolon: false -RequiresClausePosition: OwnLine -RequiresExpressionIndentation: OuterScope -SeparateDefinitionBlocks: Leave -ShortNamespaceLines: 1 -SortIncludes: Never -SortJavaStaticImport: Before -SortUsingDeclarations: LexicographicNumeric -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceAroundPointerQualifiers: Default -SpaceBeforeAssignmentOperators: true -SpaceBeforeCaseColon: false -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true -SpaceBeforeJsonColon: false -SpaceBeforeParens: ControlStatements -SpaceBeforeParensOptions: - AfterControlStatements: true - AfterForeachMacros: true - AfterFunctionDefinitionName: false - AfterFunctionDeclarationName: false - AfterIfMacros: true - AfterOverloadedOperator: false - AfterRequiresInClause: false - AfterRequiresInExpression: false - BeforeNonEmptyParentheses: false -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyBlock: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: Never -SpacesInContainerLiterals: true -SpacesInLineCommentPrefix: - Minimum: 1 - Maximum: -1 -SpacesInParens: Never -SpacesInParensOptions: - InCStyleCasts: false - InConditionalStatements: false - InEmptyParentheses: false - Other: false -SpacesInSquareBrackets: false -Standard: Auto -StatementAttributeLikeMacros: - - Q_EMIT -StatementMacros: - - Q_UNUSED - - QT_REQUIRE_VERSION -TabWidth: 8 -UseTab: Never -VerilogBreakBetweenInstancePorts: true -WhitespaceSensitiveMacros: - - STRINGIZE - - PP_STRINGIZE - - BOOST_PP_STRINGIZE - - NS_SWIFT_NAME - - CF_SWIFT_NAME -... diff --git a/cookiecutter/{{cookiecutter.project_name}}/.gitattributes b/cookiecutter/{{cookiecutter.project_name}}/.gitattributes deleted file mode 100644 index 793dce7..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -infra/** linguist-vendored -cookiecutter/** linguist-vendored -*.bib -linguist-detectable -*.tex -linguist-detectable -papers/* linguist-documentation diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/CODEOWNERS b/cookiecutter/{{cookiecutter.project_name}}/.github/CODEOWNERS deleted file mode 100644 index cced7b3..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/CODEOWNERS +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -{% if cookiecutter._generating_exemplar %} -* @ednolan @bretbrownjr @camio @dietmarkuehl @steve-downey @wusatosi -{% else %} -* @{{ cookiecutter.maintainer }} -{% endif %} diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/implementation-deficiency.md b/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/implementation-deficiency.md deleted file mode 100644 index 4a0ee77..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/implementation-deficiency.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -name: Implementation Deficiency -about: Report a bug or performance issue of our implementation -title: '' -labels: bug -assignees: '' - ---- - - - -## Describe the deficiency - -A clear and concise description of what the deficiency is. -Link all relevant issues. -This could be a bug, or a performance problem. - -## To Reproduce - -```c++ -// Use case -``` - -## Expected Behavior - -A clear and concise description of what you expected to happen. - -## Additional Discussions - -Add any other context about the problem here. -If you believe your issue is platform dependent, -please post your compiler versions here. diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/infrastructure-issues.md b/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/infrastructure-issues.md deleted file mode 100644 index 11fbd13..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/infrastructure-issues.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -name: Infrastructure Issues -about: Report a bug or feature request with our Infrastructure -title: '' -labels: infra -assignees: '' - ---- - - - -## I am attempting to - -Describe what you were attempting to do. - -## Expected Behavior - -A clear and concise description of what you expected to happen. - -## Current Behavior - -A clear and concise description of what actually happened. - -## Additional Discussions - -Add any other context about the problem here. diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/paper-discussion.md b/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/paper-discussion.md deleted file mode 100644 index 14c9e4f..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/ISSUE_TEMPLATE/paper-discussion.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -name: Paper Discussion -about: Provide feedback to current API -title: '' -labels: '' -assignees: '' - ---- - - - -## Use case - -Describe your concerns about adding this change to the C++ Standard Library. - -```c++ -// example snippet -``` - -## What I like - -Let us know what you find positive about current approach / design. - -## What I dislike - -Let us know what you find negative about current approach / design. - -## Discussion - -Let us know if you have any more remarks. diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/pull_request_template.md b/cookiecutter/{{cookiecutter.project_name}}/.github/pull_request_template.md deleted file mode 100644 index 071cb28..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/pull_request_template.md +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml deleted file mode 100644 index 94d3bf1..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/ci_tests.yml +++ /dev/null @@ -1,203 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: Continuous Integration Tests - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - schedule: - - cron: '{% if cookiecutter._ci_tests_cron %}{{ cookiecutter._ci_tests_cron }}{% else %}{{ range(0, 60) | random }} {{ range(13, 18) | random }} * * {{ range(0, 7) | random }}{% endif %}' - -concurrency: - group: {% raw %}${{format('{0}:{1}', github.repository, github.ref)}}{% endraw %} - - cancel-in-progress: true - -jobs: - beman-submodule-check: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.7.2 - - preset-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.7.2 - with: - matrix_config: > - [ - {"preset": "gcc-debug", "image": "ghcr.io/bemanproject/infra-containers-gcc:latest"}, - {"preset": "gcc-release", "image": "ghcr.io/bemanproject/infra-containers-gcc:latest"}, - {"preset": "llvm-debug", "image": "ghcr.io/bemanproject/infra-containers-clang:latest"}, - {"preset": "llvm-release", "image": "ghcr.io/bemanproject/infra-containers-clang:latest"}, - {"preset": "appleclang-debug", "runner": "macos-latest"}, - {"preset": "appleclang-release", "runner": "macos-latest"}, - {"preset": "msvc-debug", "runner": "windows-latest"}, - {"preset": "msvc-release", "runner": "windows-latest"} - ] - - build-and-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.7.2 - with: - matrix_config: > - { - "gcc": [ - { "versions": ["16"], - "tests": [ - { "cxxversions": ["c++26"], - "tests": [ - { "stdlibs": ["libstdc++"], - "tests": [ - "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", - "Debug.Coverage", "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - }, - { "cxxversions": ["c++23"], - "tests": [ - { "stdlibs": ["libstdc++"], - "tests": [ - "Release.Default", "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - }, - { "cxxversions": ["c++20", "c++17"], - "tests": [{ "stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - }, - { "versions": ["15"], - "tests": [ - { "cxxversions": ["c++26", "c++23"], - "tests": [ - { "stdlibs": ["libstdc++"], - "tests": [ - "Release.Default", "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - }, - { "cxxversions": ["c++20", "c++17"], - "tests": [{ "stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - }, - { "versions": ["14", "13"], - "tests": [ - { "cxxversions": ["c++26", "c++23", "c++20", "c++17"], - "tests": [{ "stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - }, - { - "versions": ["12", "11"], - "tests": [ - { "cxxversions": ["c++23", "c++20", "c++17"], - "tests": [{ "stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - } - ], - "clang": [ - { "versions": ["22"], - "tests": [ - {"cxxversions": ["c++26"], - "tests": [ - { "stdlibs": ["libstdc++", "libc++"], - "tests": [ - "Debug.Default", "Release.Default", "Release.TSan", - "Release.MaxSan", "Debug.Werror", - "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - }, - { "cxxversions": ["c++23"], - "tests": [ - { "stdlibs": ["libstdc++", "libc++"], - "tests": [ - "Release.Default", "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - }, - { "cxxversions": ["c++20", "c++17"], - "tests": [ - {"stdlibs": ["libstdc++", "libc++"], "tests": ["Release.Default"]} - ] - } - ] - }, - { "versions": ["21", "20", "19"], - "tests": [ - { "cxxversions": ["c++26", "c++23", "c++20", "c++17"], - "tests": [ - {"stdlibs": ["libstdc++", "libc++"], "tests": ["Release.Default"]} - ] - } - ] - }, - { "versions": ["18"], - "tests": [ - { "cxxversions": ["c++26", "c++23", "c++20", "c++17"], - "tests": [{"stdlibs": ["libc++"], "tests": ["Release.Default"]}] - }, - { "cxxversions": ["c++23", "c++20", "c++17"], - "tests": [{"stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - }, - { "versions": ["17"], - "tests": [ - { "cxxversions": ["c++26", "c++23", "c++20", "c++17"], - "tests": [{"stdlibs": ["libc++"], "tests": ["Release.Default"]}] - }, - { "cxxversions": ["c++20", "c++17"], - "tests": [{"stdlibs": ["libstdc++"], "tests": ["Release.Default"]}] - } - ] - } - ], - "appleclang": [ - { "versions": ["latest"], - "tests": [ - { "cxxversions": ["c++26", "c++23", "c++20", "c++17"], - "tests": [{ "stdlibs": ["libc++"], "tests": ["Release.Default"]}] - } - ] - } - ], - "msvc": [ - { "versions": ["latest"], - "tests": [ - { "cxxversions": ["c++23"], - "tests": [ - { "stdlibs": ["stl"], - "tests": [ - "Debug.Default", "Release.Default", "Release.MaxSan", - "Debug.-DBEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES=On" - ] - } - ] - } - ] - } - ] - } - - vcpkg-ci: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-ci.yml@1.7.2 - with: - port_name: beman-{{cookiecutter.project_name.replace('_', '-')}} - feature_combinations: | - [ - {"features": {}}, - {"features": {"modules": true}} - ] - - create-issue-when-fault: - needs: [preset-test, build-and-test] - if: failure() && github.event_name == 'schedule' - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.7.2 diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-check.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-check.yml deleted file mode 100644 index 2ab92f2..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-check.yml +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -name: Lint Check (pre-commit) - -on: - # We have to use pull_request_target here as pull_request does not grant - # enough permission for reviewdog - pull_request_target: - push: - branches: - - main - -permissions: - contents: read - checks: write - issues: write - pull-requests: write - -jobs: - pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.7.2 diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml deleted file mode 100644 index 5b54ccb..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/pre-commit-update.yml +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: Weekly pre-commit autoupdate - -on: - workflow_dispatch: - schedule: - - cron: "{% if cookiecutter._pre_commit_update_cron %}{{ cookiecutter._pre_commit_update_cron }}{% else %}{{ range(0, 60) | random }} {{ range(13, 18) | random }} * * {{ range(0, 7) | random }}{% endif %}" - -{% raw -%} -jobs: - auto-update-pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.7.2 - secrets: - APP_ID: ${{ secrets.AUTO_PR_BOT_APP_ID }} - PRIVATE_KEY: ${{ secrets.AUTO_PR_BOT_PRIVATE_KEY }} -{%- endraw %} - diff --git a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/vcpkg-release.yml b/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/vcpkg-release.yml deleted file mode 100644 index f603636..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.github/workflows/vcpkg-release.yml +++ /dev/null @@ -1,16 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: vcpkg registry release -on: - release: - types: [published] -jobs: - vcpkg-release: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-release.yml@1.7.2 - with: - port_name: beman-{{cookiecutter.project_name.replace('_', '-')}} -{%- raw %} - secrets: - VCPKG_REGISTRY_TOKEN: ${{ secrets.VCPKG_REGISTRY_TOKEN }} -{%- endraw %} - diff --git a/cookiecutter/{{cookiecutter.project_name}}/.gitignore b/cookiecutter/{{cookiecutter.project_name}}/.gitignore deleted file mode 100644 index d62996c..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -/.cache -/compile_commands.json -/build - -# ignore emacs temp files -*~ -\#*\# - -# ignore vscode settings -.vscode - -# ignore vim swap files -.swp - -# ignore merge/patch backup files -.orig diff --git a/cookiecutter/{{cookiecutter.project_name}}/.markdownlint.yaml b/cookiecutter/{{cookiecutter.project_name}}/.markdownlint.yaml deleted file mode 100644 index 48269b5..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.markdownlint.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md033.md -# Disable inline html linter is needed for
-MD033: false - -# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md013.md -# Conforms to .clang-format ColumnLimit -# Update the comment in .clang-format if we no-longer tie these two column limits. -MD013: - line_length: 119 - code_blocks: false diff --git a/cookiecutter/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/cookiecutter/{{cookiecutter.project_name}}/.pre-commit-config.yaml deleted file mode 100644 index 3845c97..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - # Clang-format for C++ - # This brings in a portable version of clang-format. - # See also: https://github.com/ssciwr/clang-format-wheel - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v22.1.4 - hooks: - - id: clang-format - types_or: [c++, c] - - # CMake linting and formatting - - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.27.2 - hooks: - - id: gersemi - name: CMake linting - exclude: ^.*/tests/.*/data/ # Exclude test data directories - - # Markdown linting - # Config file: .markdownlint.yaml - # Commented out to disable this by default. Uncomment to enable markdown linting. - # - repo: https://github.com/igorshubovych/markdownlint-cli - # rev: v0.42.0 - # hooks: - # - id: markdownlint - - - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 - hooks: - - id: codespell - -{% if not cookiecutter._generating_exemplar %} - # Beman Standard checking via beman-tidy - - repo: https://github.com/bemanproject/beman-tidy - rev: v0.3.1 - hooks: - - id: beman-tidy - -{% endif %} -exclude: 'cookiecutter/|infra/|port/' diff --git a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt deleted file mode 100644 index 8018142..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -cmake_minimum_required(VERSION 3.30...4.3) - -include(infra/cmake/enable-experimental-import-std.cmake) - -project( - beman.{{cookiecutter.project_name}} - DESCRIPTION "{{cookiecutter.description}}" - LANGUAGES CXX -{% if cookiecutter._generating_exemplar %} - VERSION 2.4.0 -{% else %} - VERSION 0.1.0 -{% endif %} -) - -# [CMAKE.SKIP_TESTS] -option( - BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS - "Enable building tests and test infrastructure. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." - ${PROJECT_IS_TOP_LEVEL} -) - -# [CMAKE.SKIP_EXAMPLES] -option( - BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_EXAMPLES - "Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }." - ${PROJECT_IS_TOP_LEVEL} -) - -option(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES "Provide beman.{{cookiecutter.project_name}} as a C++ module" OFF) - -if(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES) - set(CMAKE_CXX_SCAN_FOR_MODULES ON) -endif() - -configure_file( - "${PROJECT_SOURCE_DIR}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp.in" - "${PROJECT_BINARY_DIR}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp" - @ONLY -) - -# for find of beman_install_library and configure_build_telemetry -include(infra/cmake/beman-install-library.cmake) -include(infra/cmake/BuildTelemetryConfig.cmake) - -if(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES) - add_library(beman.{{cookiecutter.project_name}} STATIC) -else() - add_library(beman.{{cookiecutter.project_name}} INTERFACE) -endif() -add_library(beman::{{cookiecutter.project_name}} ALIAS beman.{{cookiecutter.project_name}}) - -if(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES) - target_sources( - beman.{{cookiecutter.project_name}} - PUBLIC - FILE_SET CXX_MODULES - FILE_SET HEADERS - BASE_DIRS - "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_BINARY_DIR}/include" - ) - set_target_properties(beman.{{cookiecutter.project_name}} PROPERTIES CXX_MODULE_STD ON) - target_compile_features(beman.{{cookiecutter.project_name}} PUBLIC cxx_std_23) -else() - target_sources( - beman.{{cookiecutter.project_name}} - PUBLIC - FILE_SET HEADERS - BASE_DIRS - "${CMAKE_CURRENT_SOURCE_DIR}/include" - "${CMAKE_CURRENT_BINARY_DIR}/include" - ) - set_target_properties( - beman.{{cookiecutter.project_name}} - PROPERTIES VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL} - ) -endif() - -add_subdirectory(include/beman/{{cookiecutter.project_name}}) - -beman_install_library(beman.{{cookiecutter.project_name}} TARGETS beman.{{cookiecutter.project_name}}) -configure_build_telemetry() - -if(BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS) - enable_testing() - add_subdirectory(tests/beman/{{cookiecutter.project_name}}) -endif() - -if(BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_EXAMPLES) - add_subdirectory(examples) -endif() diff --git a/cookiecutter/{{cookiecutter.project_name}}/CMakePresets.json b/cookiecutter/{{cookiecutter.project_name}}/CMakePresets.json deleted file mode 100644 index cd426be..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/CMakePresets.json +++ /dev/null @@ -1,373 +0,0 @@ -{ - "version": 6, - "configurePresets": [ - { - "name": "_root-config", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", - "cacheVariables": { - "CMAKE_CXX_STANDARD": "{{cookiecutter.minimum_cpp_build_version}}", - "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", - "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "./infra/cmake/use-fetch-content.cmake" - } - }, - { - "name": "_debug-base", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "BEMAN_BUILDSYS_SANITIZER": "MaxSan" - } - }, - { - "name": "_release-base", - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "gcc-debug", - "displayName": "GCC Debug Build", - "inherits": [ - "_root-config", - "_debug-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/gnu-toolchain.cmake" - } - }, - { - "name": "gcc-release", - "displayName": "GCC Release Build", - "inherits": [ - "_root-config", - "_release-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/gnu-toolchain.cmake" - } - }, - { - "name": "llvm-debug", - "displayName": "Clang Debug Build", - "inherits": [ - "_root-config", - "_debug-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/llvm-toolchain.cmake" - } - }, - { - "name": "llvm-release", - "displayName": "Clang Release Build", - "inherits": [ - "_root-config", - "_release-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/llvm-toolchain.cmake" - } - }, - { - "name": "appleclang-debug", - "displayName": "Appleclang Debug Build", - "inherits": [ - "_root-config", - "_debug-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/appleclang-toolchain.cmake" - } - }, - { - "name": "appleclang-release", - "displayName": "Appleclang Release Build", - "inherits": [ - "_root-config", - "_release-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/appleclang-toolchain.cmake" - } - }, - { - "name": "msvc-debug", - "displayName": "MSVC Debug Build", - "inherits": [ - "_root-config", - "_debug-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/msvc-toolchain.cmake" - } - }, - { - "name": "msvc-release", - "displayName": "MSVC Release Build", - "inherits": [ - "_root-config", - "_release-base" - ], - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "infra/cmake/msvc-toolchain.cmake" - } - } - ], - "buildPresets": [ - { - "name": "_root-build", - "hidden": true, - "jobs": 0 - }, - { - "name": "gcc-debug", - "configurePreset": "gcc-debug", - "inherits": [ - "_root-build" - ] - }, - { - "name": "gcc-release", - "configurePreset": "gcc-release", - "inherits": [ - "_root-build" - ] - }, - { - "name": "llvm-debug", - "configurePreset": "llvm-debug", - "inherits": [ - "_root-build" - ] - }, - { - "name": "llvm-release", - "configurePreset": "llvm-release", - "inherits": [ - "_root-build" - ] - }, - { - "name": "appleclang-debug", - "configurePreset": "appleclang-debug", - "inherits": [ - "_root-build" - ] - }, - { - "name": "appleclang-release", - "configurePreset": "appleclang-release", - "inherits": [ - "_root-build" - ] - }, - { - "name": "msvc-debug", - "configurePreset": "msvc-debug", - "inherits": [ - "_root-build" - ] - }, - { - "name": "msvc-release", - "configurePreset": "msvc-release", - "inherits": [ - "_root-build" - ] - } - ], - "testPresets": [ - { - "name": "_test_base", - "hidden": true, - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } - }, - { - "name": "gcc-debug", - "inherits": "_test_base", - "configurePreset": "gcc-debug" - }, - { - "name": "gcc-release", - "inherits": "_test_base", - "configurePreset": "gcc-release" - }, - { - "name": "llvm-debug", - "inherits": "_test_base", - "configurePreset": "llvm-debug" - }, - { - "name": "llvm-release", - "inherits": "_test_base", - "configurePreset": "llvm-release" - }, - { - "name": "appleclang-debug", - "inherits": "_test_base", - "configurePreset": "appleclang-debug" - }, - { - "name": "appleclang-release", - "inherits": "_test_base", - "configurePreset": "appleclang-release" - }, - { - "name": "msvc-debug", - "inherits": "_test_base", - "configurePreset": "msvc-debug" - }, - { - "name": "msvc-release", - "inherits": "_test_base", - "configurePreset": "msvc-release" - } - ], - "workflowPresets": [ - { - "name": "gcc-debug", - "steps": [ - { - "type": "configure", - "name": "gcc-debug" - }, - { - "type": "build", - "name": "gcc-debug" - }, - { - "type": "test", - "name": "gcc-debug" - } - ] - }, - { - "name": "gcc-release", - "steps": [ - { - "type": "configure", - "name": "gcc-release" - }, - { - "type": "build", - "name": "gcc-release" - }, - { - "type": "test", - "name": "gcc-release" - } - ] - }, - { - "name": "llvm-debug", - "steps": [ - { - "type": "configure", - "name": "llvm-debug" - }, - { - "type": "build", - "name": "llvm-debug" - }, - { - "type": "test", - "name": "llvm-debug" - } - ] - }, - { - "name": "llvm-release", - "steps": [ - { - "type": "configure", - "name": "llvm-release" - }, - { - "type": "build", - "name": "llvm-release" - }, - { - "type": "test", - "name": "llvm-release" - } - ] - }, - { - "name": "appleclang-debug", - "steps": [ - { - "type": "configure", - "name": "appleclang-debug" - }, - { - "type": "build", - "name": "appleclang-debug" - }, - { - "type": "test", - "name": "appleclang-debug" - } - ] - }, - { - "name": "appleclang-release", - "steps": [ - { - "type": "configure", - "name": "appleclang-release" - }, - { - "type": "build", - "name": "appleclang-release" - }, - { - "type": "test", - "name": "appleclang-release" - } - ] - }, - { - "name": "msvc-debug", - "steps": [ - { - "type": "configure", - "name": "msvc-debug" - }, - { - "type": "build", - "name": "msvc-debug" - }, - { - "type": "test", - "name": "msvc-debug" - } - ] - }, - { - "name": "msvc-release", - "steps": [ - { - "type": "configure", - "name": "msvc-release" - }, - { - "type": "build", - "name": "msvc-release" - }, - { - "type": "test", - "name": "msvc-release" - } - ] - } - ] -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/CONTRIBUTING.md b/cookiecutter/{{cookiecutter.project_name}}/CONTRIBUTING.md deleted file mode 100644 index d15f284..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/CONTRIBUTING.md +++ /dev/null @@ -1,139 +0,0 @@ - - -# Development - -## Configure and Build the Project Using CMake Presets - -The simplest way of configuring and building the project is to use [CMake -Presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html). Appropriate -presets for major compilers have been included by default. You can use `cmake ---list-presets=workflow` to see all available presets. - -Here is an example of invoking the `gcc-debug` preset: - -```shell -cmake --workflow --preset gcc-debug -``` - -Generally, there are two kinds of presets, `debug` and `release`. - -The `debug` presets are designed to aid development, so they have debuginfo and sanitizers -enabled. - -> [!NOTE] -> -> The sanitizers that are enabled vary from compiler to compiler. See the toolchain files -> under ([`infra/cmake`](infra/cmake/)) to determine the exact configuration used for each -> preset. - -The `release` presets are designed for production use, and -consequently have the highest optimization turned on (e.g. `O3`). - -## Configure and Build Manually - -If the presets are not suitable for your use case, a traditional CMake invocation will -provide more configurability. - -To configure, build and test the project manually, you can run this set of commands. Note -that this requires GoogleTest to be installed. - -```bash -cmake \ - -B build \ - -S . \ - -DCMAKE_CXX_STANDARD={{cookiecutter.minimum_cpp_build_version}} \ - # Your extra arguments here. -cmake --build build -ctest --test-dir build -``` - -> [!IMPORTANT] -> -> Beman projects are [passive projects]( -> https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md#cmakepassive_projects), -> so you need to specify the C++ version via `CMAKE_CXX_STANDARD` when manually -> configuring the project. - -## Dependency Management - -### vcpkg - -The best way to install the project's dependencies is to use the vcpkg workflow. - -To do so, make sure vcpkg is installed and `VCPKG_ROOT` is defined in your environment, -then specify -`-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"`. Vcpkg will handle -the project's dependencies, including GoogleTest. - -Example commands: - -```shell -cmake \ - -B build \ - -S . \ - -DCMAKE_CXX_STANDARD=17 \ - -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -cmake --build build -ctest --test-dir build -``` - -The file `./vcpkg.json` configures the list of dependencies that will be configured by -vcpkg. - -### FetchContent - -Instead of installing the project's dependencies via a package manager, you can optionally -configure beman.{{cookiecutter.project_name}} to fetch them automatically via CMake FetchContent. - -To do so, specify -`-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake`. This will -bring in GoogleTest automatically along with any other dependency the project may require. - -Example commands: - -```shell -cmake \ - -B build \ - -S . \ - -DCMAKE_CXX_STANDARD={{cookiecutter.minimum_cpp_build_version}} \ - -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=./infra/cmake/use-fetch-content.cmake -cmake --build build -ctest --test-dir build -``` - -The file `./lockfile.json` configures the list of dependencies and versions that will be -acquired by FetchContent. - -## Project-specific configure arguments - -Project-specific options are prefixed with `BEMAN_{{cookiecutter.project_name.upper()}}`. -You can see the list of available options with: - -```bash -cmake -LH -S . -B build | grep "BEMAN_{{cookiecutter.project_name.upper()}}" -C 2 -``` - -
- -Some project-specific configure arguments - -### `BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS` - -Enable building tests and test infrastructure. Default: `ON`. -Values: `{ ON, OFF }`. - -### `BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_EXAMPLES` - -Enable building examples. Default: `ON`. Values: `{ ON, OFF }`. - -### `BEMAN_{{cookiecutter.project_name.upper()}}_INSTALL_CONFIG_FILE_PACKAGE` - -Enable installing the CMake config file package. Default: `ON`. -Values: `{ ON, OFF }`. - -This is required so that users of `beman.{{cookiecutter.project_name}}` can use -`find_package(beman.{{cookiecutter.project_name}})` to locate the library. - -
diff --git a/cookiecutter/{{cookiecutter.project_name}}/LICENSE b/cookiecutter/{{cookiecutter.project_name}}/LICENSE deleted file mode 100644 index f6db814..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/LICENSE +++ /dev/null @@ -1,219 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. diff --git a/cookiecutter/{{cookiecutter.project_name}}/README.md b/cookiecutter/{{cookiecutter.project_name}}/README.md deleted file mode 100644 index e316112..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/README.md +++ /dev/null @@ -1,267 +0,0 @@ -{% if cookiecutter._generating_exemplar %} -# How to Use This Template - -To create a new Beman library, first click the "Use this template" dropdown in the -top-right and select "Create a new repository": - -
- -
- -This will create a new repository that's an exact copy of exemplar. The next step is to -customize it for your use case. - -To do so, execute the bash script `stamp.sh`. This script will prompt for parameters like -the new library's name, paper number, and description. Then it will replace your exemplar -copy with a stamped-out template containing these parameters and create a corresponding -git commit and branch: - -``` -$ ./stamp.sh - [1/6] project_name (my_project_name): example_library - [2/6] maintainer (your_github_username): your_username - [3/6] minimum_cpp_build_version (20): - [4/6] paper (PnnnnRr): P9999R9 - [5/6] description (Short project description.): - [6/6] Select unit_test_library - 1 - gtest - 2 - catch2 - Choose from [1/2] (1): -Switched to a new branch 'stamp' -Successfully stamped out exemplar template to the new branch 'stamp'. -Try 'git push origin stamp' to push the branch upstream, -then create a pull request. -``` - -From there, you can simply fill in all the remaining parts of the repository that are -labeled 'todo'. - -What follow is an example of a Beman library README. - -{% endif %} -# beman.{{cookiecutter.project_name}}: {{cookiecutter.description}} - - - - -![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg) ![Continuous Integration Tests](https://github.com/{{cookiecutter._owner}}/{{cookiecutter.project_name}}/actions/workflows/ci_tests.yml/badge.svg) ![Lint Check (pre-commit)](https://github.com/{{cookiecutter._owner}}/{{cookiecutter.project_name}}/actions/workflows/pre-commit-check.yml/badge.svg) [![Coverage](https://coveralls.io/repos/github/{{cookiecutter._owner}}/{{cookiecutter.project_name}}/badge.svg?branch=main)](https://coveralls.io/github/{{cookiecutter._owner}}/{{cookiecutter.project_name}}?branch=main) ![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp29.svg){% if cookiecutter._generating_exemplar %} [![Compiler Explorer Example](https://img.shields.io/badge/Try%20it%20on%20Compiler%20Explorer-grey?logo=compilerexplorer&logoColor=67c52a)](https://godbolt.org/z/4qEPK87va){% endif %} - - -{% if cookiecutter._generating_exemplar %} -`beman.exemplar` is a minimal C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md). -This can be used as a template for those intending to write Beman libraries. -It may also find use as a minimal and modern C++ project structure. -{% else %} -`beman.{{cookiecutter.project_name}}` is (... TODO: description). -{% endif %} - -{% if cookiecutter._generating_exemplar %} -**Implements**: `std::identity` proposed in [Standard Library Concepts ({{cookiecutter.paper}})](https://wg21.link/{{cookiecutter.paper}}). -{% else %} -**Implements**: `std::todo` proposed in [TODO ({{cookiecutter.paper}})](https://wg21.link/{{cookiecutter.paper}}). -{% endif %} - -**Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#under-development-and-not-yet-ready-for-production-use) - -## License - -`beman.{{cookiecutter.project_name}}` is licensed under the Apache License v2.0 with LLVM Exceptions. - -## Usage - -{% if cookiecutter._generating_exemplar %} -`std::identity` is a function object type whose `operator()` returns its argument unchanged. -`std::identity` serves as the default projection in constrained algorithms. -Its direct usage is usually not needed. - -### Usage: default projection in constrained algorithms - -The following code snippet illustrates how we can achieve a default projection using `beman::{{cookiecutter.project_name}}::identity`: - -```cpp -#include - -namespace exe = beman::{{cookiecutter.project_name}}; - -// Class with a pair of values. -struct Pair -{ - int n; - std::string s; - - // Output the pair in the form {n, s}. - // Used by the range-printer if no custom projection is provided (default: identity projection). - friend std::ostream &operator<<(std::ostream &os, const Pair &p) - { - return os << "Pair" << '{' << p.n << ", " << p.s << '}'; - } -}; - -// A range-printer that can print projected (modified) elements of a range. -// All the elements of the range are printed in the form {element1, element2, ...}. -// e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three} -// e.g., pairs with custom projection: {1:one, 2:two, 3:three} -template -void print(const std::string_view rem, R &&range, Projection projection = exe::identity>) -{ - std::cout << rem << '{'; - std::ranges::for_each( - range, - [O = 0](const auto &o) mutable - { std::cout << (O++ ? ", " : "") << o; }, - projection); - std::cout << "}\n"; -}; - -int main() -{ - // A vector of pairs to print. - const std::vector pairs = { - {1, "one"}, - {2, "two"}, - {3, "three"}, - }; - - // Print the pairs using the default projection. - print("\tpairs with beman: ", pairs); - - return 0; -} - -``` - -{% else %} -TODO - -{% endif %} -Full runnable examples can be found in [`examples/`](examples/). - -## Dependencies - -### Build Environment - -This project requires at least the following to build: - -* A C++ compiler that conforms to the C++{{cookiecutter.minimum_cpp_build_version}} standard or greater -* CMake 3.30 or later -* (Test Only) GoogleTest - -You can disable building tests by setting CMake option `BEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS` to -`OFF` when configuring the project. - -### Supported Platforms - -| Compiler | Version | C++ Standards | Standard Library | -|------------|---------|---------------|-------------------| -| GCC | 16-13 | C++26-C++17 | libstdc++ | -| GCC | 12-11 | C++23-C++17 | libstdc++ | -| Clang | 22-19 | C++26-C++17 | libstdc++, libc++ | -| Clang | 18 | C++26-C++17 | libc++ | -| Clang | 18 | C++23-C++17 | libstdc++ | -| Clang | 17 | C++26-C++17 | libc++ | -| Clang | 17 | C++20, C++17 | libstdc++ | -| AppleClang | latest | C++26-C++17 | libc++ | -| MSVC | latest | C++23 | MSVC STL | - -## Development - -See the [Contributing Guidelines](CONTRIBUTING.md). - -## Integrate beman.{{cookiecutter.project_name}} into your project - -### Build - -You can build {{cookiecutter.project_name}} using a CMake workflow preset: - -```bash -cmake --workflow --preset gcc-release -``` - -To list available workflow presets, you can invoke: - -```bash -cmake --list-presets=workflow -``` - -For details on building beman.{{cookiecutter.project_name}} without using a CMake preset, refer to the -[Contributing Guidelines](CONTRIBUTING.md). - -### Installation - -#### Vcpkg - -The preferred way to install {{cookiecutter.project_name}} is via vcpkg. To do so, after installing vcpkg -itself, you need to add support for the Beman project's [vcpkg -registry](https://github.com/bemanproject/vcpkg-registry) by configuring a -`vcpkg-configuration.json` file (which {{cookiecutter.project_name}} [provides](vcpkg-configuration.json)). - -Then, simply run `vcpkg install beman-{{cookiecutter.project_name.replace("_", "-")}}`. - -#### Manual - -To install beman.{{cookiecutter.project_name}} globally after building with the `gcc-release` preset, you can -run: - -```bash -sudo cmake --install build/gcc-release -``` - -Alternatively, to install to a prefix, for example `/opt/beman`, you can run: - -```bash -sudo cmake --install build/gcc-release --prefix /opt/beman -``` - -This will generate the following directory structure: - -```txt -/opt/beman -├── include -│ └── beman -│ └── {{cookiecutter.project_name}} -│ ├── {{cookiecutter.project_name}}.hpp -│ └── ... -└── lib - └── cmake - └── beman.{{cookiecutter.project_name}} - ├── beman.{{cookiecutter.project_name}}-config-version.cmake - ├── beman.{{cookiecutter.project_name}}-config.cmake - └── beman.{{cookiecutter.project_name}}-targets.cmake -``` - -### CMake Configuration - -If you installed beman.{{cookiecutter.project_name}} to a prefix, you can specify that prefix to your CMake -project using `CMAKE_PREFIX_PATH`; for example, `-DCMAKE_PREFIX_PATH=/opt/beman`. - -You need to bring in the `beman.{{cookiecutter.project_name}}` package to define the `beman::{{cookiecutter.project_name}}` CMake -target: - -```cmake -find_package(beman.{{cookiecutter.project_name}} REQUIRED) -``` - -You will then need to add `beman::{{cookiecutter.project_name}}` to the link libraries of any libraries or -executables that include `beman.{{cookiecutter.project_name}}` headers. - -```cmake -target_link_libraries(yourlib PUBLIC beman::{{cookiecutter.project_name}}) -``` - -### Using beman.{{cookiecutter.project_name}} - -To use `beman.{{cookiecutter.project_name}}` in your C++ project, -include an appropriate `beman.{{cookiecutter.project_name}}` header from your source code. - -```c++ -#include -``` - -> [!NOTE] -> -> `beman.{{cookiecutter.project_name}}` headers are to be included with the `beman/{{cookiecutter.project_name}}/` prefix. -> Altering include search paths to spell the include target another way (e.g. -> `#include <{{cookiecutter.project_name}}.hpp>`) is unsupported. diff --git a/cookiecutter/{{cookiecutter.project_name}}/examples/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/examples/CMakeLists.txt deleted file mode 100644 index fddbf1f..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/examples/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -{% if cookiecutter._generating_exemplar %} -set(ALL_EXAMPLES identity_direct_usage) - -# Example `identity_as_default_projection` need ranges support: -include(CheckCXXSymbolExists) -check_cxx_symbol_exists(__cpp_lib_ranges "ranges" HAS_RANGES) - -if(HAS_RANGES) - list(APPEND ALL_EXAMPLES identity_as_default_projection) -else() - message( - WARNING - "Missing range support! Skip: identity_as_default_projection" - ) -endif() - -{% else %} -set(ALL_EXAMPLES todo) -{% endif %} -message("Examples to be built: ${ALL_EXAMPLES}") - -foreach(example ${ALL_EXAMPLES}) - add_executable(beman.{{cookiecutter.project_name}}.examples.${example}) - target_sources(beman.{{cookiecutter.project_name}}.examples.${example} PRIVATE ${example}.cpp) - target_link_libraries( - beman.{{cookiecutter.project_name}}.examples.${example} - PRIVATE beman::{{cookiecutter.project_name}} - ) - if(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES) - set_target_properties( - beman.{{cookiecutter.project_name}}.examples.${example} - PROPERTIES CXX_MODULE_STD ON - ) - endif() -endforeach() diff --git a/cookiecutter/{{cookiecutter.project_name}}/examples/identity_as_default_projection.cpp b/cookiecutter/{{cookiecutter.project_name}}/examples/identity_as_default_projection.cpp deleted file mode 100644 index 20a95e8..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/examples/identity_as_default_projection.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// This example demonstrates the usage of beman::{{cookiecutter.project_name}}::identity as a default projection in a range-printer. -// Requires: range support (C++20) and std::identity support (C++20). - -#include -#include - -#if BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() -import std; -#else - #include - #include // std::identity - #include - #include - #include - #include -#endif - -namespace exe = beman::{{cookiecutter.project_name}}; - -// Class with a pair of values. -struct Pair { - int n; - std::string s; - - // Output the pair in the form {n, s}. - // Used by the range-printer if no custom projection is provided (default: identity projection). - friend std::ostream& operator<<(std::ostream& os, const Pair& p) { - return os << "Pair" << '{' << p.n << ", " << p.s << '}'; - } -}; - -// A range-printer that can print projected (modified) elements of a range. -// All the elements of the range are printed in the form {element1, element2, ...}. -// e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three} -// e.g., pairs with custom projection: {1:one, 2:two, 3:three} -template -void print_helper(const std::string_view rem, R&& range, Projection projection) { - std::cout << rem << '{'; - std::ranges::for_each(range, [O = 0](const auto& o) mutable { std::cout << (O++ ? ", " : "") << o; }, projection); - std::cout << "}\n"; -}; - -// Print wrapper with exe::identity. -template // <- Notice the default projection. -void print_beman(const std::string_view rem, R&& range, Projection projection = {}) { - print_helper(rem, range, projection); -} - -// Print wrapper with std::identity. -template // <- Notice the default projection. -void print_std(const std::string_view rem, R&& range, Projection projection = {}) { - print_helper(rem, range, projection); -} - -int main() { - // A vector of pairs to print. - const std::vector pairs = { - {1, "one"}, - {2, "two"}, - {3, "three"}, - }; - - // Print the pairs using the default projection. - std::cout << "Default projection:\n"; - print_beman("\tpairs with beman: ", pairs); - print_std("\tpairs with std: ", pairs); - - // Print the pairs using a custom projection. - std::cout << "Custom projection:\n"; - print_beman("\tpairs with beman: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); - print_std("\tpairs with std: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); - - return 0; -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/examples/identity_direct_usage.cpp b/cookiecutter/{{cookiecutter.project_name}}/examples/identity_direct_usage.cpp deleted file mode 100644 index 0284d36..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/examples/identity_direct_usage.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -#include -#include - -{% if cookiecutter._generating_exemplar %} -#if BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() -import std; -#else - #include -#endif - -namespace exe = beman::{{cookiecutter.project_name}}; - -int main() { - std::cout << exe::identity()(2024) << '\n'; - return 0; -} -{% else %} -int main() { - // TODO -} -{% endif %} diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/CMakeLists.txt deleted file mode 100644 index 352eb05..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -if(BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES) - target_sources( - beman.{{cookiecutter.project_name}} - PUBLIC - FILE_SET CXX_MODULES FILES {{cookiecutter.project_name}}.cppm - FILE_SET HEADERS - FILES - config.hpp - {{cookiecutter.project_name}}.hpp - {{identity}}.hpp - "${PROJECT_BINARY_DIR}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp" - ) -else() - target_sources( - beman.{{cookiecutter.project_name}} - PUBLIC - FILE_SET HEADERS - FILES - config.hpp - {{cookiecutter.project_name}}.hpp - {{identity}}.hpp - "${PROJECT_BINARY_DIR}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp" - ) -endif() diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config.hpp b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config.hpp deleted file mode 100644 index 7b86494..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_{{cookiecutter.project_name.upper()}}_CONFIG_HPP -#define BEMAN_{{cookiecutter.project_name.upper()}}_CONFIG_HPP - -#if !defined(__has_include) || __has_include() - #include -#else - #define BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() 0 -#endif - -#endif diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp.in b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp.in deleted file mode 100644 index 90941a1..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/config_generated.hpp.in +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_{{cookiecutter.project_name.upper()}}_CONFIG_GENERATED_HPP -#define BEMAN_{{cookiecutter.project_name.upper()}}_CONFIG_GENERATED_HPP - -#cmakedefine01 BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() - -#endif diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/identity.hpp b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/identity.hpp deleted file mode 100644 index bdea366..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/identity.hpp +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -#ifndef BEMAN_{{cookiecutter.project_name.upper()}}_{{identity.upper()}}_HPP -#define BEMAN_{{cookiecutter.project_name.upper()}}_{{identity.upper()}}_HPP - -#include - -#if BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() && !defined(BEMAN_{{cookiecutter.project_name.upper()}}_INCLUDED_FROM_INTERFACE_UNIT) - -import beman.{{cookiecutter.project_name}}; - -#else - -{% if cookiecutter._generating_exemplar %} - // C++ Standard Library: std::identity equivalent. - // See https://eel.is/c++draft/func.identity: - // - // 22.10.12 Class identity [func.identity] - // - // struct identity { - // template - // constexpr T&& operator()(T&& t) const noexcept; - // - // using is_transparent = unspecified; - // }; - // - // template - // constexpr T&& operator()(T&& t) const noexcept; - // - // Effects: Equivalent to: return std::forward(t); - - #if !BEMAN_EXEMPLAR_USE_MODULES() - #include // std::forward - #endif - -{% endif %} -namespace beman::{{cookiecutter.project_name}} { - -{% if cookiecutter._generating_exemplar %} -struct __is_transparent; // not defined - -// A function object that returns its argument unchanged. -struct identity { - // Returns `t`. - template - constexpr T&& operator()(T&& t) const noexcept { - return std::forward(t); - } - - using is_transparent = __is_transparent; -}; - -{% else %} -// TODO - -{% endif %} -} // namespace beman::{{cookiecutter.project_name}} - -#endif // BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() && - // !defined(BEMAN_{{cookiecutter.project_name.upper()}}_INCLUDED_FROM_INTERFACE_UNIT) - -#endif // BEMAN_{{cookiecutter.project_name.upper()}}_{{identity.upper()}}_HPP diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.cppm b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.cppm deleted file mode 100644 index 96b1548..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.cppm +++ /dev/null @@ -1,11 +0,0 @@ -export module beman.{{cookiecutter.project_name}}; - -import std; - -#define BEMAN_{{cookiecutter.project_name.upper()}}_INCLUDED_FROM_INTERFACE_UNIT -export { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" -#include -#pragma clang diagnostic pop -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.hpp b/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.hpp deleted file mode 100644 index 7df9cb8..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/include/beman/{{cookiecutter.project_name}}/{{cookiecutter.project_name}}.hpp +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -#ifndef BEMAN_{{cookiecutter.project_name.upper()}}_{{cookiecutter.project_name.upper()}}_HPP -#define BEMAN_{{cookiecutter.project_name.upper()}}_{{cookiecutter.project_name.upper()}}_HPP - -#include - -#if BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() && !defined(BEMAN_{{cookiecutter.project_name.upper()}}_INCLUDED_FROM_INTERFACE_UNIT) - -import beman.{{cookiecutter.project_name}}; - -#else - - #include - -#endif // BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES() && - // !defined(BEMAN_{{cookiecutter.project_name.upper()}}_INCLUDED_FROM_INTERFACE_UNIT) - -#endif // BEMAN_{{cookiecutter.project_name.upper()}}_{{cookiecutter.project_name.upper()}}_HPP diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.beman_submodule b/cookiecutter/{{cookiecutter.project_name}}/infra/.beman_submodule deleted file mode 100644 index 7367e0e..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.beman_submodule +++ /dev/null @@ -1,3 +0,0 @@ -[beman_submodule] -remote=https://github.com/bemanproject/infra.git -commit_hash=eb7b7c3688bd8f26ab0c145e3147df9a8f2ec8ce diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/CODEOWNERS b/cookiecutter/{{cookiecutter.project_name}}/infra/.github/CODEOWNERS deleted file mode 100644 index 4ff90a4..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @ednolan @neatudarius @rishyak @wusatosi @JeffGarland diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/pre-commit.yml b/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/pre-commit.yml deleted file mode 100644 index 7051c13..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/pre-commit.yml +++ /dev/null @@ -1,79 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -name: Lint Check (pre-commit) - -on: - # We have to use pull_request_target here as pull_request does not grant - # enough permission for reviewdog - pull_request_target: - push: - branches: - - main - -jobs: - pre-commit-push: - name: Pre-Commit check on Push - runs-on: ubuntu-latest - if: ${{ github.event_name == 'push' }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.13 - - # We wish to run pre-commit on all files instead of the changes - # only made in the push commit. - # - # So linting error persists when there's formatting problem. - - uses: pre-commit/action@v3.0.1 - - pre-commit-pr: - name: Pre-Commit check on PR - runs-on: ubuntu-latest - if: ${{ github.event_name == 'pull_request_target' }} - - permissions: - contents: read - checks: write - issues: write - pull-requests: write - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # pull_request_target checkout the base of the repo - # We need to checkout the actual pr to lint the changes. - - name: Checkout pr - run: gh pr checkout ${{ github.event.number }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.13 - - # we only lint on the changed file in PR. - - name: Get Changed Files - id: changed-files - uses: tj-actions/changed-files@v45 - - # See: - # https://github.com/tj-actions/changed-files?tab=readme-ov-file#using-local-git-directory- - - uses: pre-commit/action@v3.0.1 - id: run-pre-commit - with: - extra_args: --files ${{ steps.changed-files.outputs.all_changed_files }} - - # Review dog posts the suggested change from pre-commit to the pr. - - name: suggester / pre-commit - uses: reviewdog/action-suggester@v1 - if: ${{ failure() && steps.run-pre-commit.conclusion == 'failure' }} - with: - tool_name: pre-commit - level: warning - reviewdog_flags: "-fail-level=error" diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/reusable-beman-create-issue-when-fault.yml b/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/reusable-beman-create-issue-when-fault.yml deleted file mode 100644 index 024a51f..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.github/workflows/reusable-beman-create-issue-when-fault.yml +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -name: 'Beman issue creation workflow' -on: - workflow_call: - workflow_dispatch: -jobs: - create-issue: - runs-on: ubuntu-latest - steps: - # See https://github.com/cli/cli/issues/5075 - - uses: actions/checkout@v4 - - name: Create issue - run: | - issue_num=$(gh issue list -s open -S "[SCHEDULED-BUILD] infra repo CI job failure" -L 1 --json number | jq 'if length == 0 then -1 else .[0].number end') - body="**CI job failure Report** - - **Time of Failure**: $(date -u '+%B %d, %Y, %H:%M %Z') - - **Commit**: [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) - - **Action Run**: [View logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - The scheduled job triggered by cron has failed. - Please investigate the logs and recent changes associated with this commit or rerun the workflow if you believe this is an error." - if [[ $issue_num -eq -1 ]]; then - gh issue create --repo ${{ github.repository }} --title "[SCHEDULED-BUILD] infra repo CI job failure" --body "$body" --assignee ${{ github.actor }} - else - gh issue comment --repo ${{ github.repository }} $issue_num --body "$body" - fi - env: - GH_TOKEN: ${{ github.token }} diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.gitignore b/cookiecutter/{{cookiecutter.project_name}}/infra/.gitignore deleted file mode 100644 index b7cdbb5..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.gitignore +++ /dev/null @@ -1,59 +0,0 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Fortran module files -*.mod -*.smod - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app - -# Python -__pycache__/ -.pytest_cache/ -*.pyc -*.pyo -*.pyd -*.pyw -*.pyz -*.pywz -*.pyzw -*.pyzwz -*.delete_me - -# MAC OS -*.DS_Store - -# Editor files -.vscode/ -.idea/ - -# Build directories -infra.egg-info/ -beman_tidy.egg-info/ -*.egg-info/ -build/ -dist/ diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/.pre-commit-config.yaml b/cookiecutter/{{cookiecutter.project_name}}/infra/.pre-commit-config.yaml deleted file mode 100644 index 6fe1e85..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/.pre-commit-config.yaml +++ /dev/null @@ -1,22 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - - repo: https://github.com/codespell-project/codespell - rev: v2.4.2 - hooks: - - id: codespell - - # CMake linting and formatting - - repo: https://github.com/BlankSpruce/gersemi-pre-commit - rev: 0.27.2 - hooks: - - id: gersemi - name: CMake linting - exclude: ^.*/tests/.*/data/ # Exclude test data directories diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/LICENSE b/cookiecutter/{{cookiecutter.project_name}}/infra/LICENSE deleted file mode 100644 index f6db814..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/LICENSE +++ /dev/null @@ -1,219 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - ----- LLVM Exceptions to the Apache 2.0 License ---- - -As an exception, if, as a result of your compiling your source code, portions -of this Software are embedded into an Object form of such source code, you -may redistribute such embedded portions in such Object form without complying -with the conditions of Sections 4(a), 4(b) and 4(d) of the License. - -In addition, if you combine or link compiled forms of this Software with -software that is licensed under the GPLv2 ("Combined Software") and if a -court of competent jurisdiction determines that the patent provision (Section -3), the indemnity provision (Section 9) or other Section of the License -conflicts with the conditions of the GPLv2, you may retroactively and -prospectively choose to deem waived or otherwise exclude such Section(s) of -the License, but only in their entirety and only with respect to the Combined -Software. diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/README.md b/cookiecutter/{{cookiecutter.project_name}}/infra/README.md deleted file mode 100644 index 6cb8dd6..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# Beman Project Infrastructure Repository - - - -This repository contains the infrastructure for The Beman Project. This is NOT a library repository, -so it does not respect the usual structure of a Beman library repository nor The Beman Standard! - -## Description - -* `cmake/`: CMake modules and toolchain files used by Beman libraries. -* `containers/`: Containers used for CI builds and tests in the Beman org. - -## Usage - -This repository is intended to be used as a beman-submodule in other Beman repositories. See -[the beman-submodule documentation](https://github.com/bemanproject/beman-submodule) for details. - - -### CMake Modules - - -#### `beman_install_library` - -The CMake modules in this repository are intended to be used by Beman libraries. Use the -`beman_install_library()` function to install your library, along with header -files, any metadata files, and a CMake config file for `find_package()` support. - -```cmake -add_library(beman.something) -add_library(beman::something ALIAS beman.something) - -# ... configure your target as needed ... - -include(infra/cmake/beman-install-library.cmake) -beman_install_library(beman.something) -``` - -Note that the target must be created before calling `beman_install_library()`. The module -also assumes that the target is named using the `beman.something` convention, and it -uses that assumption to derive the names to match other Beman standards and conventions. -If your target does not follow that convention, raise an issue or pull request to add -more configurability to the module. - -The module will configure the target to install: - -* The library target itself -* Any public headers associated with the target -* CMake files for `find_package(beman.something)` support - -Some options for the project and target will also be supported: - -* `BEMAN_INSTALL_CONFIG_FILE_PACKAGES` - a list of package names (e.g., `beman.something`) for which to install the config file - (default: all packages) -* `_INSTALL_CONFIG_FILE_PACKAGE` - a per-project option to enable/disable config file installation (default: `ON` if the project is top-level, `OFF` otherwise). For instance for `beman.something`, the option would be `BEMAN_SOMETHING_INSTALL_CONFIG_FILE_PACKAGE`. - -# BuildTelemetry - -The cmake modules in this library provide access to CMake instrumentation data in Google Trace format which is visualizable with chrome://tracing and https://ui.perfetto.dev. - -Telemetry may be enabled in several ways: - -## `include` - -```cmake -include (infra/cmake/BuildTelemetry.cmake) -configure_build_telemetry() -``` - -## `find_package` - -```cmake -find_package(BuildTelemetry) -configure_build_telemetry() -``` - -as long as [BuildTelemetryConfig.cmake](./cmake/BuildTelemetryConfig.cmake) is in your module path. - -## `CMAKE_PROJECT_TOP_LEVEL_INCLUDES` -A non-invasive way to inject this telemetry into a CMake build you do not want to modify. -Add: -```sh --DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=infra/cmake/BuildTelemetry.cmake -``` -To the cmake invocation. - -In any form, CMake will call `telemetry.sh` which will copy the trace data in json format into a `.trace` subdirectory within the build directory. - -Multiple calls to `configure_build_telemetry` will only configure the callback hooks once, so it is safe to enable multiple times, including by TOP_LEVEL_INCLUDE. diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetry.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetry.cmake deleted file mode 100755 index cc94f40..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetry.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -include_guard(GLOBAL) - -include(${CMAKE_CURRENT_LIST_DIR}/BuildTelemetryConfig.cmake) -configure_build_telemetry() diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetryConfig.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetryConfig.cmake deleted file mode 100755 index 2160c34..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/BuildTelemetryConfig.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -include_guard(GLOBAL) - -set(BUILD_TELEMETRY_DIR ${CMAKE_CURRENT_LIST_DIR}) - -function(configure_build_telemetry) - if(NOT BUILD_TELEMETRY_CONFIGURATION) - # Check if the CMake version is at least 4.3 - if(CMAKE_VERSION VERSION_LESS "4.3") - message( - STATUS - "CMake version is less than 4.3, configuring cmake_instrumentation is unavailable." - ) - return() - else() - message(STATUS "Configuring Build Telemetry") - endif() - - # Find bash and jq for the telemetry callback script. - # On Windows, Git for Windows provides bash if available. - find_program(BEMAN_BASH bash) - find_program(BEMAN_JQ jq) - if(NOT BEMAN_BASH OR NOT BEMAN_JQ) - message( - STATUS - "bash or jq not found, build telemetry disabled on this platform." - ) - return() - endif() - - # Telemetry query - cmake_instrumentation( - API_VERSION 1 - DATA_VERSION 1 - OPTIONS staticSystemInformation dynamicSystemInformation trace - HOOKS - postGenerate - preBuild - postBuild - preCMakeBuild - postCMakeBuild - postCMakeInstall - postCTest - CALLBACK ${BEMAN_BASH} - ${BUILD_TELEMETRY_DIR}/telemetry.sh - ) - message( - DEBUG - "using callback script ${BUILD_TELEMETRY_DIR}/telemetry.sh via ${BEMAN_BASH}" - ) - - # Mark configuration as done in cache - set(BUILD_TELEMETRY_CONFIGURATION - TRUE - CACHE INTERNAL - "Flag to ensure Build Telemetry configured only once" - ) - endif() -endfunction(configure_build_telemetry) diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/Config.cmake.in b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/Config.cmake.in deleted file mode 100644 index df903cf..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/Config.cmake.in +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# cmake/Config.cmake.in -*-makefile-*- - -include(CMakeFindDependencyMacro) - -@BEMAN_INSTALL_FIND_DEPENDENCIES@ - -@PACKAGE_INIT@ - -include(${CMAKE_CURRENT_LIST_DIR}/@BEMAN_INSTALL_BASE_PKG_NAME@-targets.cmake) - -check_required_components(@BEMAN_INSTALL_BASE_PKG_NAME@) diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/appleclang-toolchain.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/appleclang-toolchain.cmake deleted file mode 100644 index 70ef548..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/appleclang-toolchain.cmake +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This toolchain file is not meant to be used directly, -# but to be invoked by CMake preset and GitHub CI. -# -# This toolchain file configures for apple clang family of compiler. -# Note this is different from LLVM toolchain. -# -# BEMAN_BUILDSYS_SANITIZER: -# This optional CMake parameter is not meant for public use and is subject to -# change. -# Possible values: -# - MaxSan: configures clang and clang++ to use all available non-conflicting -# sanitizers. Note that apple clang does not support leak sanitizer. -# - TSan: configures clang and clang++ to enable the use of thread sanitizer. - -include_guard(GLOBAL) - -# Prevent PATH collision with an LLVM clang installation by using the system -# compiler shims -set(CMAKE_C_COMPILER cc) -set(CMAKE_CXX_COMPILER c++) - -if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined" - ) -elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") -endif() - -set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") - -set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") - -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") - -set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") - -# Add this dir to the module path so that `find_package(beman-install-library)` works -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/beman-install-library.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/beman-install-library.cmake deleted file mode 100644 index df2dbe9..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/beman-install-library.cmake +++ /dev/null @@ -1,325 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -include_guard(GLOBAL) - -include(CMakePackageConfigHelpers) -include(GNUInstallDirs) - -# beman_install_library -# ===================== -# -# Installs a library (or set of targets) along with headers, C++ modules, -# and optional CMake package configuration files. -# -# Usage: -# ------ -# beman_install_library( -# TARGETS [ ...] -# [DEPENDENCIES [ ...]] -# [NAMESPACE ] -# [EXPORT_NAME ] -# [DESTINATION ] -# ) -# -# Arguments: -# ---------- -# -# name -# Logical package name (e.g. "beman.utility"). -# Used to derive config file names and cache variable prefixes. -# -# TARGETS (required) -# List of CMake targets to install. -# -# DEPENDENCIES (optional) -# Semicolon-separated list, one dependency per entry. -# Each entry is a valid find_dependency() argument list. -# Note: you must use the bracket form for quoting if not only a package name is used! -# "[===[beman.inplace_vector 1.0.0]===] [===[beman.scope 0.0.1 EXACT]===] fmt" -# -# NAMESPACE (optional) -# Namespace for exported targets. -# Defaults to "beman::". -# -# EXPORT_NAME (optional) -# Name of the CMake export set. -# Defaults to "-targets". -# -# DESTINATION (optional) -# The install destination for CXX_MODULES. -# Defaults to ${CMAKE_INSTALL_LIBDIR}/cmake/${name}/modules. -# -# Brief -# ----- -# -# This function installs the specified project TARGETS and its FILE_SET -# HEADERS to the default CMAKE install destination. -# -# It also handles the installation of the CMake config package files if -# needed. If the given targets has a PUBLIC FILE_SET CXX_MODULE, it will also -# installed to the given DESTINATION -# -# Cache variables: -# ---------------- -# -# BEMAN_INSTALL_CONFIG_FILE_PACKAGES -# List of package names for which config files should be installed. -# -# _INSTALL_CONFIG_FILE_PACKAGE -# Per-package override to enable/disable config file installation. -# is the uppercased package name with dots replaced by underscores. -# -# Caveats -# ------- -# -# **Only one `PUBLIC FILE_SET CXX_MODULES` is yet supported to install with this -# function!** -# -# **Only header files contained in a `PUBLIC FILE_SET TYPE HEADERS` will be -# install with this function!** - -function(beman_install_library name) - # ---------------------------- - # Argument parsing - # ---------------------------- - set(oneValueArgs NAMESPACE EXPORT_NAME DESTINATION) - set(multiValueArgs TARGETS DEPENDENCIES) - - cmake_parse_arguments( - BEMAN_INSTALL - "${options}" - "${oneValueArgs}" - "${multiValueArgs}" - ${ARGN} - ) - - if(NOT BEMAN_INSTALL_TARGETS) - message( - FATAL_ERROR - "beman_install_library(${name}): TARGETS must be specified" - ) - endif() - - if(CMAKE_SKIP_INSTALL_RULES) - message( - WARNING - "beman_install_library(${name}): not installing targets '${BEMAN_INSTALL_TARGETS}' due to CMAKE_SKIP_INSTALL_RULES" - ) - return() - endif() - - set(_config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${name}") - - # ---------------------------- - # Defaults - # ---------------------------- - if(NOT BEMAN_INSTALL_NAMESPACE) - set(BEMAN_INSTALL_NAMESPACE "beman::") - endif() - - if(NOT BEMAN_INSTALL_EXPORT_NAME) - set(BEMAN_INSTALL_EXPORT_NAME "${name}-targets") - endif() - - if(NOT BEMAN_INSTALL_DESTINATION) - set(BEMAN_INSTALL_DESTINATION - "${CMAKE_INSTALL_DATADIR}/${name}/modules" - ) - endif() - - string(REPLACE "beman." "" install_component_name "${name}") - message( - VERBOSE - "beman-install-library(${name}): COMPONENT '${install_component_name}'" - ) - - # -------------------------------------------------- - # Install each target with all of its file sets - # -------------------------------------------------- - foreach(_tgt IN LISTS BEMAN_INSTALL_TARGETS) - if(NOT TARGET "${_tgt}") - message( - WARNING - "beman_install_library(${name}): '${_tgt}' is not a target" - ) - continue() - endif() - - # Given foo.bar, the component name is bar - string(REPLACE "." ";" name_parts "${_tgt}") - # fail if the name doesn't look like foo.bar - list(LENGTH name_parts name_parts_length) - if(NOT name_parts_length EQUAL 2) - message( - FATAL_ERROR - "beman_install_library(${name}): expects a name of the form 'beman.', got '${_tgt}'" - ) - endif() - list(GET name_parts -1 component_name) - set_target_properties( - "${_tgt}" - PROPERTIES EXPORT_NAME "${component_name}" - ) - message( - VERBOSE - "beman_install_library(${name}): EXPORT_NAME ${component_name} for TARGET '${_tgt}'" - ) - - # Get the list of interface header sets, exact one expected! - set(_install_header_set_args) - get_target_property( - _available_header_sets - ${_tgt} - INTERFACE_HEADER_SETS - ) - if(_available_header_sets) - message( - VERBOSE - "beman-install-library(${name}): '${_tgt}' has INTERFACE_HEADER_SETS=${_available_header_sets}" - ) - foreach(_install_header_set IN LISTS _available_header_sets) - list( - APPEND _install_header_set_args - FILE_SET - "${_install_header_set}" - COMPONENT - "${install_component_name}_Development" - ) - endforeach() - else() - set(_install_header_set_args FILE_SET HEADERS) # Note: empty FILE_SET in this case! CK - endif() - - # Detect presence of PUBLIC C++ module file sets. Note: exact one is expected! - get_target_property(_module_sets "${_tgt}" INTERFACE_CXX_MODULE_SETS) - if(_module_sets) - message( - VERBOSE - "beman-install-library(${name}): '${_tgt}' has INTERFACE_CXX_MODULE_SETS=${_module_sets}" - ) - install( - TARGETS "${_tgt}" - EXPORT ${BEMAN_INSTALL_EXPORT_NAME} - ARCHIVE COMPONENT "${install_component_name}_Development" - LIBRARY - COMPONENT "${install_component_name}_Runtime" - NAMELINK_COMPONENT "${install_component_name}_Development" - RUNTIME COMPONENT "${install_component_name}_Runtime" - ${_install_header_set_args} - FILE_SET ${_module_sets} - DESTINATION "${BEMAN_INSTALL_DESTINATION}" - COMPONENT "${install_component_name}_Development" - # NOTE: There's currently no convention for this location! CK - CXX_MODULES_BMI - DESTINATION - ${CMAKE_INSTALL_DATADIR}/${name}/bmi-${CMAKE_CXX_COMPILER_ID}_$ - COMPONENT "${install_component_name}_Development" - ) - else() - install( - TARGETS "${_tgt}" - EXPORT ${BEMAN_INSTALL_EXPORT_NAME} - ARCHIVE COMPONENT "${install_component_name}_Development" - LIBRARY - COMPONENT "${install_component_name}_Runtime" - NAMELINK_COMPONENT "${install_component_name}_Development" - RUNTIME COMPONENT "${install_component_name}_Runtime" - ${_install_header_set_args} - ) - endif() - endforeach() - - # -------------------------------------------------- - # Export targets - # -------------------------------------------------- - # gersemi: off - install( - EXPORT ${BEMAN_INSTALL_EXPORT_NAME} - NAMESPACE ${BEMAN_INSTALL_NAMESPACE} - CXX_MODULES_DIRECTORY cxx-modules - DESTINATION ${_config_install_dir} - COMPONENT "${install_component_name}_Development" - ) - # gersemi: on - - # ---------------------------------------- - # Config file installation logic - # - # Precedence (highest to lowest): - # 1. Per-package variable _INSTALL_CONFIG_FILE_PACKAGE - # 2. Allow-list BEMAN_INSTALL_CONFIG_FILE_PACKAGES (if defined) - # 3. Default: ON - # ---------------------------------------- - string(TOUPPER "${name}" _pkg_upper) - string(REPLACE "." "_" _pkg_prefix "${_pkg_upper}") - - option( - ${_pkg_prefix}_INSTALL_CONFIG_FILE_PACKAGE - "Enable creating and installing a CMake config-file package. Default: ON. Values: { ON, OFF }." - ON - ) - - set(_pkg_var "${_pkg_prefix}_INSTALL_CONFIG_FILE_PACKAGE") - - # Default: install config files - set(_install_config ON) - - # If the allow-list is defined, only install for packages in the list - if(DEFINED BEMAN_INSTALL_CONFIG_FILE_PACKAGES) - if(NOT "${name}" IN_LIST BEMAN_INSTALL_CONFIG_FILE_PACKAGES) - set(_install_config OFF) - endif() - endif() - - # Per-package override takes highest precedence - if(DEFINED ${_pkg_var}) - set(_install_config ${${_pkg_var}}) - endif() - - # ---------------------------------------- - # expand dependencies - # ---------------------------------------- - set(_beman_find_deps "") - foreach(dep IN LISTS BEMAN_INSTALL_DEPENDENCIES) - message( - VERBOSE - "beman-install-library(${name}): Add find_dependency(${dep})" - ) - string(APPEND _beman_find_deps "find_dependency(${dep})\n") - endforeach() - set(BEMAN_INSTALL_FIND_DEPENDENCIES "${_beman_find_deps}") - - # ---------------------------------------- - # Generate + install config files - # ---------------------------------------- - if(_install_config) - set(BEMAN_INSTALL_BASE_PKG_NAME ${name}) - configure_package_config_file( - "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake" - INSTALL_DESTINATION ${_config_install_dir} - ) - - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/${name}-config-version.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion - ) - - install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/${name}-config-version.cmake" - DESTINATION ${_config_install_dir} - COMPONENT "${install_component_name}_Development" - ) - else() - message( - WARNING - "beman-install-library(${name}): Not installing a config package for '${name}'" - ) - endif() -endfunction() - -set(CPACK_GENERATOR TGZ) -include(CPack) diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/enable-experimental-import-std.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/enable-experimental-import-std.cmake deleted file mode 100644 index 20fc302..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/enable-experimental-import-std.cmake +++ /dev/null @@ -1,190 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -if(CMAKE_VERSION VERSION_EQUAL "3.30.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.3") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.4") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.5") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.6") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.7") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.8") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.30.9") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.10") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.11") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.12") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.3") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.4") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.5") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.6") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.7") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "0e5b6991-d74f-4b3d-a41c-cf096e0b2508" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.8") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "3.31.9") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "a9e1cf81-9932-4810-974b-6eccaf14e457" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "a9e1cf81-9932-4810-974b-6eccaf14e457" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "a9e1cf81-9932-4810-974b-6eccaf14e457" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.3") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.4") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.5") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.6") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.0.7") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.3") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.4") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.5") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.1.6") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.3") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.4") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.2.5") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "d0edc3af-4c50-42ea-a356-e2862fe7a444" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.3.0") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "451f2fe2-a8a2-47c3-bc32-94786d8fc91b" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.3.1") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "451f2fe2-a8a2-47c3-bc32-94786d8fc91b" - ) -elseif(CMAKE_VERSION VERSION_EQUAL "4.3.2") - set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD - "451f2fe2-a8a2-47c3-bc32-94786d8fc91b" - ) -endif() diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/gnu-toolchain.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/gnu-toolchain.cmake deleted file mode 100644 index d3b9f92..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/gnu-toolchain.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This toolchain file is not meant to be used directly, -# but to be invoked by CMake preset and GitHub CI. -# -# This toolchain file configures for GNU family of compiler. -# -# BEMAN_BUILDSYS_SANITIZER: -# This optional CMake parameter is not meant for public use and is subject to -# change. -# Possible values: -# - MaxSan: configures gcc and g++ to use all available non-conflicting -# sanitizers. -# - TSan: configures gcc and g++ to enable the use of thread sanitizer - -include_guard(GLOBAL) - -set(CMAKE_C_COMPILER gcc) -set(CMAKE_CXX_COMPILER g++) - -if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" - ) -elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") -endif() - -set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") - -set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") - -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") - -set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") - -# Add this dir to the module path so that `find_package(beman-install-library)` works -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-libc++-toolchain.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-libc++-toolchain.cmake deleted file mode 100644 index eabf363..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-libc++-toolchain.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This toolchain file is not meant to be used directly, -# but to be invoked by CMake preset and GitHub CI. -# -# This toolchain file configures for LLVM family of compiler. -# -# BEMAN_BUILDSYS_SANITIZER: -# This optional CMake parameter is not meant for public use and is subject to -# change. -# Possible values: -# - MaxSan: configures clang and clang++ to use all available non-conflicting -# sanitizers. -# - TSan: configures clang and clang++ to enable the use of thread sanitizer. - -include(${CMAKE_CURRENT_LIST_DIR}/llvm-toolchain.cmake) - -if(NOT CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+") - string(APPEND CMAKE_CXX_FLAGS " -stdlib=libc++") -endif() diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-toolchain.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-toolchain.cmake deleted file mode 100644 index f1623b7..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/llvm-toolchain.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This toolchain file is not meant to be used directly, -# but to be invoked by CMake preset and GitHub CI. -# -# This toolchain file configures for LLVM family of compiler. -# -# BEMAN_BUILDSYS_SANITIZER: -# This optional CMake parameter is not meant for public use and is subject to -# change. -# Possible values: -# - MaxSan: configures clang and clang++ to use all available non-conflicting -# sanitizers. -# - TSan: configures clang and clang++ to enable the use of thread sanitizer. - -include_guard(GLOBAL) - -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) - -if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - set(SANITIZER_FLAGS - "-fsanitize=address -fsanitize=leak -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fsanitize-undefined-trap-on-error" - ) -elseif(BEMAN_BUILDSYS_SANITIZER STREQUAL "TSan") - set(SANITIZER_FLAGS "-fsanitize=thread") -endif() - -set(CMAKE_C_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") -set(CMAKE_CXX_FLAGS_DEBUG_INIT "${SANITIZER_FLAGS}") - -set(RELEASE_FLAGS "-O3 ${SANITIZER_FLAGS}") - -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") - -set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") - -# Add this dir to the module path so that `find_package(beman-install-library)` works -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/msvc-toolchain.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/msvc-toolchain.cmake deleted file mode 100644 index bdc24de..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/msvc-toolchain.cmake +++ /dev/null @@ -1,41 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# This toolchain file is not meant to be used directly, -# but to be invoked by CMake preset and GitHub CI. -# -# This toolchain file configures for MSVC family of compiler. -# -# BEMAN_BUILDSYS_SANITIZER: -# This optional CMake parameter is not meant for public use and is subject to -# change. -# Possible values: -# - MaxSan: configures cl to use all available non-conflicting sanitizers. -# -# Note that in other toolchain files, TSan is also a possible value for -# BEMAN_BUILDSYS_SANITIZER, however, MSVC does not support thread sanitizer, -# thus this value is omitted. - -include_guard(GLOBAL) - -set(CMAKE_C_COMPILER cl) -set(CMAKE_CXX_COMPILER cl) - -if(BEMAN_BUILDSYS_SANITIZER STREQUAL "MaxSan") - # /Zi flag (add debug symbol) is needed when using address sanitizer - # See C5072: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-c5072 - set(SANITIZER_FLAGS "/fsanitize=address /Zi") -endif() - -set(CMAKE_CXX_FLAGS_DEBUG_INIT "/EHsc /permissive- ${SANITIZER_FLAGS}") -set(CMAKE_C_FLAGS_DEBUG_INIT "/EHsc /permissive- ${SANITIZER_FLAGS}") - -set(RELEASE_FLAGS "/EHsc /permissive- /O2 ${SANITIZER_FLAGS}") - -set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "${RELEASE_FLAGS}") - -set(CMAKE_C_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") -set(CMAKE_CXX_FLAGS_RELEASE_INIT "${RELEASE_FLAGS}") - -# Add this dir to the module path so that `find_package(beman-install-library)` works -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/telemetry.sh b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/telemetry.sh deleted file mode 100755 index cb5fd88..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/telemetry.sh +++ /dev/null @@ -1,119 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#!/usr/bin/env bash - -set -o nounset -set -o errexit -trap 'echo "Aborting due to errexit on line $LINENO. Exit code: $?" >&2' ERR -set -o errtrace -set -o pipefail -IFS=$'\n\t' - -############################################################################### -# Environment -############################################################################### - -# $_ME -# -# This program's basename. -_ME="$(basename "${0}")" - -############################################################################### -# Help -############################################################################### - -# _print_help() -# -# Usage: -# _print_help -# -# Print the program help information. -_print_help() { - cat <] - ${_ME} -h | --help - -Options: - -h --help Show this screen. - -Environment: - Setting DEBUG_TELEMETRY in the environment will enable DEBUG logging -HEREDOC -} - -############################################################################### -# Program Functions -############################################################################### -_debug_print() { - if [[ -n "${DEBUG_TELEMETRY:-}" ]]; then - printf "[DEBUG] $(date +'%H:%M:%S'): %s \n" "$1" >&2 - fi -} - -_check_file_exists() { - local file="$1" - if [[ ! -f "${file}" ]]; then - echo "Error: File not found: ${file}" >&2 - exit 1 # Exit the entire script with a non-zero status - fi -} - -_process_index() { - indexFile=${1:-} - _check_file_exists "${indexFile}" - _debug_print "$(cat "${indexFile}")" - - local buildDir - buildDir=$(jq -r '.buildDir' "${1:-}") - _debug_print "$(printf "buildDir is |%q|" "${buildDir}")" - - local dataDir - dataDir=$(jq -r '.dataDir' "${1:-}") - _debug_print "$(printf "dataDir is |%q|" "${dataDir}")" - - local hook - hook=$(jq -r '.hook' "${1:-}") - _debug_print "$(printf "hook is |%q|" "${hook}")" - - local trace - trace=$(jq -r '.trace' "${1:-}") - _debug_print "$(printf "trace is |%q|" "${trace}")" - - local outputDir - outputDir="${buildDir}/.trace" - _debug_print "$(printf "Copy trace to |%q|" "${outputDir}")" - mkdir -p "${outputDir}" - - local traceDestFile - traceDestFile="${outputDir}/${hook}-$(basename "${trace}")" - _debug_print "$(printf "traceDestFile: |%q|" "${traceDestFile}")" - cp "${dataDir}/${trace}" "${outputDir}/${hook}-$(basename "${trace}")" -} - -############################################################################### -# Main -############################################################################### - -# _main() -# -# Usage: -# _main [] [] -# -# Description: -# Entry point for the program, handling basic option parsing and dispatching. -_main() { - # Avoid complex option parsing when only one program option is expected. - if [[ "${1:-}" =~ ^-h|--help$ ]] - then - _print_help - else - _process_index "$@" - fi -} - -# Call `_main` after everything has been defined. -_main "$@" diff --git a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/use-fetch-content.cmake b/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/use-fetch-content.cmake deleted file mode 100644 index 3c7136d..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/infra/cmake/use-fetch-content.cmake +++ /dev/null @@ -1,205 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -cmake_minimum_required(VERSION 3.24) - -include(FetchContent) - -if(NOT BEMAN_LOCKFILE) - set(BEMAN_LOCKFILE - "lockfile.json" - CACHE FILEPATH - "Path to the dependency lockfile for the Beman project." - ) -endif() - -set(Beman_projectDir "${CMAKE_CURRENT_LIST_DIR}/../..") -message(TRACE "Beman_projectDir=\"${Beman_projectDir}\"") - -message(TRACE "BEMAN_LOCKFILE=\"${BEMAN_LOCKFILE}\"") -file( - REAL_PATH "${BEMAN_LOCKFILE}" - Beman_lockfile - BASE_DIRECTORY "${Beman_projectDir}" - EXPAND_TILDE -) -message(DEBUG "Using lockfile: \"${Beman_lockfile}\"") - -# Force CMake to reconfigure the project if the lockfile changes -set_property( - DIRECTORY "${Beman_projectDir}" - APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS "${Beman_lockfile}" -) - -# For more on the protocol for this function, see: -# https://cmake.org/cmake/help/latest/command/cmake_language.html#provider-commands -function(Beman_provideDependency method package_name) - # Read the lockfile - file(READ "${Beman_lockfile}" Beman_rootObj) - - # Get the "dependencies" field and store it in Beman_dependenciesObj - string( - JSON Beman_dependenciesObj - ERROR_VARIABLE Beman_error - GET "${Beman_rootObj}" - "dependencies" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_lockfile}: ${Beman_error}") - endif() - - # Get the length of the libraries array and store it in Beman_dependenciesObj - string( - JSON Beman_numDependencies - ERROR_VARIABLE Beman_error - LENGTH "${Beman_dependenciesObj}" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_lockfile}: ${Beman_error}") - endif() - - if(Beman_numDependencies EQUAL 0) - return() - endif() - - # Loop over each dependency object - math(EXPR Beman_maxIndex "${Beman_numDependencies} - 1") - foreach(Beman_index RANGE "${Beman_maxIndex}") - set(Beman_errorPrefix "${Beman_lockfile}, dependency ${Beman_index}") - - # Get the dependency object at Beman_index - # and store it in Beman_depObj - string( - JSON Beman_depObj - ERROR_VARIABLE Beman_error - GET "${Beman_dependenciesObj}" - "${Beman_index}" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_errorPrefix}: ${Beman_error}") - endif() - - # Get the "name" field and store it in Beman_name - string( - JSON Beman_name - ERROR_VARIABLE Beman_error - GET "${Beman_depObj}" - "name" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_errorPrefix}: ${Beman_error}") - endif() - - # Get the "package_name" field and store it in Beman_pkgName - string( - JSON Beman_pkgName - ERROR_VARIABLE Beman_error - GET "${Beman_depObj}" - "package_name" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_errorPrefix}: ${Beman_error}") - endif() - - # Get the "git_repository" field and store it in Beman_repo - string( - JSON Beman_repo - ERROR_VARIABLE Beman_error - GET "${Beman_depObj}" - "git_repository" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_errorPrefix}: ${Beman_error}") - endif() - - # Get the "git_tag" field and store it in Beman_tag - string( - JSON Beman_tag - ERROR_VARIABLE Beman_error - GET "${Beman_depObj}" - "git_tag" - ) - if(Beman_error) - message(FATAL_ERROR "${Beman_errorPrefix}: ${Beman_error}") - endif() - - if(method STREQUAL "FIND_PACKAGE") - if(package_name STREQUAL Beman_pkgName) - string( - APPEND Beman_debug - "Redirecting find_package calls for ${Beman_pkgName} " - "to FetchContent logic.\n" - ) - string( - APPEND Beman_debug - "Fetching ${Beman_repo} at " - "${Beman_tag} according to ${Beman_lockfile}." - ) - message(DEBUG "${Beman_debug}") - FetchContent_Declare( - "${Beman_name}" - GIT_REPOSITORY "${Beman_repo}" - GIT_TAG "${Beman_tag}" - EXCLUDE_FROM_ALL - ) - - # Apply per-dependency cmake_args from the lockfile - string( - JSON Beman_cmakeArgs - ERROR_VARIABLE Beman_cmakeArgsError - GET "${Beman_depObj}" - "cmake_args" - ) - if(NOT Beman_cmakeArgsError) - string(JSON Beman_numCmakeArgs LENGTH "${Beman_cmakeArgs}") - if(Beman_numCmakeArgs GREATER 0) - math(EXPR Beman_maxArgIndex "${Beman_numCmakeArgs} - 1") - foreach(Beman_argIndex RANGE "${Beman_maxArgIndex}") - string( - JSON Beman_argKey - MEMBER "${Beman_cmakeArgs}" - "${Beman_argIndex}" - ) - string( - JSON Beman_argValue - GET "${Beman_cmakeArgs}" - "${Beman_argKey}" - ) - message( - DEBUG - "Setting ${Beman_argKey}=${Beman_argValue} for ${Beman_name}" - ) - set("${Beman_argKey}" "${Beman_argValue}") - endforeach() - endif() - endif() - - FetchContent_MakeAvailable("${Beman_name}") - - # Catch2's CTest integration module isn't on CMAKE_MODULE_PATH - # when brought in via FetchContent. Add it so that - # `include(Catch)` works. - if(Beman_pkgName STREQUAL "Catch2") - list( - APPEND CMAKE_MODULE_PATH - "${${Beman_name}_SOURCE_DIR}/extras" - ) - set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE) - endif() - - # Important! _FOUND tells CMake that `find_package` is - # not needed for this package anymore - set("${Beman_pkgName}_FOUND" TRUE PARENT_SCOPE) - endif() - endif() - endforeach() -endfunction() - -set(BEMAN_USE_FETCH_CONTENT_ENABLED ON) - -cmake_language( - SET_DEPENDENCY_PROVIDER Beman_provideDependency - SUPPORTED_METHODS FIND_PACKAGE -) - -# Add this dir to the module path so that `find_package(beman-install-library)` works -list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_LIST_DIR}") diff --git a/cookiecutter/{{cookiecutter.project_name}}/lockfile.json b/cookiecutter/{{cookiecutter.project_name}}/lockfile.json deleted file mode 100644 index f3388cf..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/lockfile.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "dependencies": [ -{% if cookiecutter.unit_test_library == "gtest" %} - { - "name": "googletest", - "package_name": "GTest", - "git_repository": "https://github.com/google/googletest.git", - "git_tag": "6910c9d9165801d8827d628cb72eb7ea9dd538c5", - "cmake_args": { - "INSTALL_GTEST": "OFF" - } - } -{% elif cookiecutter.unit_test_library == "catch2" %} - { - "name": "Catch2", - "package_name": "Catch2", - "git_repository": "https://github.com/catchorg/Catch2.git", - "git_tag": "25319fd3047c6bdcf3c0170e76fa526c77f99ca9" - } -{% endif %} - ] -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/port/portfile.cmake.in b/cookiecutter/{{cookiecutter.project_name}}/port/portfile.cmake.in deleted file mode 100644 index 1f13b31..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/port/portfile.cmake.in +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO bemanproject/{{cookiecutter.project_name}} - REF "v@VERSION@" - SHA512 @SHA512@ - HEAD_REF main -) - -vcpkg_check_features( - OUT_FEATURE_OPTIONS FEATURE_OPTIONS - FEATURES - modules BEMAN_{{cookiecutter.project_name.upper()}}_USE_MODULES -) - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - ${FEATURE_OPTIONS} - -DBEMAN_{{cookiecutter.project_name.upper()}}_BUILD_TESTS=OFF - -DBEMAN_{{cookiecutter.project_name.upper()}}_BUILD_EXAMPLES=OFF -) - -vcpkg_cmake_install() - -vcpkg_cmake_config_fixup( - PACKAGE_NAME beman.{{cookiecutter.project_name}} - CONFIG_PATH lib/cmake/beman.{{cookiecutter.project_name}} -) - -if(NOT "modules" IN_LIST FEATURES) - file(REMOVE_RECURSE - "${CURRENT_PACKAGES_DIR}/debug" - "${CURRENT_PACKAGES_DIR}/lib" - ) -endif() - -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/cookiecutter/{{cookiecutter.project_name}}/port/vcpkg.json.in b/cookiecutter/{{cookiecutter.project_name}}/port/vcpkg.json.in deleted file mode 100644 index 81a58a5..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/port/vcpkg.json.in +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "beman-{{cookiecutter.project_name.replace('_', '-')}}", - "version-semver": "@VERSION@", - "description": "{{cookiecutter.description}}", - "homepage": "https://github.com/bemanproject/{{cookiecutter.project_name}}", - "license": "Apache-2.0 WITH LLVM-exception", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "features": { - "modules": { - "description": "Provide beman.{{cookiecutter.project_name}} as a C++ module" - } - } -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/CMakeLists.txt b/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/CMakeLists.txt deleted file mode 100644 index 4450cd8..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -{% if cookiecutter.unit_test_library == "gtest" %} -find_package(GTest REQUIRED) -{% elif cookiecutter.unit_test_library == "catch2" %} -find_package(Catch2 3 REQUIRED) -{% endif %} - -add_executable(beman.{{cookiecutter.project_name}}.tests.{{identity}}) -target_sources(beman.{{cookiecutter.project_name}}.tests.{{identity}} PRIVATE {{identity}}.test.cpp) -target_link_libraries( - beman.{{cookiecutter.project_name}}.tests.{{identity}} -{% if cookiecutter.unit_test_library == "gtest" %} - PRIVATE beman::{{cookiecutter.project_name}} GTest::gtest_main -{% elif cookiecutter.unit_test_library == "catch2" %} - PRIVATE beman::{{cookiecutter.project_name}} Catch2::Catch2WithMain -{% endif %} -) -if(BEMAN_EXEMPLAR_USE_MODULES) - set_target_properties( - beman.{{cookiecutter.project_name}}.tests.{{identity}} - PROPERTIES CXX_MODULE_STD ON - ) -endif() - -{% if cookiecutter.unit_test_library == "gtest" %} -include(GoogleTest) -gtest_discover_tests(beman.{{cookiecutter.project_name}}.tests.{{identity}} DISCOVERY_TIMEOUT 60) -{% elif cookiecutter.unit_test_library == "catch2" %} -include(Catch) -catch_discover_tests(beman.{{cookiecutter.project_name}}.tests.{{identity}}) -{% endif %} diff --git a/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/identity.test.cpp b/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/identity.test.cpp deleted file mode 100644 index 2b4c069..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/tests/beman/{{cookiecutter.project_name}}/identity.test.cpp +++ /dev/null @@ -1,117 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -{% set identity = "identity" if cookiecutter._generating_exemplar else "todo" %} - -#include -{% if cookiecutter.unit_test_library == "gtest" %} -#include -{% elif cookiecutter.unit_test_library == "catch2" %} -#include -{% endif %} -#include - -{% if cookiecutter._generating_exemplar %} -#if BEMAN_EXEMPLAR_USE_MODULES() -import std; -#else - #include - #include -#endif - -namespace exe = beman::{{cookiecutter.project_name}}; - -{% if cookiecutter.unit_test_library == "gtest" %} -TEST(IdentityTest, call_identity_with_int) { -{% elif cookiecutter.unit_test_library == "catch2" %} -TEST_CASE("can call identity with int", "[{{cookiecutter.project_name}}::call_identity_with_int]") { -{% endif %} - for (int i = -100; i < 100; ++i) { -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_EQ(i, exe::identity()(i)); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(i == exe::identity()(i)); -{% endif %} - } -} - -{% if cookiecutter.unit_test_library == "gtest" %} -TEST(IdentityTest, call_identity_with_custom_type) { -{% elif cookiecutter.unit_test_library == "catch2" %} -TEST_CASE("can call identity with custom type", "[{{cookiecutter.project_name}}::call_identity_with_custom_type]") { -{% endif %} - struct S { - int i; - }; - - for (int i = -100; i < 100; ++i) { - const S s{i}; - const S s_id = exe::identity()(s); -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_EQ(s.i, s_id.i); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(s.i == s_id.i); -{% endif %} - } -} - -{% if cookiecutter.unit_test_library == "gtest" %} -TEST(IdentityTest, compare_std_vs_beman) { -{% elif cookiecutter.unit_test_library == "catch2" %} -TEST_CASE("compare std vs beman", "[{{cookiecutter.project_name}}::compare_std_vs_beman]") { -{% endif %} -// Requires: std::identity support. -#if defined(__cpp_lib_type_identity) - std::identity std_id; - exe::identity beman_id; - for (int i = -100; i < 100; ++i) { -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_EQ(std_id(i), beman_id(i)); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(std_id(i) == beman_id(i)); -{% endif %} - } -#endif -} - -{% if cookiecutter.unit_test_library == "gtest" %} -TEST(IdentityTest, check_is_transparent) { -{% elif cookiecutter.unit_test_library == "catch2" %} -TEST_CASE("check is transparent", "[{{cookiecutter.project_name}}::check_is_transparent]") { -{% endif %} -// Requires: transparent operators support. -#if defined(__cpp_lib_transparent_operators) - - exe::identity id; - - const auto container = {1, 2, 3, 4, 5}; - auto it = std::find(std::begin(container), std::end(container), 3); -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_EQ(3, *it); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(3 == *it); -{% endif %} - auto it_with_id = std::find(std::begin(container), std::end(container), id(3)); -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_EQ(3, *it_with_id); - - EXPECT_EQ(it, it_with_id); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(3 == *it_with_id); - - CHECK(it == it_with_id); -{% endif %} -#endif -} -{% else %} -{% if cookiecutter.unit_test_library == "gtest" %} -TEST(TodoTest, todo) { -{% elif cookiecutter.unit_test_library == "catch2" %} -TEST_CASE("todo", "[{{cookiecutter.project_name}}::todo]") { -{% endif %} - const bool todo = true; -{% if cookiecutter.unit_test_library == "gtest" %} - EXPECT_TRUE(todo); -{% elif cookiecutter.unit_test_library == "catch2" %} - CHECK(todo); -{% endif %} -} -{% endif %} diff --git a/cookiecutter/{{cookiecutter.project_name}}/vcpkg-configuration.json b/cookiecutter/{{cookiecutter.project_name}}/vcpkg-configuration.json deleted file mode 100644 index db23b90..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/vcpkg-configuration.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "default-registry": { - "kind": "git", - "repository": "https://github.com/microsoft/vcpkg.git", - "baseline": "522253caf47268c1724f486a035e927a42a90092" - }, - "registries": [ - { - "kind": "git", - "repository": "https://github.com/bemanproject/vcpkg-registry.git", - "baseline": "28992b34d1e39368f5d1214a557fd61949de39fb", - "packages": ["beman-*"] - } - ] -} diff --git a/cookiecutter/{{cookiecutter.project_name}}/vcpkg.json b/cookiecutter/{{cookiecutter.project_name}}/vcpkg.json deleted file mode 100644 index 89ea514..0000000 --- a/cookiecutter/{{cookiecutter.project_name}}/vcpkg.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "beman-{{cookiecutter.project_name.replace('_', '-')}}", -{% if cookiecutter._generating_exemplar %} - "version-semver": "2.4.0", -{% else %} - "version-semver": "0.1.0", -{% endif %} -{% if cookiecutter.unit_test_library == "gtest" %} - "dependencies": [ - { - "name": "gtest", - "host": true - } - ] -{% elif cookiecutter.unit_test_library == "catch2" %} - "dependencies": [ - { - "name": "catch2", - "host": true - } - ] -{% endif %} -} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ed8ed52..3544044 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,32 +1,18 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(ALL_EXAMPLES identity_direct_usage) - -# Example `identity_as_default_projection` need ranges support: -include(CheckCXXSymbolExists) -check_cxx_symbol_exists(__cpp_lib_ranges "ranges" HAS_RANGES) - -if(HAS_RANGES) - list(APPEND ALL_EXAMPLES identity_as_default_projection) -else() - message( - WARNING - "Missing range support! Skip: identity_as_default_projection" - ) -endif() - +set(ALL_EXAMPLES todo) message("Examples to be built: ${ALL_EXAMPLES}") foreach(example ${ALL_EXAMPLES}) - add_executable(beman.exemplar.examples.${example}) - target_sources(beman.exemplar.examples.${example} PRIVATE ${example}.cpp) + add_executable(beman.str_split.examples.${example}) + target_sources(beman.str_split.examples.${example} PRIVATE ${example}.cpp) target_link_libraries( - beman.exemplar.examples.${example} - PRIVATE beman::exemplar + beman.str_split.examples.${example} + PRIVATE beman::str_split ) - if(BEMAN_EXEMPLAR_USE_MODULES) + if(BEMAN_STR_SPLIT_USE_MODULES) set_target_properties( - beman.exemplar.examples.${example} + beman.str_split.examples.${example} PROPERTIES CXX_MODULE_STD ON ) endif() diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp deleted file mode 100644 index 0fe7210..0000000 --- a/examples/identity_as_default_projection.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -// This example demonstrates the usage of beman::exemplar::identity as a default projection in a range-printer. -// Requires: range support (C++20) and std::identity support (C++20). - -#include -#include - -#if BEMAN_EXEMPLAR_USE_MODULES() -import std; -#else - #include - #include // std::identity - #include - #include - #include - #include -#endif - -namespace exe = beman::exemplar; - -// Class with a pair of values. -struct Pair { - int n; - std::string s; - - // Output the pair in the form {n, s}. - // Used by the range-printer if no custom projection is provided (default: identity projection). - friend std::ostream& operator<<(std::ostream& os, const Pair& p) { - return os << "Pair" << '{' << p.n << ", " << p.s << '}'; - } -}; - -// A range-printer that can print projected (modified) elements of a range. -// All the elements of the range are printed in the form {element1, element2, ...}. -// e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three} -// e.g., pairs with custom projection: {1:one, 2:two, 3:three} -template -void print_helper(const std::string_view rem, R&& range, Projection projection) { - std::cout << rem << '{'; - std::ranges::for_each(range, [O = 0](const auto& o) mutable { std::cout << (O++ ? ", " : "") << o; }, projection); - std::cout << "}\n"; -}; - -// Print wrapper with exe::identity. -template // <- Notice the default projection. -void print_beman(const std::string_view rem, R&& range, Projection projection = {}) { - print_helper(rem, range, projection); -} - -// Print wrapper with std::identity. -template // <- Notice the default projection. -void print_std(const std::string_view rem, R&& range, Projection projection = {}) { - print_helper(rem, range, projection); -} - -int main() { - // A vector of pairs to print. - const std::vector pairs = { - {1, "one"}, - {2, "two"}, - {3, "three"}, - }; - - // Print the pairs using the default projection. - std::cout << "Default projection:\n"; - print_beman("\tpairs with beman: ", pairs); - print_std("\tpairs with std: ", pairs); - - // Print the pairs using a custom projection. - std::cout << "Custom projection:\n"; - print_beman("\tpairs with beman: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); - print_std("\tpairs with std: ", pairs, [](const auto& p) { return std::to_string(p.n) + ':' + p.s; }); - - return 0; -} diff --git a/examples/identity_direct_usage.cpp b/examples/identity_direct_usage.cpp deleted file mode 100644 index c45f057..0000000 --- a/examples/identity_direct_usage.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include - -#if BEMAN_EXEMPLAR_USE_MODULES() -import std; -#else - #include -#endif - -namespace exe = beman::exemplar; - -int main() { - std::cout << exe::identity()(2024) << '\n'; - return 0; -} diff --git a/examples/todo.cpp b/examples/todo.cpp new file mode 100644 index 0000000..276064d --- /dev/null +++ b/examples/todo.cpp @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include + +int main() { + // TODO +} diff --git a/images/use-this-template.png b/images/use-this-template.png deleted file mode 100644 index a09ad69..0000000 Binary files a/images/use-this-template.png and /dev/null differ diff --git a/include/beman/exemplar/CMakeLists.txt b/include/beman/exemplar/CMakeLists.txt deleted file mode 100644 index f3f12ee..0000000 --- a/include/beman/exemplar/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -if(BEMAN_EXEMPLAR_USE_MODULES) - target_sources( - beman.exemplar - PUBLIC - FILE_SET CXX_MODULES FILES exemplar.cppm - FILE_SET HEADERS - FILES - config.hpp - exemplar.hpp - identity.hpp - "${PROJECT_BINARY_DIR}/include/beman/exemplar/config_generated.hpp" - ) -else() - target_sources( - beman.exemplar - PUBLIC - FILE_SET HEADERS - FILES - config.hpp - exemplar.hpp - identity.hpp - "${PROJECT_BINARY_DIR}/include/beman/exemplar/config_generated.hpp" - ) -endif() diff --git a/include/beman/exemplar/config.hpp b/include/beman/exemplar/config.hpp deleted file mode 100644 index 660698a..0000000 --- a/include/beman/exemplar/config.hpp +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_EXEMPLAR_CONFIG_HPP -#define BEMAN_EXEMPLAR_CONFIG_HPP - -#if !defined(__has_include) || __has_include() - #include -#else - #define BEMAN_EXEMPLAR_USE_MODULES() 0 -#endif - -#endif diff --git a/include/beman/exemplar/config_generated.hpp.in b/include/beman/exemplar/config_generated.hpp.in deleted file mode 100644 index a36a5f0..0000000 --- a/include/beman/exemplar/config_generated.hpp.in +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_EXEMPLAR_CONFIG_GENERATED_HPP -#define BEMAN_EXEMPLAR_CONFIG_GENERATED_HPP - -#cmakedefine01 BEMAN_EXEMPLAR_USE_MODULES() - -#endif diff --git a/include/beman/exemplar/exemplar.hpp b/include/beman/exemplar/exemplar.hpp deleted file mode 100644 index 447218e..0000000 --- a/include/beman/exemplar/exemplar.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_EXEMPLAR_EXEMPLAR_HPP -#define BEMAN_EXEMPLAR_EXEMPLAR_HPP - -#include - -#if BEMAN_EXEMPLAR_USE_MODULES() && !defined(BEMAN_EXEMPLAR_INCLUDED_FROM_INTERFACE_UNIT) - -import beman.exemplar; - -#else - - #include - -#endif // BEMAN_EXEMPLAR_USE_MODULES() && - // !defined(BEMAN_EXEMPLAR_INCLUDED_FROM_INTERFACE_UNIT) - -#endif // BEMAN_EXEMPLAR_EXEMPLAR_HPP diff --git a/include/beman/exemplar/identity.hpp b/include/beman/exemplar/identity.hpp deleted file mode 100644 index c8e03fb..0000000 --- a/include/beman/exemplar/identity.hpp +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#ifndef BEMAN_EXEMPLAR_IDENTITY_HPP -#define BEMAN_EXEMPLAR_IDENTITY_HPP - -#include - -#if BEMAN_EXEMPLAR_USE_MODULES() && !defined(BEMAN_EXEMPLAR_INCLUDED_FROM_INTERFACE_UNIT) - -import beman.exemplar; - -#else - - // C++ Standard Library: std::identity equivalent. - // See https://eel.is/c++draft/func.identity: - // - // 22.10.12 Class identity [func.identity] - // - // struct identity { - // template - // constexpr T&& operator()(T&& t) const noexcept; - // - // using is_transparent = unspecified; - // }; - // - // template - // constexpr T&& operator()(T&& t) const noexcept; - // - // Effects: Equivalent to: return std::forward(t); - - #if !BEMAN_EXEMPLAR_USE_MODULES() - #include // std::forward - #endif - -namespace beman::exemplar { - -struct __is_transparent; // not defined - -// A function object that returns its argument unchanged. -struct identity { - // Returns `t`. - template - constexpr T&& operator()(T&& t) const noexcept { - return std::forward(t); - } - - using is_transparent = __is_transparent; -}; - -} // namespace beman::exemplar - -#endif // BEMAN_EXEMPLAR_USE_MODULES() && - // !defined(BEMAN_EXEMPLAR_INCLUDED_FROM_INTERFACE_UNIT) - -#endif // BEMAN_EXEMPLAR_IDENTITY_HPP diff --git a/include/beman/str_split/CMakeLists.txt b/include/beman/str_split/CMakeLists.txt new file mode 100644 index 0000000..a4a50c2 --- /dev/null +++ b/include/beman/str_split/CMakeLists.txt @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +if(BEMAN_STR_SPLIT_USE_MODULES) + target_sources( + beman.str_split + PUBLIC + FILE_SET CXX_MODULES FILES str_split.cppm + FILE_SET HEADERS + FILES + config.hpp + str_split.hpp + todo.hpp + "${PROJECT_BINARY_DIR}/include/beman/str_split/config_generated.hpp" + ) +else() + target_sources( + beman.str_split + PUBLIC + FILE_SET HEADERS + FILES + config.hpp + str_split.hpp + todo.hpp + "${PROJECT_BINARY_DIR}/include/beman/str_split/config_generated.hpp" + ) +endif() diff --git a/include/beman/str_split/config.hpp b/include/beman/str_split/config.hpp new file mode 100644 index 0000000..7fdf13f --- /dev/null +++ b/include/beman/str_split/config.hpp @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef BEMAN_STR_SPLIT_CONFIG_HPP +#define BEMAN_STR_SPLIT_CONFIG_HPP + +#if !defined(__has_include) || __has_include() + #include +#else + #define BEMAN_STR_SPLIT_USE_MODULES() 0 +#endif + +#endif diff --git a/include/beman/str_split/config_generated.hpp.in b/include/beman/str_split/config_generated.hpp.in new file mode 100644 index 0000000..dada6ff --- /dev/null +++ b/include/beman/str_split/config_generated.hpp.in @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef BEMAN_STR_SPLIT_CONFIG_GENERATED_HPP +#define BEMAN_STR_SPLIT_CONFIG_GENERATED_HPP + +#cmakedefine01 BEMAN_STR_SPLIT_USE_MODULES() + +#endif diff --git a/include/beman/exemplar/exemplar.cppm b/include/beman/str_split/str_split.cppm similarity index 55% rename from include/beman/exemplar/exemplar.cppm rename to include/beman/str_split/str_split.cppm index 0a59630..1a646cb 100644 --- a/include/beman/exemplar/exemplar.cppm +++ b/include/beman/str_split/str_split.cppm @@ -1,11 +1,11 @@ -export module beman.exemplar; +export module beman.str_split; import std; -#define BEMAN_EXEMPLAR_INCLUDED_FROM_INTERFACE_UNIT +#define BEMAN_STR_SPLIT_INCLUDED_FROM_INTERFACE_UNIT export { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winclude-angled-in-module-purview" -#include +#include #pragma clang diagnostic pop } diff --git a/include/beman/str_split/str_split.hpp b/include/beman/str_split/str_split.hpp new file mode 100644 index 0000000..308ad99 --- /dev/null +++ b/include/beman/str_split/str_split.hpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef BEMAN_STR_SPLIT_STR_SPLIT_HPP +#define BEMAN_STR_SPLIT_STR_SPLIT_HPP + +#include + +#if BEMAN_STR_SPLIT_USE_MODULES() && !defined(BEMAN_STR_SPLIT_INCLUDED_FROM_INTERFACE_UNIT) + +import beman.str_split; + +#else + + #include + +#endif // BEMAN_STR_SPLIT_USE_MODULES() && + // !defined(BEMAN_STR_SPLIT_INCLUDED_FROM_INTERFACE_UNIT) + +#endif // BEMAN_STR_SPLIT_STR_SPLIT_HPP diff --git a/include/beman/str_split/todo.hpp b/include/beman/str_split/todo.hpp new file mode 100644 index 0000000..a4b9c5a --- /dev/null +++ b/include/beman/str_split/todo.hpp @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef BEMAN_STR_SPLIT_TODO_HPP +#define BEMAN_STR_SPLIT_TODO_HPP + +#include + +#if BEMAN_STR_SPLIT_USE_MODULES() && !defined(BEMAN_STR_SPLIT_INCLUDED_FROM_INTERFACE_UNIT) + +import beman.str_split; + +#else + +namespace beman::str_split { + +// TODO + +} // namespace beman::str_split + +#endif // BEMAN_STR_SPLIT_USE_MODULES() && + // !defined(BEMAN_STR_SPLIT_INCLUDED_FROM_INTERFACE_UNIT) + +#endif // BEMAN_STR_SPLIT_TODO_HPP diff --git a/port/portfile.cmake.in b/port/portfile.cmake.in index ba7eeac..c1097e7 100644 --- a/port/portfile.cmake.in +++ b/port/portfile.cmake.in @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH - REPO bemanproject/exemplar + REPO bemanproject/str_split REF "v@VERSION@" SHA512 @SHA512@ HEAD_REF main @@ -10,22 +10,22 @@ vcpkg_from_github( vcpkg_check_features( OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES - modules BEMAN_EXEMPLAR_USE_MODULES + modules BEMAN_STR_SPLIT_USE_MODULES ) vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" OPTIONS ${FEATURE_OPTIONS} - -DBEMAN_EXEMPLAR_BUILD_TESTS=OFF - -DBEMAN_EXEMPLAR_BUILD_EXAMPLES=OFF + -DBEMAN_STR_SPLIT_BUILD_TESTS=OFF + -DBEMAN_STR_SPLIT_BUILD_EXAMPLES=OFF ) vcpkg_cmake_install() vcpkg_cmake_config_fixup( - PACKAGE_NAME beman.exemplar - CONFIG_PATH lib/cmake/beman.exemplar + PACKAGE_NAME beman.str_split + CONFIG_PATH lib/cmake/beman.str_split ) if(NOT "modules" IN_LIST FEATURES) diff --git a/port/vcpkg.json.in b/port/vcpkg.json.in index 9a7ddab..24cea9e 100644 --- a/port/vcpkg.json.in +++ b/port/vcpkg.json.in @@ -1,8 +1,8 @@ { - "name": "beman-exemplar", + "name": "beman-str-split", "version-semver": "@VERSION@", - "description": "A Beman Library Exemplar", - "homepage": "https://github.com/bemanproject/exemplar", + "description": "Stand-alone, easy-to-use string split utilities", + "homepage": "https://github.com/bemanproject/str_split", "license": "Apache-2.0 WITH LLVM-exception", "dependencies": [ { @@ -16,7 +16,7 @@ ], "features": { "modules": { - "description": "Provide beman.exemplar as a C++ module" + "description": "Provide beman.str_split as a C++ module" } } } diff --git a/stamp.sh b/stamp.sh deleted file mode 100755 index 7dc9ee8..0000000 --- a/stamp.sh +++ /dev/null @@ -1,44 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#!/usr/bin/env bash - -{ - if [[ "$1" == "-h" || "$1" == "--help" ]] ; then - cat <<-'EOF' - stamp.sh -- beman exemplar template library creation tool - - This script is intended to be run on a fork of exemplar. - - It sets up cookiecutter, runs it on the cookiecutter template, replaces the - repository's current contents with the result, runs pre-commit, - switches to a new branch 'stamp', and creates a git commit. - - All parameters are passed through to the cookiecutter invocation. -EOF - fi - set -eu - if ! type -P python3 >/dev/null ; then - echo "Couldn't find python3 in PATH" >&2 - exit 1 - fi - declare repo_dir=$(realpath $(dirname "$BASH_SOURCE")) - cd "$repo_dir" - declare cookiecutter_venv_path - cookiecutter_venv_path=$(mktemp --directory --dry-run) - python3 -m venv "$cookiecutter_venv_path" - source "$cookiecutter_venv_path/bin/activate" - python3 -m pip install cookiecutter pre-commit >& /dev/null - declare cookiecutter_out_path - cookiecutter_out_path=$(mktemp --directory) - python3 -m cookiecutter "$repo_dir/cookiecutter" -o "$cookiecutter_out_path" "$@" - git rm -rf . &>/dev/null - cp -r "$cookiecutter_out_path"/*/. . - git add . &>/dev/null - pre-commit run --all-files &>/dev/null || true - git add . &>/dev/null - git checkout -b stamp - git commit -q -m "Stamp out exemplar template" - echo "Successfully stamped out exemplar template to the new branch 'stamp'." - echo "Try 'git push origin stamp' to push the branch upstream," - echo "then create a pull request." - rm -r "$cookiecutter_venv_path" "$cookiecutter_out_path" -}; exit diff --git a/tests/beman/exemplar/CMakeLists.txt b/tests/beman/exemplar/CMakeLists.txt deleted file mode 100644 index 597b375..0000000 --- a/tests/beman/exemplar/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -find_package(GTest REQUIRED) - -add_executable(beman.exemplar.tests.identity) -target_sources(beman.exemplar.tests.identity PRIVATE identity.test.cpp) -target_link_libraries( - beman.exemplar.tests.identity - PRIVATE beman::exemplar GTest::gtest_main -) -if(BEMAN_EXEMPLAR_USE_MODULES) - set_target_properties( - beman.exemplar.tests.identity - PROPERTIES CXX_MODULE_STD ON - ) -endif() - -include(GoogleTest) -gtest_discover_tests(beman.exemplar.tests.identity DISCOVERY_TIMEOUT 60) diff --git a/tests/beman/exemplar/identity.test.cpp b/tests/beman/exemplar/identity.test.cpp deleted file mode 100644 index 694fa88..0000000 --- a/tests/beman/exemplar/identity.test.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -#include -#include -#include - -#if BEMAN_EXEMPLAR_USE_MODULES() -import std; -#else - #include - #include -#endif - -namespace exe = beman::exemplar; - -TEST(IdentityTest, call_identity_with_int) { - for (int i = -100; i < 100; ++i) { - EXPECT_EQ(i, exe::identity()(i)); - } -} - -TEST(IdentityTest, call_identity_with_custom_type) { - struct S { - int i; - }; - - for (int i = -100; i < 100; ++i) { - const S s{i}; - const S s_id = exe::identity()(s); - EXPECT_EQ(s.i, s_id.i); - } -} - -TEST(IdentityTest, compare_std_vs_beman) { -// Requires: std::identity support. -#if defined(__cpp_lib_type_identity) - std::identity std_id; - exe::identity beman_id; - for (int i = -100; i < 100; ++i) { - EXPECT_EQ(std_id(i), beman_id(i)); - } -#endif -} - -TEST(IdentityTest, check_is_transparent) { -// Requires: transparent operators support. -#if defined(__cpp_lib_transparent_operators) - - exe::identity id; - - const auto container = {1, 2, 3, 4, 5}; - auto it = std::find(std::begin(container), std::end(container), 3); - EXPECT_EQ(3, *it); - auto it_with_id = std::find(std::begin(container), std::end(container), id(3)); - EXPECT_EQ(3, *it_with_id); - - EXPECT_EQ(it, it_with_id); -#endif -} diff --git a/tests/beman/str_split/CMakeLists.txt b/tests/beman/str_split/CMakeLists.txt new file mode 100644 index 0000000..be75247 --- /dev/null +++ b/tests/beman/str_split/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +find_package(GTest REQUIRED) + +add_executable(beman.str_split.tests.todo) +target_sources(beman.str_split.tests.todo PRIVATE todo.test.cpp) +target_link_libraries( + beman.str_split.tests.todo + PRIVATE beman::str_split GTest::gtest_main +) +if(BEMAN_EXEMPLAR_USE_MODULES) + set_target_properties( + beman.str_split.tests.todo + PROPERTIES CXX_MODULE_STD ON + ) +endif() + +include(GoogleTest) +gtest_discover_tests(beman.str_split.tests.todo DISCOVERY_TIMEOUT 60) diff --git a/tests/beman/str_split/todo.test.cpp b/tests/beman/str_split/todo.test.cpp new file mode 100644 index 0000000..f1c0082 --- /dev/null +++ b/tests/beman/str_split/todo.test.cpp @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include +#include +#include + +TEST(TodoTest, todo) { + const bool todo = true; + EXPECT_TRUE(todo); +} diff --git a/vcpkg.json b/vcpkg.json index ba9121e..9eebba5 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { - "name": "beman-exemplar", - "version-semver": "2.4.0", + "name": "beman-str-split", + "version-semver": "0.1.0", "dependencies": [ { "name": "gtest",