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
20 changes: 15 additions & 5 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 @@ -105,7 +105,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 @@ -143,4 +153,4 @@ jobs:
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.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 }}
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,4 @@ repos:
hooks:
- id: codespell

- repo: https://github.com/bemanproject/beman-tidy
rev: v0.3.1
hooks:
- id: beman-tidy
args: [".", "--verbose", "--require-all"]

exclude: 'cookiecutter/|infra/'
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,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.timed_lock_alg INTERFACE)
add_library(beman::timed_lock_alg ALIAS beman.timed_lock_alg)
Expand All @@ -43,6 +44,7 @@ set_target_properties(
add_subdirectory(include/beman/timed_lock_alg)

beman_install_library(beman.timed_lock_alg TARGETS beman.timed_lock_alg)
configure_build_telemetry()

if(BEMAN_TIMED_LOCK_ALG_BUILD_TESTS)
enable_testing()
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ You can disable building tests by setting CMake option `BEMAN_TIMED_LOCK_ALG_BUI
| GCC | 15-13 | C++26-C++20 | libstdc++ |
| GCC | 12-11 | C++23, C++20 | libstdc++ |
| Clang | 22-19 | C++26-C++20 | libstdc++, libc++ |
| Clang | 18-17 | C++26-C++20 | libc++ |
| Clang | 18-17 | C++20 | libstdc++ |
| Clang | 18 | C++26-C++20 | libc++ |
| Clang | 18 | C++23-C++20 | libstdc++ |
| Clang | 17 | C++26-C++20 | libc++ |
| Clang | 17 | C++20 | libstdc++ |
| AppleClang | latest | C++26-C++20 | 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@)
38 changes: 19 additions & 19 deletions infra/cmake/beman-install-library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ function(beman_install_library name)
set(multiValueArgs TARGETS DEPENDENCIES)

cmake_parse_arguments(
BEMAN
BEMAN_INSTALL
"${options}"
"${oneValueArgs}"
"${multiValueArgs}"
${ARGN}
)

if(NOT BEMAN_TARGETS)
if(NOT BEMAN_INSTALL_TARGETS)
message(
FATAL_ERROR
"beman_install_library(${name}): TARGETS must be specified"
Expand All @@ -103,7 +103,7 @@ function(beman_install_library name)
if(CMAKE_SKIP_INSTALL_RULES)
message(
WARNING
"beman_install_library(${name}): not installing targets '${BEMAN_TARGETS}' due to CMAKE_SKIP_INSTALL_RULES"
"beman_install_library(${name}): not installing targets '${BEMAN_INSTALL_TARGETS}' due to CMAKE_SKIP_INSTALL_RULES"
)
return()
endif()
Expand All @@ -113,16 +113,16 @@ function(beman_install_library name)
# ----------------------------
# Defaults
# ----------------------------
if(NOT BEMAN_NAMESPACE)
set(BEMAN_NAMESPACE "beman::")
if(NOT BEMAN_INSTALL_NAMESPACE)
set(BEMAN_INSTALL_NAMESPACE "beman::")
endif()

if(NOT BEMAN_EXPORT_NAME)
set(BEMAN_EXPORT_NAME "${name}-targets")
if(NOT BEMAN_INSTALL_EXPORT_NAME)
set(BEMAN_INSTALL_EXPORT_NAME "${name}-targets")
endif()

if(NOT BEMAN_DESTINATION)
set(BEMAN_DESTINATION "${_config_install_dir}/modules")
if(NOT BEMAN_INSTALL_DESTINATION)
set(BEMAN_INSTALL_DESTINATION "${_config_install_dir}/modules")
endif()

string(REPLACE "beman." "" install_component_name "${name}")
Expand All @@ -134,7 +134,7 @@ function(beman_install_library name)
# --------------------------------------------------
# Install each target with all of its file sets
# --------------------------------------------------
foreach(_tgt IN LISTS BEMAN_TARGETS)
foreach(_tgt IN LISTS BEMAN_INSTALL_TARGETS)
if(NOT TARGET "${_tgt}")
message(
WARNING
Expand Down Expand Up @@ -177,8 +177,7 @@ function(beman_install_library name)
)
foreach(_install_header_set IN LISTS _available_header_sets)
list(
APPEND
_install_header_set_args
APPEND _install_header_set_args
FILE_SET
"${_install_header_set}"
COMPONENT
Expand All @@ -198,15 +197,15 @@ function(beman_install_library name)
)
install(
TARGETS "${_tgt}"
EXPORT ${BEMAN_EXPORT_NAME}
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_DESTINATION}"
DESTINATION "${BEMAN_INSTALL_DESTINATION}"
COMPONENT "${install_component_name}_Development"
# NOTE: There's currently no convention for this location! CK
CXX_MODULES_BMI
Expand All @@ -217,7 +216,7 @@ function(beman_install_library name)
else()
install(
TARGETS "${_tgt}"
EXPORT ${BEMAN_EXPORT_NAME}
EXPORT ${BEMAN_INSTALL_EXPORT_NAME}
ARCHIVE COMPONENT "${install_component_name}_Development"
LIBRARY
COMPONENT "${install_component_name}_Runtime"
Expand All @@ -233,8 +232,8 @@ function(beman_install_library name)
# --------------------------------------------------
# gersemi: off
install(
EXPORT ${BEMAN_EXPORT_NAME}
NAMESPACE ${BEMAN_NAMESPACE}
EXPORT ${BEMAN_INSTALL_EXPORT_NAME}
NAMESPACE ${BEMAN_INSTALL_NAMESPACE}
CXX_MODULES_DIRECTORY cxx-modules
DESTINATION ${_config_install_dir}
COMPONENT "${install_component_name}_Development"
Expand Down Expand Up @@ -279,19 +278,20 @@ function(beman_install_library name)
# expand dependencies
# ----------------------------------------
set(_beman_find_deps "")
foreach(dep IN LISTS BEMAN_DEPENDENCIES)
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_FIND_DEPENDENCIES "${_beman_find_deps}")
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"
Expand Down
Loading
Loading