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 @@
0e615052846f61ed12b4cac61accac8ad0074d13
b1e7015b1bd62ce5b20009cec7ee98ba5c783818
8 changes: 4 additions & 4 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 @@ -126,4 +126,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 @@ -10,4 +10,4 @@ on:

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 @@ -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.transform_view INTERFACE)
add_library(beman::transform_view ALIAS beman.transform_view)
Expand All @@ -43,6 +44,7 @@ set_target_properties(
add_subdirectory(include/beman/transform_view)

beman_install_library(beman.transform_view TARGETS beman.transform_view)
configure_build_telemetry()

if(BEMAN_TRANSFORM_VIEW_BUILD_TESTS)
enable_testing()
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=63cb577f6484f13ce3349de49ad5ce27e20bf1da
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@)
48 changes: 24 additions & 24 deletions infra/cmake/beman-install-library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ include(GNUInstallDirs)
# 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 FILE_SET CXX_MODULE, it will also
# needed. If the given targets has a PUBLIC FILE_SET CXX_MODULE, it will also
# installed to the given DESTINATION
#
# Cache variables:
Expand All @@ -72,7 +72,7 @@ include(GNUInstallDirs)
# Caveats
# -------
#
# **Only one `FILE_SET CXX_MODULES` is yet supported to install with this
# **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
Expand All @@ -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 @@ -189,24 +188,24 @@ function(beman_install_library name)
set(_install_header_set_args FILE_SET HEADERS) # Note: empty FILE_SET in this case! CK
endif()

# Detect presence of C++ module file sets, exact one expected!
get_target_property(_module_sets "${_tgt}" CXX_MODULE_SETS)
# 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 CXX_MODULE_SETS=${_module_sets}"
"beman-install-library(${name}): '${_tgt}' has INTERFACE_CXX_MODULE_SETS=${_module_sets}"
)
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