From ba22cfd39593ce031df1adae4ec85927ef7c42c5 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 11 Feb 2022 20:13:22 +0100 Subject: [PATCH] Format via clang-format --- .clang-format | 67 ++++++++++++++++++++++++++++++++ .github/workflows/pr.yml | 25 ++++++++++++ .github/workflows/push_image.yml | 8 ++++ Dockerfile.buildlocal | 3 ++ README.md | 8 +++- include/kernel/kernel.h | 3 +- source/utils.cpp | 7 ++-- 7 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/pr.yml create mode 100644 Dockerfile.buildlocal diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..56cc685 --- /dev/null +++ b/.clang-format @@ -0,0 +1,67 @@ +# Generated from CLion C/C++ Code Style settings +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: Consecutive +AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignOperands: Align +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Always +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterReturnType: None +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true +BreakBeforeBinaryOperators: None +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 8 +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PointerAlignment: Right +ReflowComments: false +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +TabWidth: 4 +UseTab: Never diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..54f5094 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,25 @@ +name: CI-PR + +on: [pull_request] + +jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include + build-lib: + runs-on: ubuntu-18.04 + needs: clang-format + steps: + - uses: actions/checkout@v2 + - name: build lib + run: | + docker build . -f Dockerfile.buildlocal -t builder + docker run --rm -v ${PWD}:/project builder make + - uses: actions/upload-artifact@master + with: + name: lib + path: "lib/*.a" \ No newline at end of file diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 9cd7bbd..df6eb37 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -4,8 +4,16 @@ on: branches: - master jobs: + clang-format: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v2 + - name: clang-format + run: | + docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include build: runs-on: ubuntu-latest + needs: clang-format steps: - uses: actions/checkout@master - name: Get release version diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal new file mode 100644 index 0000000..080eec7 --- /dev/null +++ b/Dockerfile.buildlocal @@ -0,0 +1,3 @@ +FROM wiiuenv/devkitppc:20211229 + +WORKDIR project \ No newline at end of file diff --git a/README.md b/README.md index 62d6e3e..97cd9f7 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Publish Docker Image](https://github.com/wiiu-env/libkernel/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libkernel/actions/workflows/push_image.yml) + # libkernel Requires the [KernelModule](https://github.com/wiiu-env/KernelModule) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader). Requires [wut](https://github.com/devkitPro/wut) for building. @@ -27,4 +29,8 @@ COPY --from=wiiuenv/libkernel:[tag] /artifacts $DEVKITPRO [...] ``` Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libkernel/tags). -It's highly recommended to pin the version to the **latest date** instead of using `latest`. \ No newline at end of file +It's highly recommended to pin the version to the **latest date** instead of using `latest`. + +## Format the code via docker + +`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./source ./include -i` \ No newline at end of file diff --git a/include/kernel/kernel.h b/include/kernel/kernel.h index ff39783..f4c251a 100644 --- a/include/kernel/kernel.h +++ b/include/kernel/kernel.h @@ -3,8 +3,7 @@ #include "kernel_defs.h" #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #include diff --git a/source/utils.cpp b/source/utils.cpp index 2865241..c5d82bb 100644 --- a/source/utils.cpp +++ b/source/utils.cpp @@ -1,9 +1,9 @@ +#include "kernel/kernel.h" #include #include -#include "kernel/kernel.h" void KernelReadPTE(uint32_t outputAddr, int32_t length) { - auto dst = (uint32_t) OSEffectiveToPhysical(outputAddr); + auto dst = (uint32_t) OSEffectiveToPhysical(outputAddr); uint32_t src = 0xFFE20000; ICInvalidateRange(&dst, 4); DCFlushRange(&dst, 4); @@ -15,7 +15,7 @@ void KernelReadPTE(uint32_t outputAddr, int32_t length) { void KernelWritePTE(uint32_t inputAddr, int32_t length) { uint32_t dst = 0xFFE20000; - auto src = (uint32_t) OSEffectiveToPhysical(inputAddr); + auto src = (uint32_t) OSEffectiveToPhysical(inputAddr); ICInvalidateRange(&src, 4); DCFlushRange(&src, 4); KernelCopyData(dst, src, length); @@ -27,4 +27,3 @@ void KernelNOPAtPhysicalAddress(uint32_t addr) { DCFlushRange(&dst, 4); KernelCopyData(addr, (uint32_t) OSEffectiveToPhysical((uint32_t) &dst), 4); } -