From 725d1d38f4ac6fe7b132f285035a8d4dff4020ac Mon Sep 17 00:00:00 2001 From: Edward Nolan Date: Fri, 1 May 2026 00:20:44 -0400 Subject: [PATCH] Exemplar updates since 2026-04-26 Update infra submodule and move INSTALL_GTEST into lockfile.json as per-dependency cmake_args. Raise gtest_discover_tests DISCOVERY_TIMEOUT to 60s to avoid intermittent MSVC Debug discovery failures. Add vcpkg port templates, manifest, configuration, and CI/release workflows; bump infra-workflows from 1.5.3 to 1.6.0 and update infra submodule. Bump vcpkg registry baselines (microsoft/vcpkg and bemanproject/vcpkg-registry) in vcpkg-configuration.json. Remove superfluous comments around the project() statement in CMakeLists.txt. Add .swp and .orig to .gitignore to exclude vim swap files and merge/patch backup files. Bump infra/ beman-submodule to latest: rename BemanExemplar_/BEMAN_EXEMPLAR_LOCKFILE to Beman_/BEMAN_LOCKFILE, fix llvm-libc++ toolchain SPDX, fix telemetry.sh typo, and update infra/README.md beman_install_library docs. --- .exemplar_version | 2 +- .github/workflows/ci_tests.yml | 15 +- .github/workflows/pre-commit-check.yml | 2 +- .github/workflows/pre-commit-update.yml | 2 +- .github/workflows/vcpkg-release.yml | 13 ++ .gitignore | 6 + .pre-commit-config.yaml | 2 +- CMakeLists.txt | 3 +- CONTRIBUTING.md | 24 +++ README.md | 11 ++ infra/.beman_submodule | 2 +- infra/README.md | 4 +- infra/cmake/llvm-libc++-toolchain.cmake | 2 +- infra/cmake/telemetry.sh | 2 +- infra/cmake/use-fetch-content.cmake | 206 +++++++++++++----------- lockfile.json | 5 +- port/portfile.cmake.in | 28 ++++ port/vcpkg.json.in | 17 ++ tests/beman/cstring_view/CMakeLists.txt | 2 +- vcpkg-configuration.json | 15 ++ vcpkg.json | 10 ++ 21 files changed, 260 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/vcpkg-release.yml create mode 100644 port/portfile.cmake.in create mode 100644 port/vcpkg.json.in create mode 100644 vcpkg-configuration.json create mode 100644 vcpkg.json diff --git a/.exemplar_version b/.exemplar_version index 5223332..8f59e27 100644 --- a/.exemplar_version +++ b/.exemplar_version @@ -1 +1 @@ -b1e7015b1bd62ce5b20009cec7ee98ba5c783818 +0131279454a8b54a6038203a7b714e2e0a835039 diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 659b2bf..63b4429 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -13,10 +13,10 @@ on: jobs: beman-submodule-check: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.6.0 preset-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.6.0 with: matrix_config: > [ @@ -31,7 +31,7 @@ jobs: ] build-and-test: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.6.0 with: matrix_config: > { @@ -145,7 +145,7 @@ jobs: } build-and-test-cpp17: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.6.0 with: matrix_config: > { @@ -233,7 +233,12 @@ jobs: ] } + vcpkg-ci: + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-vcpkg-ci.yml@1.6.0 + with: + port_name: beman-cstring-view + create-issue-when-fault: needs: [preset-test, build-and-test, build-and-test-cpp17] if: failure() && github.event_name == 'schedule' - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.6.0 diff --git a/.github/workflows/pre-commit-check.yml b/.github/workflows/pre-commit-check.yml index 980f6c5..15c5280 100644 --- a/.github/workflows/pre-commit-check.yml +++ b/.github/workflows/pre-commit-check.yml @@ -16,4 +16,4 @@ permissions: jobs: pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.6.0 diff --git a/.github/workflows/pre-commit-update.yml b/.github/workflows/pre-commit-update.yml index 879e81d..4559254 100644 --- a/.github/workflows/pre-commit-update.yml +++ b/.github/workflows/pre-commit-update.yml @@ -9,7 +9,7 @@ on: jobs: auto-update-pre-commit: - uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.5.3 + uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.6.0 secrets: APP_ID: ${{ secrets.AUTO_PR_BOT_APP_ID }} PRIVATE_KEY: ${{ secrets.AUTO_PR_BOT_PRIVATE_KEY }} diff --git a/.github/workflows/vcpkg-release.yml b/.github/workflows/vcpkg-release.yml new file mode 100644 index 0000000..7d036cb --- /dev/null +++ b/.github/workflows/vcpkg-release.yml @@ -0,0 +1,13 @@ +# 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.6.0 + with: + port_name: beman-cstring-view + secrets: + VCPKG_REGISTRY_TOKEN: ${{ secrets.VCPKG_REGISTRY_TOKEN }} diff --git a/.gitignore b/.gitignore index d293e3b..d62996c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,9 @@ # ignore vscode settings .vscode + +# ignore vim swap files +.swp + +# ignore merge/patch backup files +.orig diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 934fb21..933e899 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,4 +45,4 @@ repos: hooks: - id: beman-tidy -exclude: 'cookiecutter/|infra/' +exclude: 'cookiecutter/|infra/|port/' diff --git a/CMakeLists.txt b/CMakeLists.txt index dfac472..4d6212b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,7 @@ cmake_minimum_required(VERSION 3.30...4.3) project( - beman.cstring_view # CMake Project Name, which is also the name of the top-level - # targets (e.g., library, executable, etc.). + beman.cstring_view DESCRIPTION "A null-terminated string view." LANGUAGES CXX VERSION 0.1.0 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 02c2226..96d3dce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,6 +54,30 @@ ctest --test-dir build ## 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: + +``` +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 diff --git a/README.md b/README.md index e1e8335..1c36ad2 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,17 @@ For details on building beman.cstring_view without using a CMake preset, refer t ### Installation +#### Vcpkg + +The preferred way to install cstring_view 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 cstring_view [provides](vcpkg-configuration.json)). + +Then, simply run `vcpkg install beman-cstring-view`. + +#### Manual + To install beman.cstring_view globally after building with the `gcc-release` preset, you can run: diff --git a/infra/.beman_submodule b/infra/.beman_submodule index 8463363..a2ad45f 100644 --- a/infra/.beman_submodule +++ b/infra/.beman_submodule @@ -1,3 +1,3 @@ [beman_submodule] remote=https://github.com/bemanproject/infra.git -commit_hash=dfdb103b5fc9cccd3424c377130e318466f1dd89 +commit_hash=1b14bad2cd2cf0e44d1aeb608557e0e35ce27eaa diff --git a/infra/README.md b/infra/README.md index bf9bbb0..6cb8dd6 100644 --- a/infra/README.md +++ b/infra/README.md @@ -22,7 +22,7 @@ This repository is intended to be used as a beman-submodule in other Beman repos #### `beman_install_library` The CMake modules in this repository are intended to be used by Beman libraries. Use the -`beman_add_install_library_config()` function to install your library, along with header +`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 @@ -31,7 +31,7 @@ add_library(beman::something ALIAS beman.something) # ... configure your target as needed ... -find_package(beman-install-library REQUIRED) +include(infra/cmake/beman-install-library.cmake) beman_install_library(beman.something) ``` diff --git a/infra/cmake/llvm-libc++-toolchain.cmake b/infra/cmake/llvm-libc++-toolchain.cmake index 76264c6..eabf363 100644 --- a/infra/cmake/llvm-libc++-toolchain.cmake +++ b/infra/cmake/llvm-libc++-toolchain.cmake @@ -1,4 +1,4 @@ -# SPDX-License-Identifier: BSL-1.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. diff --git a/infra/cmake/telemetry.sh b/infra/cmake/telemetry.sh index 307cc94..323982e 100755 --- a/infra/cmake/telemetry.sh +++ b/infra/cmake/telemetry.sh @@ -29,7 +29,7 @@ _ME="$(basename "${0}")" _print_help() { cat <_FOUND tells CMake that `find_package` is # not needed for this package anymore - set("${BemanExemplar_pkgName}_FOUND" TRUE PARENT_SCOPE) + set("${Beman_pkgName}_FOUND" TRUE PARENT_SCOPE) endif() endif() endforeach() endfunction() +set(BEMAN_USE_FETCH_CONTENT_ENABLED ON) + cmake_language( - SET_DEPENDENCY_PROVIDER BemanExemplar_provideDependency + SET_DEPENDENCY_PROVIDER Beman_provideDependency SUPPORTED_METHODS FIND_PACKAGE ) diff --git a/lockfile.json b/lockfile.json index 3a69ab1..787b905 100644 --- a/lockfile.json +++ b/lockfile.json @@ -4,7 +4,10 @@ "name": "googletest", "package_name": "GTest", "git_repository": "https://github.com/google/googletest.git", - "git_tag": "6910c9d9165801d8827d628cb72eb7ea9dd538c5" + "git_tag": "6910c9d9165801d8827d628cb72eb7ea9dd538c5", + "cmake_args": { + "INSTALL_GTEST": "OFF" + } } ] } diff --git a/port/portfile.cmake.in b/port/portfile.cmake.in new file mode 100644 index 0000000..473fcd2 --- /dev/null +++ b/port/portfile.cmake.in @@ -0,0 +1,28 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO bemanproject/cstring_view + REF "v@VERSION@" + SHA512 @SHA512@ + HEAD_REF main +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBEMAN_CSTRING_VIEW_BUILD_TESTS=OFF + -DBEMAN_CSTRING_VIEW_BUILD_EXAMPLES=OFF +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup( + PACKAGE_NAME beman.cstring_view + CONFIG_PATH lib/cmake/beman.cstring_view +) + +file(REMOVE_RECURSE + "${CURRENT_PACKAGES_DIR}/debug" + "${CURRENT_PACKAGES_DIR}/lib" +) + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/port/vcpkg.json.in b/port/vcpkg.json.in new file mode 100644 index 0000000..9d31447 --- /dev/null +++ b/port/vcpkg.json.in @@ -0,0 +1,17 @@ +{ + "name": "beman-cstring-view", + "version-semver": "@VERSION@", + "description": "A null-terminated string view.", + "homepage": "https://github.com/bemanproject/cstring_view", + "license": "Apache-2.0 WITH LLVM-exception", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/tests/beman/cstring_view/CMakeLists.txt b/tests/beman/cstring_view/CMakeLists.txt index 68b6480..d49db49 100644 --- a/tests/beman/cstring_view/CMakeLists.txt +++ b/tests/beman/cstring_view/CMakeLists.txt @@ -13,4 +13,4 @@ target_link_libraries( ) include(GoogleTest) -gtest_discover_tests(beman.cstring_view.tests.cstring_view) +gtest_discover_tests(beman.cstring_view.tests.cstring_view DISCOVERY_TIMEOUT 60) diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..25169b2 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,15 @@ +{ + "default-registry": { + "kind": "git", + "repository": "https://github.com/microsoft/vcpkg.git", + "baseline": "80f9bcfa455e875d9c1bf7a7c6692d7e1e481061" + }, + "registries": [ + { + "kind": "git", + "repository": "https://github.com/bemanproject/vcpkg-registry.git", + "baseline": "5195f94f2b550163917c1152180fc59bbd760556", + "packages": ["beman-*"] + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..94c0667 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,10 @@ +{ + "name": "beman-cstring-view", + "version-semver": "0.1.0", + "dependencies": [ + { + "name": "gtest", + "host": true + } + ] +}