Skip to content

Commit 1f63205

Browse files
committed
chore: init repo
0 parents  commit 1f63205

19 files changed

+456
-0
lines changed

.clang-format

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Language: Cpp
2+
BasedOnStyle: Google
3+
IndentWidth: 4
4+
5+
AccessModifierOffset: -4
6+
AlignAfterOpenBracket: DontAlign
7+
8+
AllowShortBlocksOnASingleLine: Never
9+
AllowShortFunctionsOnASingleLine: Empty
10+
AllowShortIfStatementsOnASingleLine: Never
11+
AllowShortLambdasOnASingleLine: Empty
12+
13+
AlwaysBreakTemplateDeclarations: Yes
14+
BreakBeforeTernaryOperators: true
15+
BreakStringLiterals: false
16+
ColumnLimit: 120
17+
CompactNamespaces: false
18+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
19+
ConstructorInitializerIndentWidth: 8
20+
ContinuationIndentWidth: 8
21+
Cpp11BracedListStyle: true
22+
FixNamespaceComments: true
23+
IncludeBlocks: Preserve
24+
IndentCaseBlocks: false
25+
IndentCaseLabels: true
26+
IndentGotoLabels: false
27+
PointerAlignment: Left
28+
ReflowComments: true
29+
SortUsingDeclarations: true
30+
UseTab: Never

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Checks: "-*, cppcoreguidelines-init-variables,cppcoreguidelines-narrowing-conversions,performance-inefficient-string-concatenation,performance-faster-string-find,performance-inefficient-vector-operation,bugprone-suspicious-include,bugprone-macro-parentheses,bugprone-integer-division,cppcoreguidelines-pro-bounds-constant-array-index,readability-string-compare,performance-for-range-copy,bugprone-use-after-move,bugprone-string-integer-assignment,readability-avoid-const-params-in-decls -warnings-as-errors=bugprone-copy-constructor-init,bugprone-dangling-handle,bugprone-dynamic-static-initializers,bugprone-fold-init-type,bugprone-implicit-widening-of-multiplication-result,bugprone-integer-division,bugprone-macro-parentheses,bugprone-macro-repeated-side-effects,bugprone-unhandled-self-assignment,bugprone-use-after-move,cppcoreguidelines-init-variables,readability-qualified-auto,readability-static-accessed-through-instance,bugprone-suspicious-include"

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
charset = utf-8
9+
indent_size = 4
10+
indent_style = space
11+
12+
[*.yml]
13+
charset = utf-8
14+
indent_style = space
15+
indent_size = 2
16+
17+
[Makefile]
18+
indent_style = tab

.github/workflows/clang_format.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Clang Format
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
clang-format:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- uses: DoozyX/[email protected]
20+
with:
21+
source: "."
22+
exclude: "./build"
23+
extensions: "h,hpp,c,cc,cpp"
24+
clangFormatVersion: 13

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Create Release
17+
id: create_release
18+
uses: actions/create-release@v1
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
tag_name: ${{ github.ref }}
23+
release_name: ${{ github.ref }}
24+
draft: false
25+
prerelease: false

.github/workflows/test.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# yaml-language-server: $schema=https://json-schema.org/draft-07/schema#
2+
name: Test
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
pull_request:
9+
branches:
10+
- main
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest]
19+
20+
steps:
21+
- name: Checkout codebase
22+
uses: actions/checkout@v2
23+
24+
- name: Setup cmake
25+
uses: jwlawson/actions-setup-cmake@v1
26+
with:
27+
cmake-version: "3.22.x"
28+
29+
- name: Install LLVM and Clang
30+
uses: KyleMayes/install-llvm-action@v1
31+
with:
32+
version: "14.0"
33+
34+
- name: Build
35+
run: |
36+
export CC=clang
37+
export CXX=clang++
38+
make tests
39+
40+
- name: Unit Test
41+
run: |
42+
make unittest
43+
44+
- name: GCOVR Analysis
45+
if: contains(matrix.os, 'ubuntu')
46+
run: |
47+
pip install gcovr==5.0
48+
bash -e gcovr.sh
49+
50+
- name: upload coverage artifact
51+
if: contains(matrix.os, 'ubuntu')
52+
uses: actions/upload-artifact@v2
53+
with:
54+
name: coverage
55+
path: .coverage
56+
57+
- name: Upload coverage to CodeCov
58+
if: contains(matrix.os, 'ubuntu')
59+
uses: codecov/codecov-action@v2
60+
with:
61+
files: .coverage/coverage.xml
62+
verbose: true
63+
64+
benchmark:
65+
runs-on: ${{ matrix.os }}
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
os: [ubuntu-latest, macos-latest]
70+
71+
steps:
72+
- name: Checkout codebase
73+
uses: actions/checkout@v2
74+
75+
- name: Setup cmake
76+
uses: jwlawson/actions-setup-cmake@v1
77+
with:
78+
cmake-version: "3.22.x"
79+
80+
- name: Install LLVM and Clang
81+
uses: KyleMayes/install-llvm-action@v1
82+
with:
83+
version: "13.0"
84+
85+
- name: Build
86+
run: |
87+
export CC=clang
88+
export CXX=clang++
89+
make tests
90+
91+
- name: Benchmark
92+
run: |
93+
make benchmark

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
3+
.coverage
4+
build

.vscode/settings.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"editor.tabSize": 4,
3+
"editor.insertSpaces": true,
4+
"editor.formatOnSave": true,
5+
"files.trimTrailingWhitespace": true,
6+
"files.insertFinalNewline": true,
7+
"files.trimFinalNewlines": true,
8+
"clangd.arguments": [
9+
"--compile-commands-dir=./build",
10+
"--background-index",
11+
"--header-insertion=iwyu",
12+
"--all-scopes-completion",
13+
"--completion-style=detailed",
14+
"--cross-file-rename",
15+
"--enable-config",
16+
"--pretty",
17+
"--clang-tidy",
18+
"--pch-storage=memory",
19+
],
20+
"editor.semanticTokenColorCustomizations": {
21+
"enabled": true,
22+
"rules": {
23+
"comment": "#505050",
24+
}
25+
},
26+
"cSpell.words": [
27+
"cmake",
28+
"codecov",
29+
"GCOVR"
30+
]
31+
}

CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
option(starter_cpp_build_tests "Build all of snapshot's own tests." OFF)
2+
3+
cmake_minimum_required(VERSION 3.14)
4+
5+
project(autowired-cpp VERSION 0.0.0)
6+
7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
set(CMAKE_CXX_EXTENSIONS OFF)
10+
11+
# place binaries and libraries according to GNU standards
12+
include(GNUInstallDirs)
13+
14+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
15+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
16+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
17+
18+
include_directories(
19+
${PROJECT_SOURCE_DIR}/include/
20+
)
21+
22+
add_library(autowired-cpp INTERFACE)
23+
target_include_directories(autowired-cpp INTERFACE ${PROJECT_SOURCE_DIR}/include/)
24+
25+
if (starter_cpp_build_tests)
26+
27+
enable_testing()
28+
29+
add_subdirectory(test/)
30+
31+
endif()

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Dup4
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
all:
3+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=1
4+
cmake --build build -j
5+
6+
debug:
7+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1
8+
cmake --build build -j
9+
10+
tests:
11+
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_TESTING=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -Dstarter_cpp_build_tests=ON
12+
cmake --build build -j
13+
14+
unittest:
15+
find ./build/test -name "*.gcda" -print0 | xargs -0 rm
16+
./build/bin/unit_test
17+
18+
benchmark:
19+
find ./build/test -name "*.gcda" -print0 | xargs -0 rm
20+
./build/bin/unit_benchmark
21+
22+
.PHONY: clean
23+
clean:
24+
rm -rf ./build

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<img align="right" width="96px" src="./assets/1200px_cpp_logo.svg.png">
2+
3+
# autowired-cpp
4+
5+
[![Clang Format](https://github.com/Dup4/autowired-cpp/workflows/Clang%20Format/badge.svg)](https://github.com/Dup4/snapshot-cpp/actions/workflows/clang_format.yml)
6+
[![Test](https://github.com/Dup4/autowired-cpp/workflows/Test/badge.svg)](https://github.com/Dup4/snapshot-cpp/actions/workflows/test.yml)
7+
[![codecov](https://codecov.io/gh/Dup4/autowired-cpp/branch/main/graph/badge.svg)](https://codecov.io/gh/Dup4/autowired-cpp)

assets/1200px_cpp_logo.svg.png

68.6 KB
Loading

gcovr.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/bash
2+
3+
TOP_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
4+
5+
export COVERAGE_FOLDER=${TOP_DIR}/.coverage
6+
export HTML_RESULT_PATH="${COVERAGE_FOLDER}/html_result"
7+
8+
if [[ -z "$(which gcovr)" ]]; then
9+
echo "need gcovr"
10+
exit 1
11+
fi
12+
13+
if [[ -d "${COVERAGE_FOLDER}" ]]; then
14+
rm -rf "${COVERAGE_FOLDER}"
15+
fi
16+
17+
mkdir "${COVERAGE_FOLDER}"
18+
mkdir "${HTML_RESULT_PATH}"
19+
20+
gcovr -r . \
21+
--branches \
22+
--filter=".*/autowired-cpp/.*" \
23+
--html-details "${HTML_RESULT_PATH}"/index.html \
24+
--xml-pretty -o "${COVERAGE_FOLDER}"/coverage.xml \
25+
--gcov-executable="llvm-cov gcov"

http_server_for_unittest.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/bash
2+
3+
TOP_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
4+
5+
if [[ -z "$(which python)" ]]; then
6+
echo "need python."
7+
exit 1
8+
fi
9+
10+
REPORT_FOLDER="${TOP_DIR}/.coverage/html_result"
11+
12+
if [[ ! -d "${REPORT_FOLDER}" ]]; then
13+
echo "report not exist"
14+
exit 1
15+
fi
16+
17+
cd "${REPORT_FOLDER}" || exit 1
18+
19+
PORT=8081
20+
21+
if [[ -n "${1}" ]]; then
22+
PORT="${1}"
23+
fi
24+
25+
exec python3 -m http.server "${PORT}"

include/starter-cpp/hello_world.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef HELLO_WORLD_HPP
2+
#define HELLO_WORLD_HPP
3+
4+
#include <string>
5+
6+
inline std::string HelloWorld() {
7+
return "Hello World";
8+
}
9+
10+
#endif // HELLO_WORLD_HPP

0 commit comments

Comments
 (0)