Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .exemplar_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f5759898e1ac110fc070791b83267f13c9b50b4c
b1e7015b1bd62ce5b20009cec7ee98ba5c783818
34 changes: 27 additions & 7 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ on:

jobs:
beman-submodule-check:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-submodule-check.yml@1.5.3

preset-test:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-preset-test.yml@1.5.3
with:
matrix_config: >
[
Expand All @@ -31,7 +31,7 @@ jobs:
]

build-and-test:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.3
with:
matrix_config: >
{
Expand Down Expand Up @@ -99,7 +99,17 @@ jobs:
}
]
},
{ "versions": ["18", "17"],
{ "versions": ["18"],
"tests": [
{ "cxxversions": ["c++26", "c++23", "c++20"],
"tests": [{"stdlibs": ["libc++"], "tests": ["Release.Default"]}]
},
{ "cxxversions": ["c++23", "c++20"],
"tests": [{"stdlibs": ["libstdc++"], "tests": ["Release.Default"]}]
}
]
},
{ "versions": ["17"],
"tests": [
{ "cxxversions": ["c++26", "c++23", "c++20"],
"tests": [{"stdlibs": ["libc++"], "tests": ["Release.Default"]}]
Expand Down Expand Up @@ -135,7 +145,7 @@ jobs:
}

build-and-test-cpp17:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-build-and-test.yml@1.5.3
with:
matrix_config: >
{
Expand Down Expand Up @@ -182,7 +192,17 @@ jobs:
}
]
},
{ "versions": ["18", "17"],
{ "versions": ["18"],
"tests": [
{ "cxxversions": ["c++26", "c++17"],
"tests": [{"stdlibs": ["libc++"], "tests": ["Release.-DBEMAN_CSTRING_VIEW_CPP17_MODE=on"]}]
},
{ "cxxversions": ["c++23", "c++20", "c++17"],
"tests": [{"stdlibs": ["libstdc++"], "tests": ["Release.-DBEMAN_CSTRING_VIEW_CPP17_MODE=on"]}]
}
]
},
{ "versions": ["17"],
"tests": [
{ "cxxversions": ["c++26", "c++17"],
"tests": [{"stdlibs": ["libc++"], "tests": ["Release.-DBEMAN_CSTRING_VIEW_CPP17_MODE=on"]}]
Expand Down Expand Up @@ -216,4 +236,4 @@ jobs:
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.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-create-issue-when-fault.yml@1.5.3
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ permissions:

jobs:
pre-commit:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-pre-commit.yml@1.5.3
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
auto-update-pre-commit:
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.5.0
uses: bemanproject/infra-workflows/.github/workflows/reusable-beman-update-pre-commit.yml@1.5.3
secrets:
APP_ID: ${{ secrets.AUTO_PR_BOT_APP_ID }}
PRIVATE_KEY: ${{ secrets.AUTO_PR_BOT_PRIVATE_KEY }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
# 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.3
rev: v22.1.4
hooks:
- id: clang-format
types_or: [c++, c]
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ option(
${PROJECT_IS_TOP_LEVEL}
)

# for find of beman-install-library
# for find of beman_install_library and configure_build_telemetry
include(infra/cmake/beman-install-library.cmake)
include(infra/cmake/BuildTelemetryConfig.cmake)

add_library(beman.cstring_view INTERFACE)
add_library(beman::cstring_view ALIAS beman.cstring_view)
Expand All @@ -50,6 +51,7 @@ set_target_properties(
add_subdirectory(include/beman/cstring_view)

beman_install_library(beman.cstring_view TARGETS beman.cstring_view)
configure_build_telemetry()

if(BEMAN_CSTRING_VIEW_CPP17_MODE)
target_compile_options(beman.cstring_view INTERFACE -DUSE_CPP17_VARIANT)
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ You can disable building tests by setting CMake option `BEMAN_CSTRING_VIEW_BUILD
| GCC | 15-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-17 | C++26-C++17 | libc++ |
| Clang | 18-17 | C++20, C++17 | libstdc++ |
| 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 |

Expand Down
2 changes: 1 addition & 1 deletion infra/.beman_submodule
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[beman_submodule]
remote=https://github.com/bemanproject/infra.git
commit_hash=54dcdad8b661a405a6ac06453f0f06da5d30ba5c
commit_hash=dfdb103b5fc9cccd3424c377130e318466f1dd89
6 changes: 3 additions & 3 deletions infra/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ repos:
- id: check-added-large-files

- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
rev: v2.4.2
hooks:
- id: codespell

# CMake linting and formatting
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.22.3
- repo: https://github.com/BlankSpruce/gersemi-pre-commit
rev: 0.27.2
hooks:
- id: gersemi
name: CMake linting
Expand Down
34 changes: 34 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,37 @@ 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)
* `<BEMAN_NAME>_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.
4 changes: 4 additions & 0 deletions infra/cmake/BuildTelemetry.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_guard(GLOBAL)

include(${CMAKE_CURRENT_LIST_DIR}/BuildTelemetryConfig.cmake)
configure_build_telemetry()
58 changes: 58 additions & 0 deletions infra/cmake/BuildTelemetryConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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)
6 changes: 3 additions & 3 deletions infra/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

include(CMakeFindDependencyMacro)

@BEMAN_FIND_DEPENDENCIES@
@BEMAN_INSTALL_FIND_DEPENDENCIES@

@PACKAGE_INIT@

include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/@BEMAN_INSTALL_BASE_PKG_NAME@-targets.cmake)

check_required_components(@PROJECT_NAME@)
check_required_components(@BEMAN_INSTALL_BASE_PKG_NAME@)
Loading
Loading