Format via clang-format

This commit is contained in:
Maschell 2022-02-13 16:12:10 +01:00
parent 36aee0481f
commit 4d3c85c793
12 changed files with 154 additions and 43 deletions

67
.clang-format Normal file
View File

@ -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

25
.github/workflows/pr.yml vendored Normal file
View File

@ -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"

View File

@ -4,8 +4,16 @@ on:
branches: branches:
- master - master
jobs: 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: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: clang-format
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Get release version - name: Get release version

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210920 FROM wiiuenv/devkitppc:20220213
COPY --from=wiiuenv/wiiupluginsystem:20210924 /artifacts $DEVKITPRO COPY --from=wiiuenv/wiiupluginsystem:20210924 /artifacts $DEVKITPRO

3
Dockerfile.buildlocal Normal file
View File

@ -0,0 +1,3 @@
FROM wiiuenv/devkitppc:20220213
WORKDIR project

View File

@ -1,3 +1,5 @@
[![Publish Docker Image](https://github.com/wiiu-env/libwupsbackend/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libwupsbackend/actions/workflows/push_image.yml)
## libwupsbackend ## libwupsbackend
Requires the [WiiUPluginLoaderBackendModule](https://github.com/wiiu-env/WiiUPluginLoaderBackend) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader). Requires the [WiiUPluginLoaderBackendModule](https://github.com/wiiu-env/WiiUPluginLoaderBackend) to be running via [WUMSLoader](https://github.com/wiiu-env/WUMSLoader).
Requires [wut](https://github.com/devkitpro/wut) for building. Requires [wut](https://github.com/devkitpro/wut) for building.
@ -18,3 +20,7 @@ COPY --from=wiiuenv/libwupsbackend:[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/libwupsbackend/tags). Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/libwupsbackend/tags).
It's highly recommended to pin the version to the **latest date** instead of using `latest`. 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`

View File

@ -19,8 +19,8 @@
#include <cstdint> #include <cstdint>
#include "PluginMetaInformation.h"
#include "PluginData.h" #include "PluginData.h"
#include "PluginMetaInformation.h"
class PluginContainer { class PluginContainer {

View File

@ -17,9 +17,9 @@
#pragma once #pragma once
#include <optional>
#include <string> #include <string>
#include <vector> #include <vector>
#include <optional>
class PluginMetaInformation { class PluginMetaInformation {
public: public:
@ -55,13 +55,13 @@ public:
return this->size; return this->size;
} }
PluginMetaInformation(const std::string& name, PluginMetaInformation(const std::string &name,
const std::string& author, const std::string &author,
const std::string& version, const std::string &version,
const std::string& license, const std::string &license,
const std::string& buildtimestamp, const std::string &buildtimestamp,
const std::string& description, const std::string &description,
const std::string& storageId, const std::string &storageId,
size_t size); size_t size);
private: private:

View File

@ -16,9 +16,9 @@
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <optional>
#include "PluginMetaInformation.h"
#include "PluginContainer.h" #include "PluginContainer.h"
#include "PluginMetaInformation.h"
#include <optional>
class PluginUtils { class PluginUtils {
public: public:

View File

@ -17,6 +17,8 @@
#pragma once #pragma once
#include <stdint.h>
typedef enum GetPluginInformationInputType { typedef enum GetPluginInformationInputType {
PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0, PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0,
PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1, PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1,
@ -47,4 +49,3 @@ typedef enum PluginBackendApiErrorType {
PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC = 0xFFFFFFFD, PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC = 0xFFFFFFFD,
PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND = 0xFFFFFFFC, PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND = 0xFFFFFFFC,
} PluginBackendApiErrorType; } PluginBackendApiErrorType;

View File

@ -17,17 +17,17 @@
#include "wups_backend/PluginMetaInformation.h" #include "wups_backend/PluginMetaInformation.h"
#include <optional>
#include <cstring> #include <cstring>
#include <optional>
#include <utility> #include <utility>
PluginMetaInformation::PluginMetaInformation(const std::string& name_, PluginMetaInformation::PluginMetaInformation(const std::string &name_,
const std::string& author_, const std::string &author_,
const std::string& version_, const std::string &version_,
const std::string& license_, const std::string &license_,
const std::string& buildtimestamp_, const std::string &buildtimestamp_,
const std::string& description_, const std::string &description_,
const std::string& storageId_, const std::string &storageId_,
size_t size_) { size_t size_) {
this->name = name_; this->name = name_;
this->author = author_; this->author = author_;

View File

@ -17,8 +17,8 @@
#include <cstring> #include <cstring>
#include "wups_backend/PluginUtils.h"
#include "imports.h" #include "imports.h"
#include "wups_backend/PluginUtils.h"
std::optional<PluginMetaInformation> PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) { std::optional<PluginMetaInformation> PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) {
plugin_information info; plugin_information info;
@ -184,7 +184,7 @@ void PluginUtils::destroyPluginContainer(std::vector<PluginContainer> &plugins)
uint32_t cntC = 0; uint32_t cntC = 0;
uint32_t cntD = 0; uint32_t cntD = 0;
for (auto &plugin: plugins) { for (auto &plugin : plugins) {
if (plugin.getHandle() != 0) { if (plugin.getHandle() != 0) {
container_handles[cntC] = plugin.getHandle(); container_handles[cntC] = plugin.getHandle();
cntC++; cntC++;
@ -206,7 +206,7 @@ int32_t PluginUtils::LoadAndLinkOnRestart(std::vector<PluginContainer> &plugins)
uint32_t dataSize = plugins.size(); uint32_t dataSize = plugins.size();
plugin_data_handle handles[dataSize]; plugin_data_handle handles[dataSize];
int i = 0; int i = 0;
for (auto &plugin: plugins) { for (auto &plugin : plugins) {
plugin_data_handle handle = plugin.getPluginData().getHandle(); plugin_data_handle handle = plugin.getPluginData().getHandle();
if (handle == 0) { if (handle == 0) {
dataSize--; dataSize--;
@ -216,5 +216,6 @@ int32_t PluginUtils::LoadAndLinkOnRestart(std::vector<PluginContainer> &plugins)
} }
} }
return WUPSLoadAndLinkByDataHandle(handles, dataSize);; return WUPSLoadAndLinkByDataHandle(handles, dataSize);
;
} }