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 b/Dockerfile index 604a0fb..f844858 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM wiiuenv/devkitppc:20210920 +FROM wiiuenv/devkitppc:20220213 COPY --from=wiiuenv/wiiupluginsystem:20210924 /artifacts $DEVKITPRO diff --git a/Dockerfile.buildlocal b/Dockerfile.buildlocal new file mode 100644 index 0000000..9e35bea --- /dev/null +++ b/Dockerfile.buildlocal @@ -0,0 +1,3 @@ +FROM wiiuenv/devkitppc:20220213 + +WORKDIR project \ No newline at end of file diff --git a/README.md b/README.md index 97e4690..0c0bffd 100644 --- a/README.md +++ b/README.md @@ -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 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. @@ -17,4 +19,8 @@ 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). -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/wups_backend/PluginContainer.h b/include/wups_backend/PluginContainer.h index ba1470a..fd13e94 100644 --- a/include/wups_backend/PluginContainer.h +++ b/include/wups_backend/PluginContainer.h @@ -19,8 +19,8 @@ #include -#include "PluginMetaInformation.h" #include "PluginData.h" +#include "PluginMetaInformation.h" class PluginContainer { diff --git a/include/wups_backend/PluginMetaInformation.h b/include/wups_backend/PluginMetaInformation.h index 984df76..d7de8f2 100644 --- a/include/wups_backend/PluginMetaInformation.h +++ b/include/wups_backend/PluginMetaInformation.h @@ -17,9 +17,9 @@ #pragma once +#include #include #include -#include class PluginMetaInformation { public: @@ -55,13 +55,13 @@ public: return this->size; } - PluginMetaInformation(const std::string& name, - const std::string& author, - const std::string& version, - const std::string& license, - const std::string& buildtimestamp, - const std::string& description, - const std::string& storageId, + PluginMetaInformation(const std::string &name, + const std::string &author, + const std::string &version, + const std::string &license, + const std::string &buildtimestamp, + const std::string &description, + const std::string &storageId, size_t size); private: diff --git a/include/wups_backend/PluginUtils.h b/include/wups_backend/PluginUtils.h index d8859ca..feb93fe 100644 --- a/include/wups_backend/PluginUtils.h +++ b/include/wups_backend/PluginUtils.h @@ -14,11 +14,11 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . ****************************************************************************/ -#pragma once +#pragma once -#include -#include "PluginMetaInformation.h" #include "PluginContainer.h" +#include "PluginMetaInformation.h" +#include class PluginUtils { public: diff --git a/include/wups_backend/import_defines.h b/include/wups_backend/import_defines.h index aeeb0c8..ebadcf0 100644 --- a/include/wups_backend/import_defines.h +++ b/include/wups_backend/import_defines.h @@ -17,15 +17,17 @@ #pragma once +#include + typedef enum GetPluginInformationInputType { - PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0, - PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1, + PLUGIN_INFORMATION_INPUT_TYPE_PATH = 0, + PLUGIN_INFORMATION_INPUT_TYPE_BUFFER = 1, } GetPluginInformationInputType; typedef uint32_t plugin_container_handle; typedef uint32_t plugin_data_handle; -#define PLUGIN_INFORMATION_VERSION 0x00000001 +#define PLUGIN_INFORMATION_VERSION 0x00000001 /* plugin_information message */ typedef struct __attribute__((__packed__)) plugin_information { @@ -41,10 +43,9 @@ typedef struct __attribute__((__packed__)) plugin_information { } plugin_information; typedef enum PluginBackendApiErrorType { - PLUGIN_BACKEND_API_ERROR_NONE = 0, - PLUGIN_BACKEND_API_ERROR_INVALID_SIZE = 0xFFFFFFFF, - PLUGIN_BACKEND_API_ERROR_INVALID_ARG = 0xFFFFFFFE, - PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC = 0xFFFFFFFD, - PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND = 0xFFFFFFFC, + PLUGIN_BACKEND_API_ERROR_NONE = 0, + PLUGIN_BACKEND_API_ERROR_INVALID_SIZE = 0xFFFFFFFF, + PLUGIN_BACKEND_API_ERROR_INVALID_ARG = 0xFFFFFFFE, + PLUGIN_BACKEND_API_ERROR_FAILED_ALLOC = 0xFFFFFFFD, + PLUGIN_BACKEND_API_ERROR_FILE_NOT_FOUND = 0xFFFFFFFC, } PluginBackendApiErrorType; - diff --git a/source/PluginMetaInformation.cpp b/source/PluginMetaInformation.cpp index 977319c..f546a8d 100644 --- a/source/PluginMetaInformation.cpp +++ b/source/PluginMetaInformation.cpp @@ -17,24 +17,24 @@ #include "wups_backend/PluginMetaInformation.h" -#include #include +#include #include -PluginMetaInformation::PluginMetaInformation(const std::string& name_, - const std::string& author_, - const std::string& version_, - const std::string& license_, - const std::string& buildtimestamp_, - const std::string& description_, - const std::string& storageId_, +PluginMetaInformation::PluginMetaInformation(const std::string &name_, + const std::string &author_, + const std::string &version_, + const std::string &license_, + const std::string &buildtimestamp_, + const std::string &description_, + const std::string &storageId_, size_t size_) { - this->name = name_; - this->author = author_; - this->size = size_; + this->name = name_; + this->author = author_; + this->size = size_; this->buildtimestamp = buildtimestamp_; - this->description = description_; - this->license = license_; - this->version = version_; - this->storageId = storageId_; + this->description = description_; + this->license = license_; + this->version = version_; + this->storageId = storageId_; } diff --git a/source/PluginUtils.cpp b/source/PluginUtils.cpp index b745656..0752cfc 100644 --- a/source/PluginUtils.cpp +++ b/source/PluginUtils.cpp @@ -17,8 +17,8 @@ #include -#include "wups_backend/PluginUtils.h" #include "imports.h" +#include "wups_backend/PluginUtils.h" std::optional PluginUtils::getMetaInformationForBuffer(char *buffer, size_t size) { plugin_information info; @@ -178,13 +178,13 @@ void PluginUtils::destroyPluginContainer(PluginContainer &plugin) { void PluginUtils::destroyPluginContainer(std::vector &plugins) { uint32_t containerSize = plugins.size(); - uint32_t dataSize = containerSize; + uint32_t dataSize = containerSize; plugin_container_handle container_handles[containerSize]; plugin_data_handle data_handles[dataSize]; uint32_t cntC = 0; uint32_t cntD = 0; - for (auto &plugin: plugins) { + for (auto &plugin : plugins) { if (plugin.getHandle() != 0) { container_handles[cntC] = plugin.getHandle(); cntC++; @@ -206,7 +206,7 @@ int32_t PluginUtils::LoadAndLinkOnRestart(std::vector &plugins) uint32_t dataSize = plugins.size(); plugin_data_handle handles[dataSize]; int i = 0; - for (auto &plugin: plugins) { + for (auto &plugin : plugins) { plugin_data_handle handle = plugin.getPluginData().getHandle(); if (handle == 0) { dataSize--; @@ -216,5 +216,6 @@ int32_t PluginUtils::LoadAndLinkOnRestart(std::vector &plugins) } } - return WUPSLoadAndLinkByDataHandle(handles, dataSize);; + return WUPSLoadAndLinkByDataHandle(handles, dataSize); + ; }