Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev -> main #1

Merged
merged 24 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
c6755d7
fix: :bug: fix GetProcAddress invocation (windows); add in-class init…
Nov 3, 2023
6b63c3b
fix: :bug: link commands to saber library to inherit utility methods
Dec 10, 2023
e27f285
style: :art: update .clang-format
Dec 10, 2023
a28557e
ci: :construction_worker: add ci
Dec 10, 2023
6705397
fix: :bug: fix dlerror being used in windows context
Dec 10, 2023
aa7287a
ci: :construction_worker: use g++-12 for ubuntu runner
Dec 10, 2023
e48b166
ci: :construction_worker: use ubuntu-22.04 runner and g++-10; edit ar…
Dec 10, 2023
589b122
ci: :bug: fix var usage
Dec 10, 2023
313c7ef
feat: :sparkles: add commands; add ekizu debug logging
Dec 10, 2023
e3212ad
ci: :construction_worker: use installed gcc version; update to g++-12
Dec 10, 2023
c4d13fa
fix: :bug: add <numeric> header for failing windows builds; clean up …
Dec 10, 2023
50c41ea
fix: :bug: fix unknown symbol on windows; edit COMMAND_ALLOC and COMM…
Dec 10, 2023
3ba82f7
fix: :bug: rename beep command to ping; add saber namespace in case i…
Dec 10, 2023
5c261e8
ci: :green_heart: use same runners as build job
Dec 10, 2023
580956e
ci: :green_heart: all matrix jobs must pass; release should only happ…
Dec 11, 2023
55bbff2
ci: :green_heart: pass next tag to upload job
Dec 11, 2023
984692b
ci: :green_heart: fix artifact not being found
Dec 11, 2023
846b180
ci: :green_heart: specify download path
Dec 11, 2023
96e184d
ci: :green_heart: maybe download-path is the artifact?
Dec 11, 2023
b120762
ci: :construction_worker: add binary rename step; remove matrix requi…
Dec 11, 2023
a960d58
ci: :construction_worker: add main branch to ci; compare dev/prod tag…
Dec 11, 2023
460ba0c
ci: :construction_worker: add change detection for job conditional ex…
Dec 11, 2023
729e9ac
refactor: :necktie: exit early if DISCORD_TOKEN is not provided
Dec 11, 2023
56f7187
ci: :green_heart: change base path
Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 11 additions & 110 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,113 +1,14 @@
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 80
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false

ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH

IncludeBlocks: Preserve
IncludeCategories:
- Regex: ".*"
Priority: 1
IncludeIsMainRegex: "(Test)?$"
IndentCaseLabels: false
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 8
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 8
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true

# Taken from git's rules
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60

PointerAlignment: Right
ReflowComments: false
TabWidth: 4
UseTab: Always
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortLambdasOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatementsExceptForEachMacros
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 8
UseTab: Always
PenaltyIndentedWhitespace: 1
211 changes: 211 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
name: CI

on:
push:
branches:
- main
- dev
paths:
- "**ci.yml"
- "**.hpp"
- "**.cpp"
- "**CMakeLists.txt"
pull_request:
branches:
- main
- dev
paths:
- "**ci.yml"
- "**.hpp"
- "**.cpp"
- "**CMakeLists.txt"

env:
BRANCH_NAME: ${{ github.ref == 'refs/heads/dev' && 'dev' || 'main' }}
PRERELEASE: ${{ github.ref == 'refs/heads/dev' && 'true' || 'false' }}
TAG_SUFFIX: ${{ github.ref == 'refs/heads/dev' && '-dev' || '' }}

jobs:
changes:
runs-on: ubuntu-22.04
outputs:
build: ${{ steps.filter.outputs.src }}
ci: ${{ steps.filter.outputs.ci }}

steps:
- name: Checkout
if: github.event_name == 'push'
uses: actions/checkout@v3

- uses: dorny/paths-filter@v2
id: filter
with:
base: ${{ env.BRANCH_NAME }}
filters: |
src:
- '**/*.cpp'
- '**/*.hpp'
- '**/CMakeLists.txt'
ci:
- '.github/workflows/ci.yml'
build:
needs: changes
strategy:
fail-fast: false
matrix:
config:
- {
os: ubuntu-22.04,
arch: x64,
binary_path: saber,
output_name: saber-linux-x64,
}
- {
os: windows-2022,
arch: x64,
binary_path: Release/saber.exe,
output_name: saber-windows-x64.exe,
}
- {
os: windows-2022,
arch: x86,
binary_path: Release/saber.exe,
output_name: saber-windows-x86.exe,
}

name: build-${{ matrix.config.os }}-${{ matrix.config.arch }}
runs-on: ${{ matrix.config.os }}
if: needs.changes.outputs.build == 'true'

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake g++-12 libssl-dev ninja-build rpm zlib1g-dev

- name: Add MSBuild to PATH (Windows)
if: runner.os == 'Windows'
uses: microsoft/[email protected]

- name: Configure CMake (Linux)
if: runner.os == 'Linux'
run: cmake -S . -B build -G Ninja
env:
CXX: g++-12

- name: Configure CMake (Windows x64)
if: runner.os == 'Windows' && matrix.config.arch == 'x64'
run: cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -T host=x64

- name: Configure CMake (Windows x86)
if: runner.os == 'Windows' && matrix.config.arch == 'x86'
run: cmake -S . -B build -D net_FORCE_BUILD_OPENSSL=ON -G "Visual Studio 17 2022" -A Win32 -T host=x86

- name: Build
run: cmake --build build --config Release

- name: Move binary (Linux)
if: runner.os == 'Linux'
run: mv build/${{ matrix.config.binary_path }} build/${{ matrix.config.output_name }}

- name: Move binary (Windows)
if: runner.os == 'Windows'
run: Move-Item build/${{ matrix.config.binary_path }} build/${{ matrix.config.output_name }}

- name: Upload Binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.config.output_name }}
path: ./build/${{ matrix.config.output_name }}
if-no-files-found: error

release:
needs: build
runs-on: ubuntu-22.04
if: github.event_name == 'push'

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get Latest Tag
id: latest-tag
run: |
if [[ "${{ github.ref }}" == 'refs/heads/dev' ]]; then
latest_tag=$(git tag -l | grep "\-dev" | sort -V | tail -n 1 || true)
else
latest_tag=$(git tag -l | grep -v "\-dev" | sort -V | tail -n 1 || true)
fi

if [[ -z $latest_tag ]]; then
latest_tag=""
fi

echo "::set-output name=tag::$latest_tag"
shell: bash

- name: Get Next Version
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: ${{ env.BRANCH_NAME }}
fromTag: ${{ steps.latest-tag.outputs.tag }}

- name: Create Draft Release
uses: ncipollo/[email protected]
with:
prerelease: ${{ env.PRERELEASE }}
draft: false
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
name: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
body: "*pending*"
token: ${{ github.token }}

- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
writeToFile: false

- name: Create Release
uses: ncipollo/[email protected]
with:
prerelease: ${{ env.PRERELEASE }}
allowUpdates: true
draft: false
makeLatest: true
commit: ${{ github.sha }}
tag: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
name: ${{ steps.semver.outputs.next }}${{ env.TAG_SUFFIX }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}

outputs:
next: ${{ steps.semver.outputs.next }}

upload:
needs: release
runs-on: ubuntu-22.04
if: github.event_name == 'push'

steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: .

- name: Upload artifacts to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
file_glob: true
file: "**/*"
tag: ${{ needs.release.outputs.next }}${{ env.TAG_SUFFIX }}
28 changes: 15 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,34 @@ cpmfindpackage(
)

file(GLOB_RECURSE sources CONFIGURE_DEPENDS "include/*.hpp" "src/*.cpp")
list(FILTER sources EXCLUDE REGEX ".*main\\.cpp$")

add_executable(${PROJECT_NAME} ${sources})
add_library(${PROJECT_NAME}_lib ${sources})
add_executable(${PROJECT_NAME} src/main.cpp)

target_compile_features(${PROJECT_NAME}_lib PUBLIC cxx_std_17)

if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${PROJECT_NAME}_lib PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_link_libraries(${PROJECT_NAME} PRIVATE ekizu spdlog::spdlog)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ekizu spdlog::spdlog)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}_lib)

file(GLOB_RECURSE commands CONFIGURE_DEPENDS commands/*.cpp)

foreach(fullcmdname ${commands})
get_filename_component(cmdname ${fullcmdname} NAME_WE)
message(STATUS "Found command:'cmd_${cmdname}'")
add_library(cmd_${cmdname} SHARED ${fullcmdname})
target_include_directories(
cmd_${cmdname} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
target_link_libraries(cmd_${cmdname} PRIVATE ekizu)
target_link_libraries(cmd_${cmdname} PRIVATE ${PROJECT_NAME}_lib)
endforeach(fullcmdname)

if(${PROJECT_NAME}_INSTALL)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
endif()

target_compile_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
target_link_options(${PROJECT_NAME} PUBLIC -fsanitize=thread)
endif()
Loading
Loading