mirror of
https://github.com/pmret/papermario.git
synced 2024-11-09 12:32:38 +01:00
add astyle, update clang-tidy config
This commit is contained in:
parent
7498c2dc1c
commit
b5256e31ee
@ -1,23 +0,0 @@
|
|||||||
IndentWidth: 4
|
|
||||||
Language: Cpp
|
|
||||||
UseTab: Never
|
|
||||||
ColumnLimit: 120
|
|
||||||
PointerAlignment: Left
|
|
||||||
BreakBeforeBraces: Attach
|
|
||||||
SpaceAfterCStyleCast: false
|
|
||||||
Cpp11BracedListStyle: false
|
|
||||||
IndentCaseLabels: true
|
|
||||||
BinPackArguments: true
|
|
||||||
BinPackParameters: true
|
|
||||||
AlignAfterOpenBracket: Align
|
|
||||||
AlignOperands: true
|
|
||||||
BreakBeforeTernaryOperators: true
|
|
||||||
BreakBeforeBinaryOperators: None
|
|
||||||
AllowShortBlocksOnASingleLine: true
|
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
|
||||||
AllowShortLoopsOnASingleLine: false
|
|
||||||
AllowShortCaseLabelsOnASingleLine: false
|
|
||||||
AllowShortFunctionsOnASingleLine: false
|
|
||||||
AlignEscapedNewlines: Left
|
|
||||||
AlignTrailingComments: true
|
|
||||||
SortIncludes: false
|
|
@ -1,5 +1,2 @@
|
|||||||
Checks: '-*,readability-braces-around-statements'
|
Checks: '-*,clang-analyzer-core.*,clang-analyzer-deadcode.*,readability-*,-readability-magic-numbers,-readability-else-after-return,-readability-named-parameter,-readability-braces-around-statements,-clang-diagnostic-error'
|
||||||
WarningsAsErrors: ''
|
HeaderFilterRegex: '(src|include)\/.*\.h'
|
||||||
HeaderFilterRegex: '(src|include)\/.*\.h$'
|
|
||||||
FormatStyle: 'file'
|
|
||||||
CheckOptions:
|
|
||||||
|
39
.github/workflows/lint.yaml
vendored
Normal file
39
.github/workflows/lint.yaml
vendored
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
name: Lint
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'src/*'
|
||||||
|
- 'include/*'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- 'src/*'
|
||||||
|
- 'include/*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- run: ./install.sh
|
||||||
|
|
||||||
|
# lint files changed by the push/pr
|
||||||
|
- id: files
|
||||||
|
uses: trilom/file-changes-action@v1.2.4
|
||||||
|
with:
|
||||||
|
output: ' '
|
||||||
|
continue-on-error: true # see jitterbit/get-changed-files#7
|
||||||
|
- run: ./format.sh ${{ steps.files.outputs.files}}
|
||||||
|
|
||||||
|
# fail if any files were changed by ./format.sh
|
||||||
|
- id: files_formatted
|
||||||
|
uses: jackton1/find-changed-files@v1.1
|
||||||
|
with:
|
||||||
|
files: src, include
|
||||||
|
|
||||||
|
- name: Fail if any files reformatted
|
||||||
|
if: steps.files_formatted.outputs.files_changed == 'true'
|
||||||
|
run: |
|
||||||
|
git diff
|
||||||
|
exit 1
|
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -3,4 +3,5 @@
|
|||||||
"editor.insertSpaces": true,
|
"editor.insertSpaces": true,
|
||||||
"files.eol": "\n",
|
"files.eol": "\n",
|
||||||
"files.insertFinalNewline": true,
|
"files.insertFinalNewline": true,
|
||||||
|
"editor.rulers": [120],
|
||||||
}
|
}
|
||||||
|
46
format.sh
46
format.sh
@ -1,26 +1,34 @@
|
|||||||
FORMAT_OPTS="-i -style=file"
|
COMPILER_OPTS="-fno-builtin -std=gnu89 -Iinclude -Isrc -D_LANGUAGE_C"
|
||||||
TIDY_OPTS="-p . --fix --fix-errors"
|
|
||||||
COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING"
|
|
||||||
|
|
||||||
shopt -s globstar
|
shopt -s globstar
|
||||||
|
|
||||||
|
FILES="src/**/*.c include/*.h"
|
||||||
if (( $# > 0 )); then
|
if (( $# > 0 )); then
|
||||||
echo "Formatting file(s) $*"
|
# only process .c and .h files
|
||||||
echo "Running clang-format..."
|
FILES=$(echo "$@" | sed 's/ /\n/g' | grep '.[ch]$')
|
||||||
clang-format ${FORMAT_OPTS} "$@"
|
fi
|
||||||
echo "Running clang-tidy..."
|
|
||||||
clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null
|
if [[ -z $FILES ]]; then
|
||||||
echo "Adding missing final new lines..."
|
echo "no .c or .h files specified"
|
||||||
sed -i -e '$a\' "$@"
|
|
||||||
echo "Done formatting file(s) $*"
|
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Formatting C files. This will take a bit"
|
# format
|
||||||
echo "Running clang-format..."
|
astyle ${FILES} \
|
||||||
clang-format ${FORMAT_OPTS} src/**/*.c
|
--formatted --suffix=none \
|
||||||
echo "Running clang-tidy..."
|
--lineend=linux \
|
||||||
clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null
|
--convert-tabs \
|
||||||
echo "Adding missing final new lines..."
|
--max-code-length=120 \
|
||||||
find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \;
|
--min-conditional-indent=1 \
|
||||||
echo "Done formatting all files."
|
--style=attach \
|
||||||
|
--align-pointer=type --align-reference=name \
|
||||||
|
--indent-switches \
|
||||||
|
--indent-labels \
|
||||||
|
--pad-oper --pad-comma --pad-header --unpad-paren \
|
||||||
|
--attach-return-type \
|
||||||
|
|
||||||
|
# add newline at eof
|
||||||
|
find ${FILES} -exec sed -i -e '$a\' {} \;
|
||||||
|
|
||||||
|
# lint
|
||||||
|
clang-tidy -p . ${FILES} -- ${COMPILER_OPTS}
|
||||||
|
@ -48,7 +48,7 @@ extern s16 D_8010CD10;
|
|||||||
extern s16 D_8010CD12;
|
extern s16 D_8010CD12;
|
||||||
extern s32 D_801595A0;
|
extern s32 D_801595A0;
|
||||||
extern char gCloudyFlowerFieldsBg[]; // "fla_bg"
|
extern char gCloudyFlowerFieldsBg[]; // "fla_bg"
|
||||||
extern char gSunnyFlowerFieldsBg[]; // "flb_bg"
|
extern char gSunnyFlowerFieldsBg[]; // "flb_bg"
|
||||||
extern BackgroundHeader gBackgroundImage;
|
extern BackgroundHeader gBackgroundImage;
|
||||||
extern s8 D_8014F12F;
|
extern s8 D_8014F12F;
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ if command -v apt-install &> /dev/null; then
|
|||||||
|
|
||||||
if [[ $1 == "--extra" ]]; then
|
if [[ $1 == "--extra" ]]; then
|
||||||
echo "Installing extra"
|
echo "Installing extra"
|
||||||
sudo apt install -y python3 python3-pip clang-tidy clang-format
|
sudo apt install -y python3 python3-pip clang-tidy astyle || exit 1
|
||||||
python3 -m pip install stringcase
|
python3 -m pip install stringcase || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done"
|
echo "Done"
|
||||||
@ -48,7 +48,7 @@ if command -v pacman &> /dev/null; then
|
|||||||
|
|
||||||
if [[ $1 == "--extra" ]]; then
|
if [[ $1 == "--extra" ]]; then
|
||||||
echo "Installing extra"
|
echo "Installing extra"
|
||||||
sudo pacman -S --noconfirm --needed python python-pip clang || exit 1
|
sudo pacman -S --noconfirm --needed python python-pip clang astyle || exit 1
|
||||||
python3 -m pip install stringcase || exit 1
|
python3 -m pip install stringcase || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user