Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
FrogTheFrog committed Aug 12, 2023
0 parents commit d18fb48
Show file tree
Hide file tree
Showing 20 changed files with 1,479 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
AccessModifierOffset: '-4'
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: 'true'
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Right
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'true'
AllowAllConstructorInitializersOnNextLine: 'false'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'true'
BinPackParameters: 'true'
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: 'true'
ColumnLimit: '120'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
ConstructorInitializerIndentWidth: '4'
ContinuationIndentWidth: '4'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'true'
IndentPPDirectives: BeforeHash
#IndentRequiresClause: 'false'
IndentWidth: '4'
IndentWrappedFunctionNames: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: 'true'
#RequiresClausePosition: WithPreceding
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '2'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never
...
41 changes: 41 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build
on: [pull_request,workflow_call]
jobs:
Formatting:
uses: ./.github/workflows/formatting.yaml

Filename:
uses: ./.github/workflows/filename.yaml
with:
original_event_name: "${{ github.event_name }}"

Windows:
runs-on: windows-latest
needs: [Formatting, Filename]
steps:
- name: Install MSCV
uses: ilammy/msvc-dev-cmd@v1

- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure
run: cmake -DCMAKE_BUILD_TYPE:STRING=Release -B build -G Ninja

- name: Build
run: cmake --build build

- name: Rename
working-directory: ./build/src
run: mv gsynctoggle.exe ${{ needs.Filename.outputs.filename }}.exe

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: ./build/src/gsynctoggle*exe
retention-days: 1
if-no-files-found: error

38 changes: 38 additions & 0 deletions .github/workflows/filename.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Generate binary filename
on:
workflow_call:
inputs:
original_event_name:
required: true
type: string
outputs:
filename:
value: ${{ jobs.Filename.outputs.filename }}

jobs:
Filename:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.name }}
hash: ${{ steps.hash.outputs.name }}
filename: ${{ steps.filename.outputs.name }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Using the CMakeLists version
if: inputs.original_event_name != 'pull_request'
id: version
run: echo "name=$(grep -E "\s+VERSION" CMakeLists.txt | xargs | cut -d' ' -f 2)" >> $GITHUB_OUTPUT

- name: Using the commit SHA as a version
if: inputs.original_event_name == 'pull_request'
id: hash
run: echo "name=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_OUTPUT

- name: Generate name
id: filename
run: echo "name=gsynctoggle-${{ steps.version.outputs.name }}${{ steps.hash.outputs.name }}-x86_64" >> $GITHUB_OUTPUT

- name: Print the filename base
run: echo "${{ steps.filename.outputs.name }}"
11 changes: 11 additions & 0 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Formatting check
on: [workflow_call]
jobs:
Formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Clang-format check
run: find $PWD/src -type f \( -name "*.h" -o -name "*.cpp" \) -exec clang-format -style=file --dry-run --Werror {} +
52 changes: 52 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish
on:
push:
branches:
- main
jobs:
Build:
uses: ./.github/workflows/build.yaml

Publish:
runs-on: ubuntu-latest
needs: [Build]
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || echo "No tags fetched"

- name: Get project version
id: project_version
run: echo "VERSION=$(grep -E "\s+VERSION" CMakeLists.txt | xargs | cut -d' ' -f 2)" >> $GITHUB_OUTPUT

- name: Get tag status
id: tagstatus
run: echo "TAG_EXISTS=$(git show-ref --tags --verify --quiet -- 'refs/tags/v${{ steps.project_version.outputs.VERSION }}' && echo 1 || echo 0)" >> $GITHUB_OUTPUT

- name: Print version and status
run: |
echo "Version: ${{ steps.project_version.outputs.VERSION }}"
echo "Aready exists: ${{ steps.tagstatus.outputs.TAG_EXISTS }}"
- name: Download artifacts
uses: actions/download-artifact@v3
if: steps.tagstatus.outputs.TAG_EXISTS == 0
with:
name: dist
path: dist

- name: Tag release
uses: rickstaa/action-create-tag@v1
if: steps.tagstatus.outputs.TAG_EXISTS == 0
with:
tag: "v${{ steps.project_version.outputs.VERSION }}"

- name: Release
uses: softprops/action-gh-release@v1
if: steps.tagstatus.outputs.TAG_EXISTS == 0
with:
tag_name: "v${{ steps.project_version.outputs.VERSION }}"
files: dist/*
draft: true
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
#external
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "externals/nvapi-open-source-sdk"]
path = externals/nvapi-open-source-sdk
url = https://github.com/LizardByte/nvapi-open-source-sdk
branch = sdk
92 changes: 92 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"files.associations": {
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocinfo": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"chrono": "cpp",
"typeindex": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cwctype": "cpp",
"any": "cpp",
"array": "cpp",
"strstream": "cpp",
"*.tcc": "cpp",
"bitset": "cpp",
"charconv": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"deque": "cpp",
"set": "cpp",
"string": "cpp",
"algorithm": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"optional": "cpp",
"random": "cpp",
"source_location": "cpp",
"string_view": "cpp",
"format": "cpp",
"future": "cpp",
"iomanip": "cpp",
"numbers": "cpp",
"semaphore": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"cinttypes": "cpp",
"variant": "cpp"
}
}
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#----------------------------------------------------------------------------------------------------------------------
# Project config
#----------------------------------------------------------------------------------------------------------------------

cmake_minimum_required(VERSION 3.21)
project(gsynctoggle
VERSION 1.0.0
DESCRIPTION "Command line app for Windows to toggle GSync."
HOMEPAGE_URL "https://github.com/FrogTheFrog/gsync-toggle"
LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#----------------------------------------------------------------------------------------------------------------------
# Compile settings
#----------------------------------------------------------------------------------------------------------------------

if(MSVC)
# warning level 4 and all warnings as errors
add_compile_options(/W4 /WX)
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()

#----------------------------------------------------------------------------------------------------------------------
# Subdirectories
#----------------------------------------------------------------------------------------------------------------------

add_subdirectory(src)
Loading

0 comments on commit d18fb48

Please sign in to comment.