Skip to content

Commit f3267ca

Browse files
Initial commit
0 parents  commit f3267ca

24 files changed

Lines changed: 544 additions & 0 deletions

.clang-format

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
BasedOnStyle: Google
2+
BreakBeforeBraces: Stroustrup
3+
IndentWidth: 4
4+
UseTab: Never
5+
TabWidth: 4
6+
AccessModifierOffset: -4
7+
IndentAccessModifiers: false
8+
AlignEscapedNewlines: Right
9+
AlignOperands: DontAlign
10+
AlignTrailingComments:
11+
Kind: Never
12+
AllowShortBlocksOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: Never
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakBeforeMultilineStrings: false
16+
AlwaysBreakTemplateDeclarations: MultiLine
17+
BreakBeforeBinaryOperators: All
18+
BreakConstructorInitializers: BeforeComma
19+
ColumnLimit: 0
20+
Cpp11BracedListStyle: false
21+
DerivePointerAlignment: false
22+
FixNamespaceComments: false
23+
IndentCaseLabels: false
24+
KeepEmptyLinesAtTheStartOfBlocks: true
25+
NamespaceIndentation: Inner
26+
PackConstructorInitializers: BinPack
27+
PenaltyBreakBeforeFirstCallParameter: 19
28+
PenaltyReturnTypeOnItsOwnLine: 60
29+
SpaceBeforeCpp11BracedList: true
30+
SpaceInEmptyBlock: true
31+
SpacesBeforeTrailingComments: 1
32+
Standard: Latest

.clang-tidy

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Checks: >
2+
bugprone-*,
3+
google-*,
4+
misc-*,
5+
modernize-*,
6+
performance-*,
7+
portability-*,
8+
readability-*,
9+
-modernize-use-trailing-return-type
10+
11+
CheckOptions:
12+
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
13+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
14+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
15+
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
16+
- { key: readability-identifier-naming.FunctionCase, value: CamelCase }
17+
- { key: readability-identifier-naming.VariableCase, value: lower_case }
18+
- { key: readability-identifier-naming.PublicMemberCase, value: lower_case }
19+
- { key: readability-identifier-naming.PrivateMemberCase, value: lower_case }
20+
- { key: readability-identifier-naming.ProtectedMemberCase, value: lower_case }
21+
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
22+
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
23+
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
24+
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
25+
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
26+
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
27+
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
28+
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
29+
# Reference: https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html

.clangd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Diagnostics:
2+
UnusedIncludes: Strict
3+
MissingIncludes: Strict

.devcontainer/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM mcr.microsoft.com/devcontainers/cpp:0-ubuntu-22.04
2+
3+
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.22.2"
4+
ARG REINSTALL_LLVM_VERSION="16"
5+
6+
# Optionally install the cmake for vcpkg
7+
COPY ./reinstall-cmake.sh /tmp/
8+
9+
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
10+
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
11+
fi \
12+
&& rm -f /tmp/reinstall-cmake.sh
13+
14+
# [Optional] Uncomment this section to install additional vcpkg ports.
15+
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install <your-port-name-here>"
16+
17+
# [Optional] Uncomment this section to install additional packages.
18+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19+
&& apt-get -y install --no-install-recommends lsb-release wget software-properties-common gnupg
20+
21+
COPY ./reinstall-llvm.sh /tmp/
22+
23+
RUN if [ "${REINSTALL_LLVM_VERSION}" != "none" ]; then \
24+
chmod +x /tmp/reinstall-llvm.sh && /tmp/reinstall-llvm.sh ${REINSTALL_LLVM_VERSION}; \
25+
fi \
26+
&& rm -f /tmp/reinstall-llvm.sh

.devcontainer/devcontainer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13+
// "forwardPorts": [],
14+
15+
// Use 'postCreateCommand' to run commands after the container is created.
16+
// "postCreateCommand": "gcc -v",
17+
18+
// Configure tool-specific properties.
19+
"customizations": {
20+
// Configure properties specific to VS Code.
21+
"vscode": {
22+
// Set *default* container specific settings.json values on container create.
23+
"settings": {
24+
"C_Cpp.intelliSenseEngine": "disabled",
25+
"terminal.integrated.defaultProfile.linux": "zsh",
26+
"cmake.copyCompileCommands": "${workspaceFolder}/compile_commands.json",
27+
"cmake.configureOnOpen": true,
28+
"cmake.generator": "Ninja",
29+
"cmake.configureSettings": {
30+
"CMAKE_TOOLCHAIN_FILE": "/usr/local/vcpkg/scripts/buildsystems/vcpkg.cmake"
31+
}
32+
},
33+
"extensions": [
34+
"llvm-vs-code-extensions.vscode-clangd",
35+
"ms-vscode.cmake-tools", // Reference: https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md
36+
"ms-vscode.cpptools",
37+
"matepek.vscode-catch2-test-adapter",
38+
"cschlosser.doxdocgen"
39+
]
40+
}
41+
}
42+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
43+
// "remoteUser": "root"
44+
}

.devcontainer/reinstall-cmake.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
set -e
8+
9+
CMAKE_VERSION=${1:-"none"}
10+
11+
if [ "${CMAKE_VERSION}" = "none" ]; then
12+
echo "No CMake version specified, skipping CMake reinstallation"
13+
exit 0
14+
fi
15+
16+
# Cleanup temporary directory and associated files when exiting the script.
17+
cleanup() {
18+
EXIT_CODE=$?
19+
set +e
20+
if [[ -n "${TMP_DIR}" ]]; then
21+
echo "Executing cleanup of tmp files"
22+
rm -Rf "${TMP_DIR}"
23+
fi
24+
exit $EXIT_CODE
25+
}
26+
trap cleanup EXIT
27+
28+
29+
echo "Installing CMake..."
30+
apt-get -y purge --auto-remove cmake
31+
mkdir -p /opt/cmake
32+
33+
architecture=$(dpkg --print-architecture)
34+
case "${architecture}" in
35+
arm64)
36+
ARCH=aarch64 ;;
37+
amd64)
38+
ARCH=x86_64 ;;
39+
*)
40+
echo "Unsupported architecture ${architecture}."
41+
exit 1
42+
;;
43+
esac
44+
45+
CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
46+
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
47+
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)
48+
49+
echo "${TMP_DIR}"
50+
cd "${TMP_DIR}"
51+
52+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
53+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O
54+
55+
sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
56+
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license
57+
58+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
59+
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest

.devcontainer/reinstall-llvm.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
LLVM_VERSION=${1:-"none"}
5+
6+
if [ "${LLVM_VERSION}" = "none" ]; then
7+
echo "No LLVM version specified, skipping LLVM reinstallation"
8+
exit 0
9+
fi
10+
11+
echo "Installing LLVM..."
12+
apt-get -y purge --auto-remove "llvm*"
13+
mkdir -p /opt/llvm
14+
cd /opt/llvm
15+
wget https://apt.llvm.org/llvm.sh
16+
chmod +x llvm.sh
17+
./llvm.sh ${LLVM_VERSION} all
18+
19+
llvm_dir="/usr/lib/llvm-${LLVM_VERSION}/bin"
20+
usr_local_dir="/usr/local/bin"
21+
22+
# Loop through each file in the input directory
23+
for file in "$llvm_dir"/*
24+
do
25+
# Check if the file is a binary
26+
if [[ -x "$file" && -f "$file" ]]; then
27+
# Get the file name and create the symbolic link in the output directory
28+
file_name=$(basename "$file")
29+
ln -s "$file" "$usr_local_dir/$file_name"
30+
fi
31+
done

.github/workflows/codeql.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '36 16 * * 6'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'cpp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Use only 'java' to analyze code written in Java, Kotlin or both
38+
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
39+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v3
44+
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v2
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
54+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
55+
# queries: security-extended,security-and-quality
56+
- name: Install VCPKG
57+
run: |
58+
git clone https://github.com/microsoft/vcpkg
59+
60+
- name: Set reusable strings
61+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
62+
id: strings
63+
shell: bash
64+
run: |
65+
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
66+
67+
- name: Configure CMake
68+
run: >
69+
cmake -B ${{ steps.strings.outputs.build-output-dir }}
70+
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake
71+
-S ${{ github.workspace }}
72+
73+
- name: Build
74+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }}
75+
76+
- name: Perform CodeQL Analysis
77+
uses: github/codeql-action/analyze@v2
78+
with:
79+
category: "/language:${{matrix.language}}"

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
# Build directory
35+
build/*
36+
37+
compile_commands.json
38+
39+
# Clangd cache
40+
.cache/*

.vscode/launch.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "(gdb) Launch",
6+
"type": "cppdbg",
7+
"request": "launch",
8+
// Resolved by CMake Tools:
9+
"program": "${command:cmake.launchTargetPath}",
10+
"args": [],
11+
"stopAtEntry": false,
12+
"cwd": "${workspaceFolder}",
13+
"environment": [
14+
{
15+
// add the directory where our target was built to the PATHs
16+
// it gets resolved by CMake Tools:
17+
"name": "PATH",
18+
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
19+
},
20+
// {
21+
// "name": "OTHER_VALUE",
22+
// "value": "Something something"
23+
// }
24+
],
25+
"externalConsole": false,
26+
"MIMode": "gdb",
27+
"setupCommands": [
28+
{
29+
"description": "Enable pretty-printing for gdb",
30+
"text": "-enable-pretty-printing",
31+
"ignoreFailures": true
32+
},
33+
{
34+
"description": "Set Disassembly Flavor to Intel",
35+
"text": "-gdb-set disassembly-flavor intel",
36+
"ignoreFailures": true
37+
}
38+
]
39+
}
40+
]
41+
}

0 commit comments

Comments
 (0)