Skip to content
Closed
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: 2 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- "scripts/bazel.py"
- "scripts/bazel.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"
- "xyz/tutorials/BUILD.bazel"
# No `paths:` filter here. The `bazel` summary job is a required status
# check for merging to main, and a workflow that is filtered out by
Expand Down Expand Up @@ -72,6 +73,7 @@ jobs:
- "scripts/bazel.py"
- "scripts/bazel.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"
- "xyz/tutorials/BUILD.bazel"

build:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- "**/.clang-tidy"
- "scripts/cmake.py"
- "scripts/cmake.sh"
- "scripts/generate_operator_thunks.py"
# The clang-tidy job is not a required status check, so a `paths:` filter
# here is safe: a pull request that touches nothing relevant simply gets no
# check rather than an eternally pending one.
Expand All @@ -36,6 +37,7 @@ on:
- "**/.clang-tidy"
- "scripts/cmake.py"
- "scripts/cmake.sh"
- "scripts/generate_operator_thunks.py"
workflow_dispatch:

# One group per PR, or per ref for pushes and scheduled runs. A new push to a
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ on:
- "scripts/cmake.py"
- "scripts/cmake.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"
# No `paths:` filter here. The `cmake` summary job is a required status
# check for merging to main, and a workflow that is filtered out by
# `paths:` never reports a check, which leaves unrelated pull requests
Expand Down Expand Up @@ -65,6 +66,7 @@ jobs:
- "scripts/cmake.py"
- "scripts/cmake.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"

build:
needs: detect-changes
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
- "scripts/consteval_coverage.py"
- "scripts/consteval_coverage_test.py"
- "scripts/consteval_coverage.sh"
- "scripts/generate_operator_thunks.py"
pull_request:
paths:
# Keep in sync with the `push.paths` list above.
Expand All @@ -43,6 +44,7 @@ on:
- "scripts/consteval_coverage.py"
- "scripts/consteval_coverage_test.py"
- "scripts/consteval_coverage.sh"
- "scripts/generate_operator_thunks.py"

# One group per PR, or per ref for pushes and scheduled runs. A new push to a
# PR cancels the runs for its previous head; main and scheduled runs only queue.
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- "scripts/bazel.py"
- "scripts/bazel.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"
- "xyz/tutorials/BUILD.bazel"
# No `paths:` filter here. The `sanitizers` summary job is a required
# status check for merging to main, and a workflow that is filtered out by
Expand Down Expand Up @@ -72,6 +73,7 @@ jobs:
- "scripts/bazel.py"
- "scripts/bazel.sh"
- "scripts/compiler_discovery.py"
- "scripts/generate_operator_thunks.py"
- "xyz/tutorials/BUILD.bazel"

sanitized-tests:
Expand Down
29 changes: 29 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
load("@apple_support//xcode:xcode_config.bzl", "xcode_config")
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("@rules_python//python:py_binary.bzl", "py_binary")

package(default_visibility = ["//visibility:public"])

py_binary(
name = "py_generate_operator_thunks",
srcs = ["scripts/generate_operator_thunks.py"],
main = "scripts/generate_operator_thunks.py",
)

genrule(
name = "generate_operator_thunks",
outs = ["xyz/detail/operator_thunks.hh"],
cmd = "$(location :py_generate_operator_thunks) --output $@",
tools = [":py_generate_operator_thunks"],
)

# Implementation headers. Visible only inside this repository; tests that
# include them depend on this target directly.
cc_library(
Expand Down Expand Up @@ -62,6 +76,21 @@ cc_test(
],
)

cc_test(
name = "protocol_feature_test",
size = "small",
srcs = [
"xyz/tests/feature_tests.cc",
],
tags = ["manual"],
deps = [
":consteval_check",
":detail",
":protocol",
"@googletest//:gtest_main",
],
)

# An xcode_config with no Xcode versions. build:macos in .bazelrc selects it
# so the C++ toolchain does not fetch @local_config_xcode, which compiles and
# runs xcode-locator and then xcodebuild for every installed Xcode on each
Expand Down
35 changes: 32 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,31 @@ include(xyz_add_test)
include(xyz_add_object_library)

find_package(ClangTidy)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

set(XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}/generated")
set(XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER
"${XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY}/xyz/detail/operator_thunks.hh")

add_custom_command(
OUTPUT "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}"
COMMAND
Python3::Interpreter
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_operator_thunks.py"
--output "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_operator_thunks.py"
COMMENT "Generating xyz/detail/operator_thunks.hh"
VERBATIM)

add_custom_target(
generate_operator_thunks ALL
DEPENDS "${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}")

xyz_add_library(
NAME protocol
ALIAS xyz_protocol::protocol)
add_dependencies(protocol generate_operator_thunks)
# One header list drives the build tree, the export and the install: a
# header missing here is missing from the installed package too.
target_sources(
Expand All @@ -127,14 +148,21 @@ target_sources(
xyz/detail/conformance.hh
xyz/detail/conversion_thunks.hh
xyz/detail/member_function_thunks.hh
xyz/detail/operator_thunks.hh
xyz/detail/overload_spec.hh
xyz/detail/owning_vtable.hh
xyz/detail/protocol_traits.hh
xyz/detail/protocol_wrappers.hh
xyz/detail/small_buffer.hh
xyz/detail/vtable.hh
xyz/detail/name_mangling.hh)
xyz/detail/name_mangling.hh
FILE_SET
generated_headers
TYPE
HEADERS
BASE_DIRS
"${XYZ_PROTOCOL_GENERATED_INCLUDE_DIRECTORY}"
FILES
"${XYZ_PROTOCOL_OPERATOR_THUNKS_HEADER}")
# Consumers need the reflection flags of whichever compiler they build with,
# so the options are generator expressions evaluated at their configure time
# rather than the flags of the compiler that installed the package.
Expand Down Expand Up @@ -206,7 +234,8 @@ if(XYZ_PROTOCOL_IS_NOT_SUBPROJECT)
install(
TARGETS protocol
EXPORT xyz_protocol-targets
FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
FILE_SET HEADERS DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILE_SET generated_headers DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

install(
EXPORT xyz_protocol-targets
Expand Down
7 changes: 7 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ bazel_dep(name = "googletest", version = "1.18.0")

# Only for the empty xcode_config in BUILD.bazel that build:macos selects.
bazel_dep(name = "apple_support", version = "1.24.2")
bazel_dep(name = "rules_python", version = "1.9.3")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")

# Python below is used in bazel for a generator, without deps.
# It does not need keeping in sync with pyproject.toml.
python.toolchain(python_version = "3.13")
Loading
Loading