Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-format all cpp and hpp files #1

Open
wants to merge 23 commits into
base: feature/fix-typos-with-codespell
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# We'll use defaults from the LLVM style, but with 4 columns indentation.
BasedOnStyle: Llvm
IndentWidth: 4
---
Language: Json
UseTab: Never
---
Language: JavaScript
# Don't format .js files.
DisableFormat: true
---
Language: Cpp
# TBD IndentWidth: 2

# ColumnLimit: 80
# AccessModifierOffset: -2
# AllowShortIfStatementsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: Inline
# ConstructorInitializerIndentWidth: 4
# ContinuationIndentWidth: 4
# DerivePointerAlignment: false
# InsertBraces: true
# InsertNewlineAtEOF: true
# NamespaceIndentation: None
# PointerAlignment: Right
# SpacesBeforeTrailingComments: 1
# UseTab: Never

# TODO: TBD Keep original style? CK
# AlignTrailingComments:
# Kind: Always
# OverEmptyLines: 0

# TODO: TBD Keep original style? CK
# BreakBeforeBraces: Custom
# BraceWrapping:
# AfterNamespace: true

---
# XXX Language: Objective-C
# Implicit supported .mm files.
39 changes: 39 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
Checks: "-*,\
boost-*,\
bugprone-*,\
-bugprone-exception-escape,\
cert-*,\
clang-analyzer-*,\
-cppcoreguidelines-*,\
-cppcoreguidelines-avoid-*,\
-cppcoreguidelines-no-*,\
-cppcoreguidelines-prefere-*,\
-cppcoreguidelines-slicing,\
-cppcoreguidelines-use-*,\
concurrency-*,\
hicpp-*,\
-hicpp-vararg,\
misc-*,\
-misc-include-cleaner,\
-misc-non-private-member-variables-in-classes,\
-misc-unused-parameters,\
modernize-*,\
-modernize-macro-to-enum,\
-modernize-use-trailing-return-type,\
performance-*,\
-performance-avoid-endl,\
portability-*,\
readability-*,\
-readability-identifier-naming,\
-readability-identifier-length,\
-*avoid-c-arrays,\
-*magic-numbers,\
-*named-parameter,\
"
WarningsAsErrors: ''
HeaderFilterRegex: 'chapter.*'
FormatStyle: file
User: CK
...

39 changes: 39 additions & 0 deletions .cmake-format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"format": {
"disable": false,
"line_width": 85,
"tab_size": 4,
"use_tabchars": false,
"fractional_tab_policy": "use-space",
"max_subgroups_hwrap": 4,
"max_pargs_hwrap": 6,
"max_rows_cmdline": 2,
"separate_ctrl_name_with_space": false,
"separate_fn_name_with_space": false,
"dangle_parens": true,
"dangle_align": "prefix",
"min_prefix_chars": 4,
"max_prefix_chars": 10,
"max_lines_hwrap": 2,
"command_case": "lower",
"keyword_case": "upper",
"always_wrap": [
"add-librariy",
"externalproject_add",
"fetchcontent_declare",
"generate_export_header",
"install",
"project",
"set_property",
"set_target_properties",
"target_include_directories",
"target_link_libraries",
"target_sources"
],
"enable_sort": true,
"autosort": false
},
"markup": {
"first_comment_is_literal": true
}
}
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
builtin = clear,rare,en-GB_to_en-US,names,informal,code
check-hidden =
skip = ./.git,./build/*,./prefix/*,./conan/*,./stagedir/*,*.log,.*.swp,*~,*.bak
quiet-level = 2
ignore-words = .ignore-words
6 changes: 3 additions & 3 deletions .github/toolchain/clang-on-windows-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyied from https://github.com/friendlyanon/cmake-init-clang-on-windows
cmake_minimum_required(VERSION 3.13)
# Copyied from https://github.com/friendlyanon/cmake-init-clang-on-windows
cmake_minimum_required(VERSION 3.25...3.30)

set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
Expand Down Expand Up @@ -34,4 +34,4 @@ include_directories(
)

# Tell Clang what version of cl.exe to emulate, so it sets the defines up correctly
add_compile_options("-fms-compatibility-version=${cl_version}")
add_compile_options("-fms-compatibility-version=${cl_version}")
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
ci:
name: ${{ matrix.os }}-${{ matrix.configurePreset}}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: true
fail-fast: false
matrix:
name:
[ubuntu-gcc, ubuntu-clang, macos-appleclang, windows-msvc-22, windows-clang]
Expand Down Expand Up @@ -48,6 +48,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: install-python-3
uses: actions/setup-python@v5
Expand All @@ -57,7 +59,7 @@ jobs:
- name: install-python-deps
run: |
python3 -m pip install --upgrade pip
pip3 install pytest pytest-depends conan cpplint
pip3 install pytest pytest-depends conan cpplint

- name: set-compiler-env
run: |
Expand All @@ -73,7 +75,7 @@ jobs:
brew update
brew install plantuml ninja clang-format llvm
brew install --cask doxygen

ln -s "/usr/local/opt/llvm/bin/clang-tidy" "/usr/local/bin/clang-tidy"

- name: dependencies (windows)
Expand All @@ -83,7 +85,7 @@ jobs:
choco install -y --limit-output doxygen.install --version="1.9.2"
choco install openssl --version 3.1.1 -y
echo "OPENSSL_ROOT_DIR=C:/Program Files/OpenSSL/" >> $GITHUB_ENV

shell: bash

- name: dependencies (debian-like)
Expand All @@ -106,7 +108,7 @@ jobs:
- name: build
run: |
if [ "${{ matrix.buildPreset }}" == "" ]; then
cmake --build ./build
cmake --build ./build
else
cmake --build --preset=${{ matrix.buildPreset }}
fi
Expand All @@ -122,4 +124,4 @@ jobs:
shell: bash

- name: pytest
run: python3 -m pytest -x -v
run: python3 -m pytest -x -v
10 changes: 6 additions & 4 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
linux-coverage:
name: linux-coverage
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: install-python-3
uses: actions/setup-python@v2
Expand All @@ -39,7 +41,7 @@ jobs:

- name: build
run: |
cmake --build ./build
cmake --build ./build
shell: bash

- name: ctest
Expand All @@ -64,7 +66,7 @@ jobs:
path: |
./build/gcov-coverage/
./build/lcov-coverage/

windows-coverage:
name: windows-coverage
runs-on: windows-2022
Expand Down Expand Up @@ -112,4 +114,4 @@ jobs:
with:
name: code-coverage-report
path: |
./build/opencppcoverage
./build/opencppcoverage
12 changes: 5 additions & 7 deletions .github/workflows/cross-compiling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
ios:
name: ios
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: cmake-configure
run: |
Expand All @@ -41,7 +43,7 @@ jobs:
add-to-path: false

- uses: actions/checkout@v4

- name: cmake-configure
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release --toolchain=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
Expand Down Expand Up @@ -82,13 +84,9 @@ jobs:
run: |
cd build
ctest --verbose


- name: run-emulator-bare
run: |
cd build
qemu-arm -L /usr/arm-linux-gnueabihf ./ch12_emulator_example




14 changes: 8 additions & 6 deletions .github/workflows/sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
linux-sanitizers:
name: linux-sanitizers
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: install-python-3
uses: actions/setup-python@v2
Expand All @@ -26,7 +28,7 @@ jobs:
- name: dependencies (debian-like)
run: |
sudo apt -y update
sudo apt -y install ninja-build clang-tidy doxygen plantuml
sudo apt -y install ninja-build clang-tidy doxygen plantuml

- name: install-python-deps
run: |
Expand All @@ -39,14 +41,14 @@ jobs:

- name: build
run: |
cmake --build ./build
cmake --build ./build
shell: bash

- name: ctest
run: |
ctest -V --test-dir build
shell: bash

windows-sanitizers:
name: windows-sanitizers
runs-on: windows-2022
Expand Down Expand Up @@ -88,7 +90,7 @@ jobs:
working-directory: build-sanitizer
run: |
set PATH="%PATH%;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.40.33807\bin\Hostx64\x64;C:\Program Files\CMake\bin"

echo %PATH%
"C:\Program Files\CMake\bin\ctest.exe" -V -C Debug
shell: cmd
shell: cmd
8 changes: 5 additions & 3 deletions .github/workflows/superbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
windows-superbuild:
Expand All @@ -18,7 +18,9 @@ jobs:

steps:
- uses: actions/checkout@v4

with:
submodules: recursive

- name: dependencies (windows)
run: |
choco install -y --limit-output ninja
Expand Down Expand Up @@ -49,5 +51,5 @@ jobs:

- name: build
run: |
cmake --build ./build
cmake --build ./build
working-directory: ./ch10_ex03
9 changes: 6 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "chapter05/conan_conanfile_example/cmake-conan"]
path = chapter05/conan_example/cmake-conan
url = https://github.com/conan-io/cmake-conan.git
# [submodule "chapter05/conan_conanfile_example/cmake-conan"]
# path = chapter05/conan_example/cmake-conan
# url = https://github.com/conan-io/cmake-conan.git
[submodule "Format.cmake"]
path = Format.cmake
url = https://github.com/TheLartians/Format.cmake
3 changes: 3 additions & 0 deletions .ignore-words
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
claus
DEPENDEES
DEPENDERS
Loading
Loading