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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -13,14 +13,14 @@ 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: v20.1.7
rev: v21.1.2
hooks:
- id: clang-format
types_or: [c++, c]

# CMake linting and formatting
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.15.1
rev: 0.22.3
hooks:
- id: gersemi
name: CMake linting
Expand All @@ -34,7 +34,7 @@ repos:
# - id: markdownlint

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

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=78de7eb4ff54bd12c9abb790107edc86bcda07d8
commit_hash=bb58b2a1cc894d58a55bf745be78f5d27029e245
2 changes: 1 addition & 1 deletion infra/.github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @ednolan @neatudarius @rishyak @wusatosi
* @ednolan @neatudarius @rishyak @wusatosi @JeffGarland
36 changes: 0 additions & 36 deletions infra/.github/workflows/beman-tidy.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 }}
9 changes: 5 additions & 4 deletions infra/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
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.3.0
rev: v2.4.1
hooks:
- id: codespell

# CMake linting and formatting
- repo: https://github.com/BlankSpruce/gersemi
rev: 0.15.1
rev: 0.22.3
hooks:
- id: gersemi
name: CMake linting
exclude: ^.*/tests/.*/data/ # Exclude test data directories

# Python linting and formatting
# config file: ruff.toml (not currently present but add if needed)
# https://docs.astral.sh/ruff/configuration/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.1
rev: v0.13.2
hooks:
- id: ruff-check
files: ^tools/beman-tidy/
Expand Down
13 changes: 1 addition & 12 deletions infra/LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -216,15 +217,3 @@ 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.

==============================================================================
Software from third parties included in the Beman Project:
==============================================================================
The Beman Project contains third party software which is under different license
terms. All such code will be identified clearly using at least one of two
mechanisms:
1) It will be in a separate directory tree with its own `LICENSE.txt` or
`LICENSE` file at the top containing the specific license and restrictions
which apply to that software, or
2) It will contain specific license and restriction terms at the top of every
file.
48 changes: 46 additions & 2 deletions infra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,54 @@

<!-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->

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!
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.
* `tools/`: Tools used to manage the infrastructure and the codebase (e.g., linting, formatting, etc.).

## Usage

This repository is intended to be used as a beman-submodule in other Beman repositories. See
[the Beman Submodule documentation](./tools/beman-submodule/README.md) for details.


### CMake Modules


#### `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
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 ...

find_package(beman-install-library REQUIRED)
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)
* `<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`.
3 changes: 3 additions & 0 deletions infra/cmake/appleclang-toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ 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}")
169 changes: 169 additions & 0 deletions infra/cmake/beman-install-library-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
include_guard(GLOBAL)

# This file defines the function `beman_install_library` which is used to
# install a library target and its headers, along with optional CMake
# configuration files.
#
# The function is designed to be reusable across different Beman libraries.

function(beman_install_library name)
# Usage
# -----
#
# beman_install_library(NAME)
#
# Brief
# -----
#
# This function installs the specified library target and its headers.
# It also handles the installation of the CMake configuration files if needed.
#
# CMake variables
# ---------------
#
# Note that configuration of the installation is generally controlled by CMake
# cache variables so that they can be controlled by the user or tool running the
# `cmake` command. Neither `CMakeLists.txt` nor `*.cmake` files should set these
# variables directly.
#
# - BEMAN_INSTALL_CONFIG_FILE_PACKAGES:
# List of packages that require config file installation.
# If the package name is in this list, it will install the config file.
#
# - <PREFIX>_INSTALL_CONFIG_FILE_PACKAGE:
# Boolean to control config file installation for the specific library.
# The prefix `<PREFIX>` is the uppercased name of the library with dots
# replaced by underscores.
#
if(NOT TARGET "${name}")
message(FATAL_ERROR "Target '${name}' does not exist.")
endif()

if(NOT ARGN STREQUAL "")
message(
FATAL_ERROR
"beman_install_library does not accept extra arguments: ${ARGN}"
)
endif()

# Given foo.bar, the component name is bar
string(REPLACE "." ";" name_parts "${name}")
# 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 expects a name of the form 'beman.<name>', got '${name}'"
)
endif()

set(target_name "${name}")
set(install_component_name "${name}")
set(export_name "${name}")
set(package_name "${name}")
list(GET name_parts -1 component_name)

install(
TARGETS "${target_name}"
COMPONENT "${install_component_name}"
EXPORT "${export_name}"
FILE_SET HEADERS
)

set_target_properties(
"${target_name}"
PROPERTIES EXPORT_NAME "${component_name}"
)

include(GNUInstallDirs)

# Determine the prefix for project-specific variables
string(TOUPPER "${name}" project_prefix)
string(REPLACE "." "_" project_prefix "${project_prefix}")

option(
${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE
"Enable building examples. Default: ${PROJECT_IS_TOP_LEVEL}. Values: { ON, OFF }."
${PROJECT_IS_TOP_LEVEL}
)

# By default, install the config package
set(install_config_package ON)

# Turn OFF installation of config package by default if,
# in order of precedence:
# 1. The specific package variable is set to OFF
# 2. The package name is not in the list of packages to install config files
if(DEFINED BEMAN_INSTALL_CONFIG_FILE_PACKAGES)
if(
NOT "${install_component_name}"
IN_LIST
BEMAN_INSTALL_CONFIG_FILE_PACKAGES
)
set(install_config_package OFF)
endif()
endif()
if(DEFINED ${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE)
set(install_config_package
${${project_prefix}_INSTALL_CONFIG_FILE_PACKAGE}
)
endif()

if(install_config_package)
message(
DEBUG
"beman-install-library: Installing a config package for '${name}'"
)

include(CMakePackageConfigHelpers)

find_file(
config_file_template
NAMES "${package_name}-config.cmake.in"
PATHS "${CMAKE_CURRENT_SOURCE_DIR}"
NO_DEFAULT_PATH
NO_CACHE
REQUIRED
)
set(config_package_file
"${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config.cmake"
)
set(package_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${package_name}")
configure_package_config_file(
"${config_file_template}"
"${config_package_file}"
INSTALL_DESTINATION "${package_install_dir}"
PATH_VARS PROJECT_NAME PROJECT_VERSION
)

set(config_version_file
"${CMAKE_CURRENT_BINARY_DIR}/${package_name}-config-version.cmake"
)
write_basic_package_version_file(
"${config_version_file}"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY ExactVersion
)

install(
FILES "${config_package_file}" "${config_version_file}"
DESTINATION "${package_install_dir}"
COMPONENT "${install_component_name}"
)

set(config_targets_file "${package_name}-targets.cmake")
install(
EXPORT "${export_name}"
DESTINATION "${package_install_dir}"
NAMESPACE beman::
FILE "${config_targets_file}"
COMPONENT "${install_component_name}"
)
else()
message(
DEBUG
"beman-install-library: Not installing a config package for '${name}'"
)
endif()
endfunction()
Loading