Format the code via clang-format

This commit is contained in:
Maschell 2022-02-13 12:12:26 +01:00
parent 96be7edd0e
commit 3bdd79b69e
8 changed files with 174 additions and 67 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:
- main
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
@ -23,4 +31,3 @@ jobs:
snapshot: true
cache: true
tags: "latest, ${{ env.RELEASE_VERSION }}"
dockerfile: Dockerfile

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210920
FROM wiiuenv/devkitppc:20211229
WORKDIR tmp_build
COPY . .

3
Dockerfile.buildlocal Normal file
View File

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

View File

@ -1,3 +1,5 @@
[![Publish Docker Image](https://github.com/wiiu-env/libromfs_wiiu/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/libromfs_wiiu/actions/workflows/push_image.yml)
# libromfs
Ported from [libnx](https://github.com/switchbrew/libnx/blob/e5ae43f4c2cca5320559d9c27ce256b2901aed40/nx/source/runtime/devices/romfs_dev.c)
@ -16,3 +18,7 @@ COPY --from=wiiuenv/libromfs_wiiu:[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/libromfs_wiiu/tags).
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

@ -85,4 +85,3 @@ int romfsGetFileInfoPerPath(const char *romfs, const char *path, romfs_fileInfo
#ifdef __cplusplus
}
#endif

View File

@ -1,16 +1,16 @@
#include <coreinit/cache.h>
#include <coreinit/filesystem.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <malloc.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/dirent.h>
#include <sys/iosupport.h>
#include <sys/param.h>
#include <unistd.h>
#include <stdbool.h>
#include <malloc.h>
#include <coreinit/cache.h>
#include <coreinit/filesystem.h>
#include "romfs_dev.h"
@ -37,8 +37,8 @@ extern char **__system_argv;
//static char __thread __component[PATH_MAX+1];
static char __component[PATH_MAX + 1];
#define romFS_root(m) ((romfs_dir*)(m)->dirTable)
#define romFS_none ((uint32_t)~0)
#define romFS_root(m) ((romfs_dir *) (m)->dirTable)
#define romFS_none ((uint32_t) ~0)
#define romFS_dir_mode (S_IFDIR | S_IRUSR | S_IRGRP | S_IROTH)
#define romFS_file_mode (S_IFREG | S_IRUSR | S_IRGRP | S_IROTH)
@ -148,7 +148,7 @@ static const devoptab_t romFS_devoptab =
.dirclose_r = romfs_dirclose,
// symlinks aren't supported so alias lstat to stat
.lstat_r = romfs_stat,
};
};
static bool romfs_initialised = false;
static romfs_mount romfs_mounts[32];
@ -341,11 +341,11 @@ int32_t romfsMountCommon(const char *name, romfs_mount *mount) {
DCFlushRange(mount, sizeof(*mount));
return 0;
fail_oom:
fail_oom:
romfs_mountclose(mount);
return 9;
fail_io:
fail_io:
romfs_mountclose(mount);
return 10;
}