added clang-format file and make pretty. Removed previous indent tools.
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
#--indent-cases
|
|
||||||
--indent-classes
|
|
||||||
--indent-switches
|
|
||||||
--indent=spaces=4
|
|
||||||
#--max-instatement-indent=4
|
|
||||||
#--min-conditional-indent=0
|
|
||||||
--brackets=linux
|
|
||||||
--convert-tabs
|
|
||||||
--mode=c
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
BasedOnStyle: Google
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
|
IndentWidth: 4
|
||||||
|
SortIncludes: false
|
||||||
|
...
|
||||||
Vendored
-1
@@ -1 +0,0 @@
|
|||||||
-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl
|
|
||||||
@@ -122,6 +122,11 @@ mstpsnap: ports/linux/mstpsnap.mak
|
|||||||
bdk-atxx4-mstp: ports/bdk-atxx4-mstp/Makefile
|
bdk-atxx4-mstp: ports/bdk-atxx4-mstp/Makefile
|
||||||
$(MAKE) -s -C ports/bdk-atxx4-mstp clean all
|
$(MAKE) -s -C ports/bdk-atxx4-mstp clean all
|
||||||
|
|
||||||
|
pretty:
|
||||||
|
find ./src -iname *.h -o -iname *.c -exec clang-format -i -style=file -fallback-style=none {} \;
|
||||||
|
find ./include -iname *.h -o -iname *.c -exec clang-format -i -style=file -fallback-style=none {} \;
|
||||||
|
find ./demo -iname *.h -o -iname *.c -exec clang-format -i -style=file -fallback-style=none {} \;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -s -C lib clean
|
$(MAKE) -s -C lib clean
|
||||||
$(MAKE) -s -C demo clean
|
$(MAKE) -s -C demo clean
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# How to configure clang‐format
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
clang-format is an utility to format source code in several languages
|
||||||
|
according to predefined settings. Settings for auto-formatting of C source
|
||||||
|
files are summarized below, and should be saved in .clang-format file in root
|
||||||
|
folder. These settings are chosen to closely match the formatting style used.
|
||||||
|
|
||||||
|
## Configuring Editors
|
||||||
|
### Visual Studio Code
|
||||||
|
Install the C/C++ extension and customize settings.json to include:
|
||||||
|
|
||||||
|
"C_Cpp.clang_format_path": "/path/to/<clang-format-executable>",
|
||||||
|
"C_Cpp.clang_format_style": "file",
|
||||||
|
"C_Cpp.clang_format_fallbackStyle": "none"
|
||||||
|
|
||||||
|
### Emacs
|
||||||
|
Add the line
|
||||||
|
|
||||||
|
(load "/path/to/clang-format.el")
|
||||||
|
|
||||||
|
to `~/.emacs.d/init.el`. Format a source file with `M-x clang-format-region`.
|
||||||
|
|
||||||
|
### CLion
|
||||||
|
* Add the .clang-format file to the Kratos root directory as
|
||||||
|
explained aboveGo to File->Settings->Tools->External Tools
|
||||||
|
and click on the plus sign. A window should pop up.
|
||||||
|
Choose a name, for example "clang-format"
|
||||||
|
* For the Tool settings tab I'm using this configuration:
|
||||||
|
- Program: clang-format (you should use the name of your executable here)
|
||||||
|
- Parameters: --style=file -i $FileName$
|
||||||
|
- Working directory: $FileDir$
|
||||||
|
Now, with your file open, you can go to Tools->External tools and run the config above. It basically calls clang-format and does inplace formatting using the style define in the first .clang-format file found in a parent directory.
|
||||||
|
|
||||||
|
### .clang-format file
|
||||||
|
|
||||||
|
---
|
||||||
|
BasedOnStyle: Google
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
BreakBeforeBraces: Linux
|
||||||
|
IndentWidth: 4
|
||||||
|
SortIncludes: false
|
||||||
|
...
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
@echo off
|
|
||||||
rem fix DOS/Unix names and Subversion EOL-Style
|
|
||||||
rem unix2dos.exe from MSYS: mingw.sourceforge.net
|
|
||||||
rem svn.exe from Subversion Tools
|
|
||||||
call :treeProcess
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:treeProcess
|
|
||||||
rem fix all the specific files of this subdirectory:
|
|
||||||
for %%f in (*.c) do (
|
|
||||||
unix2dos.exe "%%f"
|
|
||||||
svn.exe propset svn:eol-style native "%%f"
|
|
||||||
svn.exe propset svn:mime-type text/plain "%%f"
|
|
||||||
)
|
|
||||||
for %%f in (*.h) do (
|
|
||||||
unix2dos.exe "%%f"
|
|
||||||
svn.exe propset svn:eol-style native "%%f"
|
|
||||||
svn.exe propset svn:mime-type text/plain "%%f"
|
|
||||||
)
|
|
||||||
for %%f in (*.bat) do (
|
|
||||||
unix2dos.exe "%%f"
|
|
||||||
svn.exe propset svn:eol-style native "%%f"
|
|
||||||
svn.exe propset svn:mime-type text/plain "%%f"
|
|
||||||
)
|
|
||||||
rem loop over all directories and sub directories
|
|
||||||
for /D %%d in (*) do (
|
|
||||||
cd %%d
|
|
||||||
call :treeProcess
|
|
||||||
cd ..
|
|
||||||
)
|
|
||||||
exit /b
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# fix DOS/Unix names and Subversion EOL-Style, and remove backup files
|
|
||||||
|
|
||||||
#DOS2UNIX=/usr/bin/dos2unix
|
|
||||||
DOS2UNIX=/usr/bin/fromdos
|
|
||||||
|
|
||||||
# exit silently if utility is not installed
|
|
||||||
[ -x ${DOS2UNIX} ] || exit 0
|
|
||||||
[ -x /usr/bin/svn ] || exit 0
|
|
||||||
|
|
||||||
directory=${1-`pwd`}
|
|
||||||
for filename in $( find ${directory} -name '*.c' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.h' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.bat' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.pl' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/x-script.perl ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.eww' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/xml ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.ewp' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/xml ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.cbp' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/xml ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.icf' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.htm' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/html ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.txt' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.lua' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/plain ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.sh' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/x-script.sh ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.b32' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/x-makefile ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.mak' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/x-makefile ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name 'Makefile' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propset svn:eol-style native ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type text/x-makefile ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.xls' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propdel svn:eol-style ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type application/excel ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*.ods' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix ${filename}
|
|
||||||
${DOS2UNIX} ${filename}
|
|
||||||
echo Setting Subversion EOL Style for ${filename}
|
|
||||||
/usr/bin/svn propdel svn:eol-style ${filename}
|
|
||||||
/usr/bin/svn propset svn:mime-type application/vnd.oasis.opendocument.spreadsheet ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find ${directory} -name '*~' )
|
|
||||||
do
|
|
||||||
echo Removing backup ${filename}
|
|
||||||
rm ${filename}
|
|
||||||
done
|
|
||||||
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
rem Indent the C and H files with specific coding standard
|
|
||||||
rem requires 'indent.exe' from MSYS (MinGW).
|
|
||||||
rem See http://www.gnu.org/software/indent/manual/indent.pdf
|
|
||||||
set OPTIONS=-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl
|
|
||||||
rem -kr The Kernighan & Ritchie style, corresponds to the following options:
|
|
||||||
rem -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
|
|
||||||
rem -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
|
|
||||||
rem -nprs -npsl -saf -sai -saw -nsc -nsob -nss
|
|
||||||
rem -nut Use spaces instead of tabs.
|
|
||||||
rem -nlp Do not line up parentheses.
|
|
||||||
rem -ip4 Indent parameter types in old-style function definitions by n spaces.
|
|
||||||
rem -cli4 Case label indent of n spaces.
|
|
||||||
rem -bfda Break the line before all arguments in a declaration.
|
|
||||||
rem -nbc Do not force newlines after commas in declarations.
|
|
||||||
rem -nbbo Do not prefer to break long lines before boolean operators.
|
|
||||||
rem -c0 Put comments to the right of code in column n.
|
|
||||||
rem -cd0 Put comments to the right of the declarations in column n.
|
|
||||||
rem -cp0 Put comments to the right of #else and #endif statements in column n.
|
|
||||||
rem -di0 Put variables in column n.
|
|
||||||
rem -l79 Set maximum line length for non-comment lines to n.
|
|
||||||
rem -nhnl Do not prefer to break long lines at the position of newlines in the input.
|
|
||||||
|
|
||||||
call :treeProcess
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:treeProcess
|
|
||||||
rem perform the indent on all the files of this subdirectory:
|
|
||||||
for %%f in (*.c) do (
|
|
||||||
indent.exe "%%f" -o "%%f" %OPTIONS%
|
|
||||||
)
|
|
||||||
for %%f in (*.h) do (
|
|
||||||
indent.exe "%%f" -o "%%f" %OPTIONS%
|
|
||||||
)
|
|
||||||
rem loop over all directories and sub directories
|
|
||||||
for /D %%d in (*) do (
|
|
||||||
cd %%d
|
|
||||||
call :treeProcess
|
|
||||||
cd ..
|
|
||||||
)
|
|
||||||
exit /b
|
|
||||||
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
@echo off
|
|
||||||
rem Indent the C and H files with specific coding standard
|
|
||||||
rem requires 'indent.exe' from MSYS (MinGW).
|
|
||||||
rem See http://www.gnu.org/software/indent/manual/indent.pdf
|
|
||||||
rem -kr The Kernighan & Ritchie style, corresponds to the following options:
|
|
||||||
rem -nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
|
|
||||||
rem -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
|
|
||||||
rem -nprs -npsl -saf -sai -saw -nsc -nsob -nss
|
|
||||||
rem -nut Use spaces instead of tabs.
|
|
||||||
rem -nlp Do not line up parentheses.
|
|
||||||
rem -ip4 Indent parameter types in old-style function definitions by n spaces.
|
|
||||||
rem -cli4 Case label indent of n spaces.
|
|
||||||
rem -bfda Break the line before all arguments in a declaration.
|
|
||||||
rem -nbc Do not force newlines after commas in declarations.
|
|
||||||
rem -nbbo Do not prefer to break long lines before boolean operators.
|
|
||||||
rem -c0 Put comments to the right of code in column n.
|
|
||||||
rem -cd0 Put comments to the right of the declarations in column n.
|
|
||||||
rem -cp0 Put comments to the right of #else and #endif statements in column n.
|
|
||||||
rem -di0 Put variables in column n.
|
|
||||||
rem -l79 Set maximum line length for non-comment lines to n.
|
|
||||||
rem -nhnl Do not prefer to break long lines at the position of newlines in the input.
|
|
||||||
|
|
||||||
echo Fixing Unix/DOS line endings for "%1"
|
|
||||||
unix2dos.exe "%1"
|
|
||||||
echo Setting Subversion EOL Style for "%1"
|
|
||||||
svn.exe propset svn:eol-style native "%1"
|
|
||||||
svn.exe propset svn:mime-type text/plain "%1"
|
|
||||||
echo Indenting "%1"
|
|
||||||
set OPTIONS=-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl
|
|
||||||
indent.exe "%1" -o "%1" %OPTIONS%
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
# indent uses a local indent.pro file if it exists
|
|
||||||
# File must be in consistent unix format before indenting
|
|
||||||
|
|
||||||
#DOS2UNIX=/usr/bin/dos2unix
|
|
||||||
DOS2UNIX=/usr/bin/fromdos
|
|
||||||
INDENT=/usr/bin/indent
|
|
||||||
REMOVE=/bin/rm
|
|
||||||
|
|
||||||
# exit silently if utility is not installed
|
|
||||||
[ -x ${INDENT} ] || exit 0
|
|
||||||
[ -x ${DOS2UNIX} ] || exit 0
|
|
||||||
|
|
||||||
INDENTRC=".indent.pro"
|
|
||||||
if [ ! -e ${INDENTRC} ]
|
|
||||||
then
|
|
||||||
echo No ${INDENTRC} file found. Creating ${INDENTRC} file.
|
|
||||||
echo "-kr -nut -nlp -ip4 -cli4 -bfda -nbc -nbbo -c0 -cd0 -cp0 -di0 -l79 -nhnl" > ${INDENTRC}
|
|
||||||
fi
|
|
||||||
|
|
||||||
directory=${1-`pwd`}
|
|
||||||
for filename in $( find $directory -name '*.c' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix $filename
|
|
||||||
${DOS2UNIX} $filename
|
|
||||||
echo Indenting $filename
|
|
||||||
${INDENT} $filename
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find $directory -name '*.h' )
|
|
||||||
do
|
|
||||||
echo Fixing DOS/Unix $filename
|
|
||||||
${DOS2UNIX} $filename
|
|
||||||
echo Indenting $filename
|
|
||||||
${INDENT} $filename
|
|
||||||
done
|
|
||||||
|
|
||||||
for filename in $( find $directory -name '*~' )
|
|
||||||
do
|
|
||||||
echo Removing backup $filename
|
|
||||||
${REMOVE} $filename
|
|
||||||
done
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user