mirror of
https://github.com/wiiu-env/WiiUModuleSystem.git
synced 2024-11-24 18:56:53 +01:00
Format the code via clang-format
This commit is contained in:
parent
c7b9039dae
commit
fdf9993069
67
.clang-format
Normal file
67
.clang-format
Normal 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
25
.github/workflows/pr.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: CI-PR
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
clang-format-lib:
|
||||
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 ./include ./libraries
|
||||
build-lib:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format-lib
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -f Dockerfile.buildlocal -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
||||
- uses: actions/upload-artifact@master
|
||||
with:
|
||||
name: binary
|
||||
path: "/lib/*.a"
|
19
.github/workflows/push_image.yml
vendored
19
.github/workflows/push_image.yml
vendored
@ -4,8 +4,25 @@ on:
|
||||
branches:
|
||||
- master
|
||||
jobs:
|
||||
build:
|
||||
clang-format-lib:
|
||||
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 ./include ./libraries
|
||||
build-lib:
|
||||
runs-on: ubuntu-18.04
|
||||
needs: clang-format-lib
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build binary
|
||||
run: |
|
||||
docker build . -f Dockerfile.buildlocal -t builder
|
||||
docker run --rm -v ${PWD}:/project builder make
|
||||
push_image:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-lib
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Get release version
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM wiiuenv/devkitppc:20210920
|
||||
FROM wiiuenv/devkitppc:20211229
|
||||
|
||||
WORKDIR build
|
||||
COPY . .
|
||||
|
3
Dockerfile.buildlocal
Normal file
3
Dockerfile.buildlocal
Normal file
@ -0,0 +1,3 @@
|
||||
FROM wiiuenv/devkitppc:20211229
|
||||
|
||||
WORKDIR project
|
80
README.MD
Normal file
80
README.MD
Normal file
@ -0,0 +1,80 @@
|
||||
[![Publish Docker Image](https://github.com/wiiu-env/WiiUModuleSystem/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/WiiUModuleSystem/actions/workflows/push_image.yml)
|
||||
|
||||
# Wii U Module System
|
||||
|
||||
This lib is required to build Modules to be loaded with the [Wii U Module System Loader](https://github.com/wiiu-env/WUMSLoader).
|
||||
|
||||
## Usage
|
||||
|
||||
A module needs to implements at least the following macros.
|
||||
```C++
|
||||
#include <wums.h>
|
||||
|
||||
WUMS_MODULE_EXPORT_NAME("homebrew_modulename");
|
||||
|
||||
WUMS_INITIALIZE() {
|
||||
/** THIS CODE WILL BE RUN ONCE **/
|
||||
}
|
||||
```
|
||||
|
||||
The `WUMS_MODULE_EXPORT_NAME` needs to be a globally unique name across all loaded modules. `WUMS_INITIALIZE` defines the code that will be run after the module was loaded.
|
||||
The module will have full permission to the sd card via `fs:/vol/external01`.
|
||||
|
||||
### Optional macros/hooks
|
||||
Other optional macros/hooks are support, here some examples:
|
||||
|
||||
```C++
|
||||
WUMS_APPLICATION_STARTS() {
|
||||
/** Is called when a new application was started. **/
|
||||
}
|
||||
|
||||
WUMS_APPLICATION_REQUESTS_EXIT() {
|
||||
/** Is called when a new application is going to be closed. **/
|
||||
}
|
||||
```
|
||||
|
||||
This list is incomplete, see `hooks.h` for all hooks and `meta.h` for all macros.
|
||||
|
||||
### Export functions
|
||||
|
||||
Modules can be used to export functions for other modules or "normal" applications.
|
||||
|
||||
```C++
|
||||
#include <wums.h>
|
||||
|
||||
void MyCustomFunction() {
|
||||
/** Some special code that should be useable for everyone */
|
||||
}
|
||||
|
||||
WUMS_EXPORT_FUNCTION(MyCustomFunction);
|
||||
```
|
||||
|
||||
This function can then be used like they would be inside a .rpl, where the name of the "rpl" is the one defined in `WUMS_MODULE_EXPORT_NAME`.
|
||||
|
||||
Example using the Cafe OS OSDynLoad API:
|
||||
```C++
|
||||
if (OSDynLoad_Acquire("homebrew_modulename", &sModuleHandle) != OS_DYNLOAD_OK) {
|
||||
OSFatal("OSDynLoad_Acquire failed.");
|
||||
}
|
||||
|
||||
void (*sMyCustomFunction)() = NULL;
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, FALSE, "MyCustomFunction", (void**) &sMyCustomFunction) != OS_DYNLOAD_OK) {
|
||||
OSFatal("OSDynLoad_FindExport failed.");
|
||||
}
|
||||
```
|
||||
|
||||
## Use this lib in Dockerfiles.
|
||||
A prebuilt version of this lib can found on dockerhub. To use it for your projects, add this to your Dockerfile.
|
||||
```Dockerfile
|
||||
[...]
|
||||
COPY --from=wiiuenv/wiiumodulesystem:[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/wiiumodulesystem/tags).
|
||||
It's highly recommended to pin the version to the **latest date** instead of using `latest`.
|
||||
|
||||
## Format the code via docker
|
||||
```bash
|
||||
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries -i
|
||||
```
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "wums/meta.h"
|
||||
#include "wums/common.h"
|
||||
#include "wums/exports.h"
|
||||
#include "wums/hooks.h"
|
||||
#include "wums/meta.h"
|
@ -18,8 +18,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -17,11 +17,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "dynamic_linking_defines.h"
|
||||
#include "relocation_defines.h"
|
||||
#include "export_defines.h"
|
||||
#include "relocation_defines.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -46,6 +46,7 @@ typedef struct module_function_symbol_data_t {
|
||||
uint32_t size;
|
||||
} module_function_symbol_data_t;
|
||||
|
||||
// clang-format off
|
||||
typedef struct module_information_single_t {
|
||||
char path[MAXIMUM_MODULE_PATH_NAME_LENGTH]; // Path where the module is stored
|
||||
dyn_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH];
|
||||
@ -65,10 +66,12 @@ typedef struct module_information_single_t {
|
||||
module_function_symbol_data_t * function_symbol_entries;
|
||||
uint32_t number_used_function_symbols;
|
||||
} module_information_single_t;
|
||||
// clang-format on
|
||||
|
||||
#define MAXIMUM_MODULES 32
|
||||
#define MODULE_INFORMATION_VERSION 0x00000007
|
||||
|
||||
// clang-format off
|
||||
typedef struct module_information_t {
|
||||
uint32_t version;
|
||||
int32_t number_used_modules; // Number of used function. Maximum is MAXIMUM_MODULES
|
||||
@ -78,6 +81,7 @@ typedef struct module_information_t {
|
||||
uint32_t number_used_function_symbols;
|
||||
module_information_single_t module_data[MAXIMUM_MODULES];
|
||||
} module_information_t;
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ typedef struct wums_entry_t {
|
||||
const wums_loader_entry_t wums_entry_##pointer = { \
|
||||
.type = _type, \
|
||||
.name = #pointer, \
|
||||
.address = (const void*) value \
|
||||
}
|
||||
.address = (const void *) value}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ extern "C" {
|
||||
extern const wums_hook_t wums_hooks_##original_func WUMS_SECTION("hooks"); \
|
||||
const wums_hook_t wums_hooks_##original_func = { \
|
||||
.type = type_def, \
|
||||
.target = (const void*)&(original_func) \
|
||||
}
|
||||
.target = (const void *) &(original_func)}
|
||||
|
||||
typedef enum wums_hook_type_t {
|
||||
WUMS_HOOK_INIT_WUT_MALLOC,
|
||||
|
Loading…
Reference in New Issue
Block a user