mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-07 21:23:32 +00:00
infra: remove unused resources.
thorvg will revisit this later.
This commit is contained in:
parent
9a6eff8ce2
commit
865f87d15e
3 changed files with 0 additions and 157 deletions
|
@ -1,8 +0,0 @@
|
||||||
[Tools] Added scripts for code style validation and auto fixing
|
|
||||||
|
|
||||||
[Features]
|
|
||||||
- tools/codestyle/code_formatter.sh - formatter for C/C++ (changes files)
|
|
||||||
- tools/codestyle/c++_clang_formatter.sh - for auto formating C++ files
|
|
||||||
- code_format - link to script for easier access
|
|
||||||
|
|
||||||
[Help] You can check usage for code_format using '-h' option
|
|
|
@ -1,59 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
|
||||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
|
||||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
SOURCE="$(readlink "$SOURCE")"
|
|
||||||
[[ $SOURCE != /* ]] && SOURCE="$SCRIPT_DIR/$SOURCE"
|
|
||||||
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
|
||||||
done
|
|
||||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
|
|
||||||
# https://clangformat.com/
|
|
||||||
if [ ! "$(command -v clang-format)" ]; then
|
|
||||||
echo >&2 "clang-format is required, but it's not installed";
|
|
||||||
echo "-------------------------------------------------------------------------------------";
|
|
||||||
echo "To install clang-format on Debian/Ubuntu, execute the following commands."
|
|
||||||
echo " sudo apt-get install clang-format-3.9"
|
|
||||||
echo " sudo ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format"
|
|
||||||
echo "-------------------------------------------------------------------------------------";
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
config='{
|
|
||||||
BasedOnStyle: Google,
|
|
||||||
Language: Cpp,
|
|
||||||
Standard: Cpp11,
|
|
||||||
UseTab: Never,
|
|
||||||
IndentWidth: 2,
|
|
||||||
ColumnLimit: 100,
|
|
||||||
PointerBindsToType: true,
|
|
||||||
AllowShortFunctionsOnASingleLine: false,
|
|
||||||
BreakBeforeBraces: GNU,
|
|
||||||
}'
|
|
||||||
|
|
||||||
formatC++() {
|
|
||||||
printf "."
|
|
||||||
find -- "$1" -type f \( -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) | \
|
|
||||||
grep -v 'src/google' | xargs -n1 --no-run-if-empty clang-format -i -style="$config"
|
|
||||||
}
|
|
||||||
|
|
||||||
checkUpdatedFiles() {
|
|
||||||
while IFS= read -r -d '' f; do
|
|
||||||
if [ "${f: -3}" == ".cc" ] || [ "${f: -4}" == ".cpp" ] || [ "${f: -2}" == ".h" ] || \
|
|
||||||
[ "${f: -4}" == ".hpp" ]; then
|
|
||||||
printf '.'
|
|
||||||
clang-format -i -style="$config" "$f";
|
|
||||||
fi
|
|
||||||
done < <(git diff-index -z --name-only --diff-filter=AM HEAD --)
|
|
||||||
}
|
|
||||||
|
|
||||||
printf "C/C++ reformatting: ";
|
|
||||||
if [[ $# -eq 0 ]]; then
|
|
||||||
formatC++ "$SCRIPT_DIR/../../src/"
|
|
||||||
elif [[ "$1" == "-u" ]]; then
|
|
||||||
checkUpdatedFiles
|
|
||||||
else
|
|
||||||
formatC++ "$1"
|
|
||||||
fi
|
|
||||||
printf " DONE C/C++ reformatting\n"
|
|
|
@ -1,90 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
|
||||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
|
||||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
SOURCE="$(readlink "$SOURCE")"
|
|
||||||
[[ $SOURCE != /* ]] && SOURCE="$SCRIPT_DIR/$SOURCE"
|
|
||||||
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
|
||||||
done
|
|
||||||
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
echo "$SCRIPT_DIR"
|
|
||||||
|
|
||||||
dir2analyze="$SCRIPT_DIR/../../src"
|
|
||||||
analyzeC="false";
|
|
||||||
files_to_update="";
|
|
||||||
|
|
||||||
printHelp() {
|
|
||||||
echo "Script for automatic fixing some coding style rules issues."
|
|
||||||
echo "In case of any issues of analysed code, the script would adjust it to follow"
|
|
||||||
echo "coding style. THIS COULD CHANGE YOUR FILES. Please commit your changes locally"
|
|
||||||
echo "if you want to have meaningful changes divided from style-only changes"
|
|
||||||
echo "Using it without specifying a path would analyse \"src\" from current directory."
|
|
||||||
printf -- "\nUsage: %s [directory] [options ...]\n" "$(basename "$0")"
|
|
||||||
printf -- "Options:\n"
|
|
||||||
printf -- "-u\t\tcheck all C/C++ files that has been modified since last commit and fix issues\n"
|
|
||||||
printf -- "-c\t\tcheck C/C++ files and fix issues\n"
|
|
||||||
printf -- "-a [--all]\tcheck all C/C++ files and fix issues\n"
|
|
||||||
printf -- "-h [--help]\tshow this help\n"
|
|
||||||
echo "When using any of 'u' options, all not commited files will be backed up."
|
|
||||||
}
|
|
||||||
|
|
||||||
formatC++() {
|
|
||||||
path="$(readlink -f "$1")"
|
|
||||||
if [[ "$analyzeC" == "true" ]]; then
|
|
||||||
echo "Reformatting C++ sources recursively for directory $path";
|
|
||||||
"$SCRIPT_DIR/c++_clang_formatter.sh" "$path";
|
|
||||||
else
|
|
||||||
echo "no C++ sources reformatting - please use '-c' option to enable it";
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
backupUpdatedFiles() {
|
|
||||||
files_to_update="$(git diff-index -z --name-only --diff-filter=AM HEAD --)";
|
|
||||||
if [[ "$files_to_update" == "" ]]; then
|
|
||||||
echo "There are no updated files to format";
|
|
||||||
exit;
|
|
||||||
fi
|
|
||||||
time_stamp=$(date +%Y-%m-%d-%T);
|
|
||||||
dir_name="backup_${time_stamp}";
|
|
||||||
echo "Creating backup of not commited changes in directory: $dir_name";
|
|
||||||
mkdir -p "${dir_name}";
|
|
||||||
while IFS= read -r -d '' file; do
|
|
||||||
cp -- "$file" "$dir_name";
|
|
||||||
done <<< "$files_to_update"
|
|
||||||
}
|
|
||||||
|
|
||||||
formatUpdatedC++() {
|
|
||||||
if [[ "$files_to_update" == "" ]]; then
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
echo "Reformatting C++ sources from list:";
|
|
||||||
git diff-index --name-only --diff-filter=AM HEAD --;
|
|
||||||
"$SCRIPT_DIR/c++_clang_formatter.sh" -u;
|
|
||||||
}
|
|
||||||
|
|
||||||
for arg in "$@";
|
|
||||||
do
|
|
||||||
if [[ "$arg" == "-u" ]]; then
|
|
||||||
backupUpdatedFiles
|
|
||||||
formatUpdatedC++
|
|
||||||
exit
|
|
||||||
elif [[ "$arg" == "-c" ]]; then
|
|
||||||
analyzeC="true";
|
|
||||||
elif [[ "$arg" == "--all" ]] || [[ "$arg" == "-a" ]]; then
|
|
||||||
analyzeC="true";
|
|
||||||
elif [[ "$arg" == "--help" ]] || [[ "$arg" == "-h" ]]; then
|
|
||||||
printHelp
|
|
||||||
exit
|
|
||||||
else
|
|
||||||
if [[ -d "$arg" ]]; then
|
|
||||||
dir2analyze="$arg";
|
|
||||||
else
|
|
||||||
(>&2 printf "ERROR: directory %s does not exist\n\n" "$arg")
|
|
||||||
printHelp
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
formatC++ "$dir2analyze"
|
|
Loading…
Add table
Reference in a new issue