Skip to content

Commit d18fb48

Browse files
committed
Initial commit
0 parents  commit d18fb48

20 files changed

Lines changed: 1479 additions & 0 deletions

.clang-format

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
AccessModifierOffset: '-4'
3+
AlignAfterOpenBracket: Align
4+
AlignConsecutiveMacros: 'true'
5+
AlignConsecutiveAssignments: 'true'
6+
AlignConsecutiveDeclarations: 'true'
7+
AlignEscapedNewlines: Right
8+
AlignOperands: 'true'
9+
AlignTrailingComments: 'true'
10+
AllowAllArgumentsOnNextLine: 'true'
11+
AllowAllConstructorInitializersOnNextLine: 'false'
12+
AllowAllParametersOfDeclarationOnNextLine: 'false'
13+
AllowShortBlocksOnASingleLine: 'false'
14+
AllowShortCaseLabelsOnASingleLine: 'false'
15+
AllowShortFunctionsOnASingleLine: None
16+
AllowShortIfStatementsOnASingleLine: Never
17+
AllowShortLambdasOnASingleLine: All
18+
AllowShortLoopsOnASingleLine: 'false'
19+
AlwaysBreakAfterReturnType: None
20+
AlwaysBreakBeforeMultilineStrings: 'false'
21+
AlwaysBreakTemplateDeclarations: 'Yes'
22+
BinPackArguments: 'true'
23+
BinPackParameters: 'true'
24+
BreakBeforeBinaryOperators: NonAssignment
25+
BreakBeforeBraces: Allman
26+
BreakBeforeTernaryOperators: 'true'
27+
BreakConstructorInitializers: BeforeComma
28+
BreakInheritanceList: BeforeComma
29+
BreakStringLiterals: 'true'
30+
ColumnLimit: '120'
31+
CompactNamespaces: 'false'
32+
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
33+
ConstructorInitializerIndentWidth: '4'
34+
ContinuationIndentWidth: '4'
35+
Cpp11BracedListStyle: 'true'
36+
DerivePointerAlignment: 'false'
37+
FixNamespaceComments: 'true'
38+
IncludeBlocks: Preserve
39+
IndentCaseLabels: 'true'
40+
IndentPPDirectives: BeforeHash
41+
#IndentRequiresClause: 'false'
42+
IndentWidth: '4'
43+
IndentWrappedFunctionNames: 'true'
44+
KeepEmptyLinesAtTheStartOfBlocks: 'false'
45+
Language: Cpp
46+
MaxEmptyLinesToKeep: '1'
47+
NamespaceIndentation: None
48+
PointerAlignment: Left
49+
ReflowComments: 'true'
50+
#RequiresClausePosition: WithPreceding
51+
SortIncludes: 'true'
52+
SortUsingDeclarations: 'true'
53+
SpaceAfterCStyleCast: 'false'
54+
SpaceAfterLogicalNot: 'false'
55+
SpaceAfterTemplateKeyword: 'false'
56+
SpaceBeforeAssignmentOperators: 'true'
57+
SpaceBeforeCpp11BracedList: 'false'
58+
SpaceBeforeCtorInitializerColon: 'true'
59+
SpaceBeforeInheritanceColon: 'true'
60+
SpaceBeforeParens: ControlStatements
61+
SpaceBeforeRangeBasedForLoopColon: 'true'
62+
SpaceInEmptyParentheses: 'false'
63+
SpacesBeforeTrailingComments: '2'
64+
SpacesInAngles: 'false'
65+
SpacesInCStyleCastParentheses: 'false'
66+
SpacesInContainerLiterals: 'false'
67+
SpacesInParentheses: 'false'
68+
SpacesInSquareBrackets: 'false'
69+
Standard: Cpp11
70+
TabWidth: '4'
71+
UseTab: Never
72+
...

.github/workflows/build.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build
2+
on: [pull_request,workflow_call]
3+
jobs:
4+
Formatting:
5+
uses: ./.github/workflows/formatting.yaml
6+
7+
Filename:
8+
uses: ./.github/workflows/filename.yaml
9+
with:
10+
original_event_name: "${{ github.event_name }}"
11+
12+
Windows:
13+
runs-on: windows-latest
14+
needs: [Formatting, Filename]
15+
steps:
16+
- name: Install MSCV
17+
uses: ilammy/msvc-dev-cmd@v1
18+
19+
- name: Checkout
20+
uses: actions/checkout@v3
21+
with:
22+
submodules: recursive
23+
24+
- name: Configure
25+
run: cmake -DCMAKE_BUILD_TYPE:STRING=Release -B build -G Ninja
26+
27+
- name: Build
28+
run: cmake --build build
29+
30+
- name: Rename
31+
working-directory: ./build/src
32+
run: mv gsynctoggle.exe ${{ needs.Filename.outputs.filename }}.exe
33+
34+
- name: Upload artifacts
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: dist
38+
path: ./build/src/gsynctoggle*exe
39+
retention-days: 1
40+
if-no-files-found: error
41+

.github/workflows/filename.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Generate binary filename
2+
on:
3+
workflow_call:
4+
inputs:
5+
original_event_name:
6+
required: true
7+
type: string
8+
outputs:
9+
filename:
10+
value: ${{ jobs.Filename.outputs.filename }}
11+
12+
jobs:
13+
Filename:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
version: ${{ steps.version.outputs.name }}
17+
hash: ${{ steps.hash.outputs.name }}
18+
filename: ${{ steps.filename.outputs.name }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
23+
- name: Using the CMakeLists version
24+
if: inputs.original_event_name != 'pull_request'
25+
id: version
26+
run: echo "name=$(grep -E "\s+VERSION" CMakeLists.txt | xargs | cut -d' ' -f 2)" >> $GITHUB_OUTPUT
27+
28+
- name: Using the commit SHA as a version
29+
if: inputs.original_event_name == 'pull_request'
30+
id: hash
31+
run: echo "name=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT
32+
33+
- name: Generate name
34+
id: filename
35+
run: echo "name=gsynctoggle-${{ steps.version.outputs.name }}${{ steps.hash.outputs.name }}-x86_64" >> $GITHUB_OUTPUT
36+
37+
- name: Print the filename base
38+
run: echo "${{ steps.filename.outputs.name }}"

.github/workflows/formatting.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Formatting check
2+
on: [workflow_call]
3+
jobs:
4+
Formatting:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v3
9+
10+
- name: Clang-format check
11+
run: find $PWD/src -type f \( -name "*.h" -o -name "*.cpp" \) -exec clang-format -style=file --dry-run --Werror {} +

.github/workflows/publish.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
Build:
8+
uses: ./.github/workflows/build.yaml
9+
10+
Publish:
11+
runs-on: ubuntu-latest
12+
needs: [Build]
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Fetch tags
18+
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || echo "No tags fetched"
19+
20+
- name: Get project version
21+
id: project_version
22+
run: echo "VERSION=$(grep -E "\s+VERSION" CMakeLists.txt | xargs | cut -d' ' -f 2)" >> $GITHUB_OUTPUT
23+
24+
- name: Get tag status
25+
id: tagstatus
26+
run: echo "TAG_EXISTS=$(git show-ref --tags --verify --quiet -- 'refs/tags/v${{ steps.project_version.outputs.VERSION }}' && echo 1 || echo 0)" >> $GITHUB_OUTPUT
27+
28+
- name: Print version and status
29+
run: |
30+
echo "Version: ${{ steps.project_version.outputs.VERSION }}"
31+
echo "Aready exists: ${{ steps.tagstatus.outputs.TAG_EXISTS }}"
32+
33+
- name: Download artifacts
34+
uses: actions/download-artifact@v3
35+
if: steps.tagstatus.outputs.TAG_EXISTS == 0
36+
with:
37+
name: dist
38+
path: dist
39+
40+
- name: Tag release
41+
uses: rickstaa/action-create-tag@v1
42+
if: steps.tagstatus.outputs.TAG_EXISTS == 0
43+
with:
44+
tag: "v${{ steps.project_version.outputs.VERSION }}"
45+
46+
- name: Release
47+
uses: softprops/action-gh-release@v1
48+
if: steps.tagstatus.outputs.TAG_EXISTS == 0
49+
with:
50+
tag_name: "v${{ steps.project_version.outputs.VERSION }}"
51+
files: dist/*
52+
draft: true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
#external

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "externals/nvapi-open-source-sdk"]
2+
path = externals/nvapi-open-source-sdk
3+
url = https://github.com/LizardByte/nvapi-open-source-sdk
4+
branch = sdk

.vscode/settings.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"files.associations": {
3+
"atomic": "cpp",
4+
"bit": "cpp",
5+
"cctype": "cpp",
6+
"clocale": "cpp",
7+
"cmath": "cpp",
8+
"compare": "cpp",
9+
"concepts": "cpp",
10+
"cstddef": "cpp",
11+
"cstdint": "cpp",
12+
"cstdio": "cpp",
13+
"cstdlib": "cpp",
14+
"cstring": "cpp",
15+
"ctime": "cpp",
16+
"cwchar": "cpp",
17+
"exception": "cpp",
18+
"functional": "cpp",
19+
"initializer_list": "cpp",
20+
"ios": "cpp",
21+
"iosfwd": "cpp",
22+
"iostream": "cpp",
23+
"istream": "cpp",
24+
"iterator": "cpp",
25+
"limits": "cpp",
26+
"list": "cpp",
27+
"map": "cpp",
28+
"memory": "cpp",
29+
"mutex": "cpp",
30+
"new": "cpp",
31+
"ostream": "cpp",
32+
"ratio": "cpp",
33+
"stdexcept": "cpp",
34+
"stop_token": "cpp",
35+
"streambuf": "cpp",
36+
"system_error": "cpp",
37+
"thread": "cpp",
38+
"tuple": "cpp",
39+
"type_traits": "cpp",
40+
"typeinfo": "cpp",
41+
"unordered_map": "cpp",
42+
"utility": "cpp",
43+
"vector": "cpp",
44+
"xfacet": "cpp",
45+
"xhash": "cpp",
46+
"xiosbase": "cpp",
47+
"xlocale": "cpp",
48+
"xlocinfo": "cpp",
49+
"xlocnum": "cpp",
50+
"xmemory": "cpp",
51+
"xstddef": "cpp",
52+
"xstring": "cpp",
53+
"xtr1common": "cpp",
54+
"xtree": "cpp",
55+
"xutility": "cpp",
56+
"chrono": "cpp",
57+
"typeindex": "cpp",
58+
"csignal": "cpp",
59+
"cstdarg": "cpp",
60+
"cwctype": "cpp",
61+
"any": "cpp",
62+
"array": "cpp",
63+
"strstream": "cpp",
64+
"*.tcc": "cpp",
65+
"bitset": "cpp",
66+
"charconv": "cpp",
67+
"codecvt": "cpp",
68+
"complex": "cpp",
69+
"condition_variable": "cpp",
70+
"coroutine": "cpp",
71+
"deque": "cpp",
72+
"set": "cpp",
73+
"string": "cpp",
74+
"algorithm": "cpp",
75+
"memory_resource": "cpp",
76+
"numeric": "cpp",
77+
"optional": "cpp",
78+
"random": "cpp",
79+
"source_location": "cpp",
80+
"string_view": "cpp",
81+
"format": "cpp",
82+
"future": "cpp",
83+
"iomanip": "cpp",
84+
"numbers": "cpp",
85+
"semaphore": "cpp",
86+
"shared_mutex": "cpp",
87+
"span": "cpp",
88+
"sstream": "cpp",
89+
"cinttypes": "cpp",
90+
"variant": "cpp"
91+
}
92+
}

CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#----------------------------------------------------------------------------------------------------------------------
2+
# Project config
3+
#----------------------------------------------------------------------------------------------------------------------
4+
5+
cmake_minimum_required(VERSION 3.21)
6+
project(gsynctoggle
7+
VERSION 1.0.0
8+
DESCRIPTION "Command line app for Windows to toggle GSync."
9+
HOMEPAGE_URL "https://github.com/FrogTheFrog/gsync-toggle"
10+
LANGUAGES C CXX)
11+
12+
set(CMAKE_CXX_STANDARD 20)
13+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
15+
16+
#----------------------------------------------------------------------------------------------------------------------
17+
# Compile settings
18+
#----------------------------------------------------------------------------------------------------------------------
19+
20+
if(MSVC)
21+
# warning level 4 and all warnings as errors
22+
add_compile_options(/W4 /WX)
23+
else()
24+
# lots of warnings and all warnings as errors
25+
add_compile_options(-Wall -Wextra -pedantic -Werror)
26+
endif()
27+
28+
#----------------------------------------------------------------------------------------------------------------------
29+
# Subdirectories
30+
#----------------------------------------------------------------------------------------------------------------------
31+
32+
add_subdirectory(src)

0 commit comments

Comments
 (0)