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
117 changes: 117 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
# SPDX-License-Identifier: BSD-3-Clause

# This is the clang-format configuration style to be used by Qt,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions

---
# Webkit style was loosely based on the Qt style
BasedOnStyle: WebKit

Standard: c++17

# Column width is limited to 100 in accordance with Qt Coding Style.
# https://wiki.qt.io/Qt_Coding_Style
# Note that this may be changed at some point in the future.
ColumnLimit: 100
# How much weight do extra characters after the line length limit have.
# PenaltyExcessCharacter: 4

# Disable reflow of some specific comments
# qdoc comments: indentation rules are different.
# Translation comments and SPDX license identifiers are also excluded.
# REUSE-IgnoreStart
CommentPragmas: "^!|^:|^ SPDX-License-Identifier:"
# REUSE-IgnoreEnd

# We want a space between the type and the star for pointer types.
PointerBindsToType: false

# We generally use "template <" with space.
SpaceAfterTemplateKeyword: true

# We want to break before the operators, but not before a '='.
BreakBeforeBinaryOperators: NonAssignment

# Braces are usually attached, but not after functions or class declarations.
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false

# When constructor initializers do not fit on one line, put them each on a new line.
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# Indent initializers by 4 spaces
ConstructorInitializerIndentWidth: 4

# Indent width for line continuations.
ContinuationIndentWidth: 8

# No indentation for namespaces.
NamespaceIndentation: None

# Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125
IndentPPDirectives: AfterHash
# We only indent with 2 spaces for preprocessor directives
PPIndentWidth: 2

# Horizontally align arguments after an open bracket.
# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: true
AlwaysBreakTemplateDeclarations: true

# Ideally we should also allow less short function in a single line, but
# clang-format does not handle that.
AllowShortFunctionsOnASingleLine: Inline

# The coding style specifies some include order categories, but also tells to
# separate categories with an empty line. It does not specify the order within
# the categories. Since the SortInclude feature of clang-format does not
# re-order includes separated by empty lines, the feature is not used.
SortIncludes: false

# macros for which the opening brace stays attached.
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]

# Break constructor initializers before the colon and after the commas.
BreakConstructorInitializers: BeforeColon

# Add "// namespace <namespace>" comments on closing brace for a namespace
# Ignored for namespaces that qualify as a short namespace,
# see 'ShortNamespaceLines'
FixNamespaceComments: true

# Definition of how short a short namespace is, default 1
ShortNamespaceLines: 1

# When escaping newlines in a macro attach the '\' as far left as possible, e.g.
##define a \
# something; \
# other; \
# thelastlineislong;
AlignEscapedNewlines: Left

# Avoids the addition of a space between an identifier and the
# initializer list in list-initialization.
SpaceBeforeCpp11BracedList: false

# Do not reflow any comment
ReflowComments: false

---
# Use the Google-based style for .proto files.
Language: Proto
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
32 changes: 32 additions & 0 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI Linux

on:
push:
branches: [ main, master ]
pull_request:

jobs:
build-and-test:
# Ubuntu 24.04 ships Qt 6.4, which is the minimum the CMakeLists asks for.
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # full history + tags, for the version from git describe

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
cmake ninja-build g++ \
qt6-base-dev \
libgtest-dev

- name: Configure
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build

- name: Test
run: ctest --test-dir build --output-on-failure
35 changes: 35 additions & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI (macOS)

on:
push:
branches: [ main, master ]
pull_request:

jobs:
build-and-test:
# macos-14 is Apple Silicon; the clang_64 Qt kit is a universal build, so it works there.
runs-on: macos-14
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # full history + tags, for the version from git describe

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.8.3
host: mac
arch: clang_64
cache: true

- name: Install build tools
run: brew install ninja googletest

- name: Configure
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build

- name: Test
run: ctest --test-dir build --output-on-failure
47 changes: 47 additions & 0 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI (Windows)

on:
push:
branches: [ main, master ]
pull_request:

jobs:
build-and-test:
runs-on: windows-2022
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # full history + tags, for the version from git describe

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.8.3
host: windows
arch: win64_mingw
tools: tools_mingw1310
cache: true

# The runner's own gcc would not match the ABI of Qt's MinGW kit, so put the kit's first.
- name: Use Qt's MinGW toolchain
shell: bash
run: echo "$(cygpath -u "$QT_ROOT_DIR/../../Tools/mingw1310_64/bin")" >> "$GITHUB_PATH"

# No packaged GTest for Qt's MinGW kit, so build one with it.
- name: Install GTest
shell: bash
run: |
git clone --depth 1 --branch v1.15.2 https://github.com/google/googletest.git "$RUNNER_TEMP/googletest"
cmake -S "$RUNNER_TEMP/googletest" -B "$RUNNER_TEMP/googletest/build" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$RUNNER_TEMP/gtest"
cmake --build "$RUNNER_TEMP/googletest/build"
cmake --install "$RUNNER_TEMP/googletest/build"
echo "GTest_ROOT=$RUNNER_TEMP/gtest" >> "$GITHUB_ENV"

- name: Configure
run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release

- name: Build
run: cmake --build build

- name: Test
run: ctest --test-dir build --output-on-failure
Loading
Loading