Compare commits

...

7 Commits

Author SHA1 Message Date
Jake Goodwin 9343842eae removed whitespace 2024-08-04 09:28:29 -07:00
Jake Goodwin b83b28af84 removed filecheck for formatting file. 2024-08-04 09:28:22 -07:00
Jake Goodwin c734ede4e6 fixed cli flags
The style flag/option needed to be changed. Also removed problamatic line from config.
2024-08-04 09:27:15 -07:00
Jake Goodwin 0a9d348710 added option
Added the inplace editing option.
2024-08-04 08:43:07 -07:00
Jake Goodwin 0723cb259b Added function for clang formatting.
The shell function finds all the C source and header files in the './src' directory; then it
applies the formatting specified in the .clang-format file.

Right now it only runs when the ctests shell function is called.
2024-08-04 08:40:53 -07:00
Jake Goodwin 77364c22d1 Updated to 'Allman' or 'BSD' style.
This is what I found on a stackoverflow post for their recommended settings for the allman style.
I'm going to try it for awhile and see what I think.
2024-08-04 08:11:49 -07:00
Jake Goodwin 385abf37ea Adding a formating file.
The '.clang-format' file is a configuration file for the llvm/clang formatting tools.
2024-08-04 07:56:05 -07:00
3 changed files with 66 additions and 1 deletions

48
.clang-format Normal file
View File

@ -0,0 +1,48 @@
# ---
Language: Cpp
# The Based on style flag causes nothing to work.
#BasedOnStyle: None
AlignTrailingComments: true
AlignArrayOfStructures: Left
AlignConsecutiveAssignments:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveDeclarations:
Enabled: true
AcrossEmptyLines: true
AcrossComments: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatementsOnASingleLine: true
BreakBeforeBraces: Allman
ColumnLimit: 0
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
TabWidth: 8
UseTab: Never

18
otto.sh
View File

@ -10,6 +10,23 @@ TEMPLATE_FILES=".template_files"
MODULE_DIR="${TEMPLATE_FILES}/modules"
format_source_code () {
#Get a list of all C files
source_c_files=$(find ./src -name '*.c')
for f in $source_c_files; do
clang-format -i -style=file $f
done
#Get a list of all H files
source_h_files=$(find ./src -name '*.h')
for f in $source_h_files; do
clang-format -i -style=file $f
done
echo "Applying Formating standard!"
}
add_compile_commands () {
if [ -f ./compile_commands.json ]; then
echo "compile_commands.json already exists!\n"
@ -172,6 +189,7 @@ build_main () {
}
run_c_tests () {
format_source_code
clear_cmake_cache
cmake -DUNIT_TESTING=ON -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE} ../
make AllTests && ./tests/AllTests

View File

@ -5,4 +5,3 @@ int main(int argc, char **argv)
printf("Hello!\n");
return 0;
}