Merge commit '227425b90e9a671118026689dd30967e127a1090' as 'external/toxcore/c-toxcore'
This commit is contained in:
32
external/toxcore/c-toxcore/other/astyle/README.md
vendored
Normal file
32
external/toxcore/c-toxcore/other/astyle/README.md
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
This directory can house various tools and utilities.
|
||||
|
||||
# How to use astyle
|
||||
|
||||
## Manually
|
||||
|
||||
### For all files
|
||||
|
||||
Run from ``toxcore`` directory:
|
||||
```bash
|
||||
astyle --options=./other/astyle/astylerc ./toxcore/*.c ./toxcore/*.h ./testing/*.c ./toxav/*.c ./toxav/*.h ./other/*.c ./other/bootstrap_daemon/*.c ./toxencryptsave/*.c ./toxencryptsave/*.h ./auto_tests/*.c
|
||||
```
|
||||
|
||||
### For selected file
|
||||
|
||||
Run from ``toxcore`` directory, e.g. for [``tox.h``](/toxcore/tox.h) file:
|
||||
```bash
|
||||
astyle --options=./other/astyle/astylerc ./toxcore/tox.h
|
||||
```
|
||||
|
||||
|
||||
## Automatically, as pre-commit hook (*NIX only)
|
||||
|
||||
Copy [``astylerc``](/other/astyle/astylerc) to ``toxcore/.git/hooks``
|
||||
|
||||
|
||||
|
||||
# Why
|
||||
|
||||
``astylerc`` - this file can be used in the pre-commit hook to try its best at making the code conform to the coding style of toxcore.
|
||||
|
||||
Furthermore, it is being used to format ``tox.h`` after using ``apidsl`` to generate it.
|
26
external/toxcore/c-toxcore/other/astyle/astylerc
vendored
Normal file
26
external/toxcore/c-toxcore/other/astyle/astylerc
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
# Bracket Style Options
|
||||
--style=kr
|
||||
|
||||
# Tab Options
|
||||
--indent=spaces=4
|
||||
|
||||
# Indentation Options
|
||||
--indent-switches
|
||||
|
||||
# Padding Options
|
||||
--pad-header
|
||||
--break-blocks
|
||||
--pad-oper
|
||||
--unpad-paren
|
||||
--align-pointer=name
|
||||
--align-reference=name
|
||||
|
||||
# Formatting Options
|
||||
--add-brackets
|
||||
--convert-tabs
|
||||
--max-code-length=120
|
||||
|
||||
# Other Options
|
||||
--preserve-date
|
||||
--formatted
|
||||
--lineend=linux
|
46
external/toxcore/c-toxcore/other/astyle/format-source
vendored
Executable file
46
external/toxcore/c-toxcore/other/astyle/format-source
vendored
Executable file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
SOURCE_DIR="$1"
|
||||
ASTYLE="$2"
|
||||
|
||||
# Go to the source root.
|
||||
if [ -z "$SOURCE_DIR" ]; then
|
||||
SOURCE_DIR=.
|
||||
fi
|
||||
cd "$SOURCE_DIR"
|
||||
|
||||
if [ -z "$ASTYLE" ] || ! which "$ASTYLE"; then
|
||||
ASTYLE=astyle
|
||||
fi
|
||||
|
||||
if ! which "$ASTYLE"; then
|
||||
# If we couldn't find or install an astyle binary, don't do anything.
|
||||
echo "Could not find an astyle binary; please install astyle."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
readarray -t CC_SOURCES <<<"$(find . '(' -name '*.cc' ')')"
|
||||
CC_SOURCES+=(toxcore/crypto_core.c)
|
||||
CC_SOURCES+=(toxcore/ping_array.c)
|
||||
|
||||
for bin in clang-format-11 clang-format-7 clang-format-6.0 clang-format-5.0 clang-format; do
|
||||
if which "$bin"; then
|
||||
"$bin" -i -style='{BasedOnStyle: Google, ColumnLimit: 100}' "${CC_SOURCES[@]}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
FIND="find ."
|
||||
FIND="$FIND '(' -name '*.[ch]' ')'"
|
||||
FIND="$FIND -and -not -name '*.api.h'"
|
||||
FIND="$FIND -and -not -wholename './super_donators/*'"
|
||||
FIND="$FIND -and -not -wholename './third_party/*'"
|
||||
FIND="$FIND -and -not -wholename './toxencryptsave/crypto_pwhash*'"
|
||||
|
||||
readarray -t C_SOURCES <<<"$(eval "$FIND")"
|
||||
|
||||
"$ASTYLE" -n --options=other/astyle/astylerc "${C_SOURCES[@]}"
|
||||
|
||||
git diff --color=always --exit-code
|
17
external/toxcore/c-toxcore/other/astyle/pre-commit
vendored
Normal file
17
external/toxcore/c-toxcore/other/astyle/pre-commit
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env sh
|
||||
#
|
||||
# An example hook script to verify what is about to be committed.
|
||||
# Called by "git commit" with no arguments. The hook should
|
||||
# exit with non-zero status after issuing an appropriate message if
|
||||
# it wants to stop the commit.
|
||||
#
|
||||
# To enable this hook, rename this file to "pre-commit".
|
||||
|
||||
for file in `git diff-index --diff-filter=ACMR --name-only HEAD`; do
|
||||
if [[ $file == *.c || $file == *.h ]]
|
||||
then
|
||||
echo $file
|
||||
`which astyle` $file --options=tools/astylerc
|
||||
git add $file
|
||||
fi
|
||||
done
|
Reference in New Issue
Block a user