Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 5eedd7d

Browse files
authored
Add CMake scripts, main.cpp, CI scripts (#1)
1 parent 5a99f1e commit 5eedd7d

File tree

8 files changed

+115
-1
lines changed

8 files changed

+115
-1
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Language: Cpp
33
BasedOnStyle: LLVM
44
AlwaysBreakTemplateDeclarations: Yes
5-
BreakBeforeBraces: Attach
5+
BreakBeforeBraces: Allman
66
ColumnLimit: 160
77
SpaceAfterTemplateKeyword: true
88
Standard: c++20

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Checks: 'clang-analyzer-*,
99
-misc-non-private-member-variables-in-classes,
1010
-misc-no-recursion,
1111
modernize-*,
12+
-modernize-use-trailing-return-type,
1213
performance-*,
1314
portability-*,
1415
readability-*,

.github/format_check_diff.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
[[ ! $(git --version) ]] && exit 1
4+
5+
output=$(git diff)
6+
7+
if [[ "$output" != "" ]]; then
8+
echo -e "One or more source files are not formatted!\n\n$output\n"
9+
echo -e "Using $(clang-format --version)\n"
10+
exit 1
11+
fi
12+
13+
echo "All source files are formatted"
14+
exit

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: ci-push
2+
on: [push]
3+
jobs:
4+
format-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: format code
9+
run: scripts/format_code.sh
10+
- name: check diff
11+
run: .github/format_check_diff.sh
12+
linux-gcc:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: init
17+
run: sudo apt update -yqq; sudo apt install -yqq ninja-build xorg-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules
18+
- name: configure
19+
run: export CC=gcc-14; export CXX=g++-14; cmake -S . --preset=default -B build -DKVF_USE_FREETYPE=OFF
20+
- name: build debug
21+
run: cmake --build build --config=Debug
22+
- name: build release
23+
run: cmake --build build --config=Release
24+
linux-clang:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: init
29+
run: sudo apt update -yqq; sudo apt install -yqq ninja-build xorg-dev libwayland-dev libxkbcommon-dev wayland-protocols extra-cmake-modules
30+
- name: configure
31+
run: cmake -S . --preset=ninja-clang -B build -DKVF_USE_FREETYPE=OFF
32+
- name: build debug
33+
run: cmake --build build --config=Debug
34+
- name: build release
35+
run: cmake --build build --config=Release
36+
windows-vs22:
37+
runs-on: windows-latest
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: configure
41+
run: cmake -S . --preset=vs22 -B build -DKVF_USE_FREETYPE=OFF
42+
- name: build debug
43+
run: cmake --build build --config=Debug
44+
- name: build release
45+
run: cmake --build build --config=Release
46+
windows-clang:
47+
runs-on: windows-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
- name: init
51+
run: choco install ninja
52+
- name: configure
53+
run: cmake -S . --preset=ninja-clang -B build -DKVF_USE_FREETYPE=OFF
54+
- name: build debug
55+
run: cmake --build build --config=Debug
56+
- name: build release
57+
run: cmake --build build --config=Release

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.24)
2+
3+
set(project_name tkge)
4+
project(${project_name})
5+
6+
set(CMAKE_CXX_STANDARD 23)
7+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
8+
set(CMAKE_CXX_EXTENSIONS OFF)
9+
set(CMAKE_DEBUG_POSTFIX "-d")
10+
11+
# TODO
12+
# add_subdirectory(lib)
13+
add_subdirectory(app)

app/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
project(${project_name}-app)
2+
3+
add_executable(${PROJECT_NAME})
4+
5+
file(GLOB_RECURSE sources LIST_DIRECTORIES false "src/*.[hc]pp")
6+
target_sources(${PROJECT_NAME} PRIVATE
7+
${sources}
8+
)

app/src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main() {}

scripts/format_code.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
[[ ! $(clang-format --version) ]] && exit 1
4+
5+
if [[ ! -d ./app ]]; then
6+
echo "Please run script from the project root"
7+
exit 1
8+
fi
9+
10+
files=$(find app -name "*.?pp")
11+
12+
if [[ "$files" == "" ]]; then
13+
echo "-- No source files found"
14+
exit
15+
fi
16+
17+
clang-format -i $files || exit 1
18+
echo -e "-- Formatted Files:\n$files\n"
19+
20+
exit

0 commit comments

Comments
 (0)