Skip to content
Open
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
20 changes: 19 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,18 @@ jobs:
std: 20,
},
}
- {
name: "Ubuntu GCC-16 (C++26 Reflection)",
os: ubuntu-24.04,
compiler:
{
type: GCC16,
version: 16,
cc: "gcc-16",
cxx: "g++-16",
std: 26,
},
}
steps:
- uses: actions/checkout@v4
- uses: lukka/[email protected]
Expand All @@ -231,9 +243,15 @@ jobs:
with:
version: ${{ matrix.settings.compiler.version }}
platform: x64
- name: Install GCC 16 from ubuntu-toolchain-r PPA
if: matrix.settings.compiler.type == 'GCC16'
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y --no-install-recommends g++-16 gcc-16
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Set up Python
run: uv sync
- name: Run CMake
run: ./scripts/cmake.sh --${{ matrix.configuration == 'Debug' && 'debug' || 'release' }}
run: ./scripts/cmake.sh --${{ matrix.configuration == 'Debug' && 'debug' || 'release' }} ${{ matrix.settings.compiler.type == 'GCC16' && '--reflection' || '' }}
31 changes: 30 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22.4 FATAL_ERROR)
cmake_minimum_required(VERSION 3.25 FATAL_ERROR)
cmake_policy(SET CMP0127 NEW)
cmake_policy(SET CMP0135 NEW)
cmake_policy(SET CMP0140 NEW)
Expand Down Expand Up @@ -29,6 +29,35 @@ option(ENABLE_UBSAN "Enable Undefined Behaviour Sanitizer" OFF)
option(ENABLE_TSAN "Enable Thread Sanitizer" OFF)
option(ENABLE_MSAN "Enable Memory Sanitizer" OFF)

option(
XYZ_PROTOCOL_BUILD_REFLECTION
"Also build and test tutorials/reflection.cc, which requires a compiler \
with C++26 P2996 reflection support (eg. GCC 16+ with -freflection)."
OFF)

if(XYZ_PROTOCOL_BUILD_REFLECTION)
set(CMAKE_CXX_STANDARD 26)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_REQUIRED_FLAGS "-freflection")
endif()
include(CheckCXXSourceCompiles)
check_cxx_source_compiles(
"
#include <meta>
constexpr std::meta::info reflection_of_int = ^^int;
int main() {}
"
XYZ_PROTOCOL_REFLECTION_SUPPORTED)
unset(CMAKE_REQUIRED_FLAGS)
if(NOT XYZ_PROTOCOL_REFLECTION_SUPPORTED)
Comment thread
jbcoe marked this conversation as resolved.
message(
FATAL_ERROR
"XYZ_PROTOCOL_BUILD_REFLECTION is ON but the compiler "
"(${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}) does not "
"support C++26 reflection.")
endif()
endif()

if(ENABLE_ASAN OR ENABLE_UBSAN OR ENABLE_TSAN OR ENABLE_MSAN)
set(ENABLE_SANITIZERS ON)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/xyz_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function(xyz_add_test)
if(NOT XYZ_VERSION)
set(XYZ_VERSION 20)
else()
set(VALID_TARGET_VERSIONS 11 14 17 20 23)
set(VALID_TARGET_VERSIONS 11 14 17 20 23 26)
Comment thread
jbcoe marked this conversation as resolved.
list(FIND VALID_TARGET_VERSIONS ${XYZ_VERSION} index)
if(index EQUAL -1)
message(FATAL_ERROR "TYPE must be one of <${VALID_TARGET_VERSIONS}>")
Expand Down
27 changes: 17 additions & 10 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1
FROM ubuntu:24.04

# Install base tools and C++ development tools.
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
curl \
g++ \
gdb \
Expand All @@ -18,13 +18,20 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
ssh \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/*

# Install newer CMake from kitware.
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \
&& apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ noble main' \
&& apt-get update && apt-get install -y --no-install-recommends cmake \
&& rm -rf /var/lib/apt/lists/*
&& apt-add-repository -y 'deb https://apt.kitware.com/ubuntu/ noble main' \
&& apt-get update && apt-get install -y --no-install-recommends cmake \
&& rm -rf /var/lib/apt/lists/*

# Install GCC 16 (experimental C++26 reflection support via -std=c++26
# -freflection, see https://gcc.gnu.org/gcc-16/changes.html) from the Ubuntu
# Toolchain Test PPA, since Ubuntu 24.04's own repos only go up to GCC 14.
RUN add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update && apt-get install -y --no-install-recommends g++-16 gcc-16 \
&& rm -rf /var/lib/apt/lists/*

# Install bazelisk.
RUN ARCH=$(dpkg --print-architecture) && \
Expand All @@ -36,11 +43,11 @@ RUN ARCH=$(dpkg --print-architecture) && \
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md (not reliably
# available via Ubuntu 24.04's default repos).
RUN mkdir -p -m 755 /etc/apt/keyrings \
&& wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list >/dev/null \
&& apt-get update && apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*
&& wget -nv -O /etc/apt/keyrings/githubcli-archive-keyring.gpg https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list >/dev/null \
&& apt-get update && apt-get install -y --no-install-recommends gh \
&& rm -rf /var/lib/apt/lists/*

# Install jj (Jujutsu VCS) from its GitHub release binary. The jujutsu apt
# package isn't built for Ubuntu 24.04 (noble) or Debian stable; it only
Expand Down
Loading
Loading