From 9f00efe281a903cef2f82aad00de45304e18e1d8 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Thu, 19 Dec 2019 22:31:31 -0800 Subject: [PATCH] Upgrade cgen to also create a .gitignore and .clang-format --- dotfiles/bash/scripts/cgen.sh | 11 ++- .../bash/scripts/cgen_etc/template_clang_format | 13 ++++ dotfiles/bash/scripts/cgen_etc/template_gitignore | 83 ++++++++++++++++++++++ 3 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 dotfiles/bash/scripts/cgen_etc/template_clang_format create mode 100644 dotfiles/bash/scripts/cgen_etc/template_gitignore diff --git a/dotfiles/bash/scripts/cgen.sh b/dotfiles/bash/scripts/cgen.sh index f611dd1..1d9344a 100755 --- a/dotfiles/bash/scripts/cgen.sh +++ b/dotfiles/bash/scripts/cgen.sh @@ -4,6 +4,9 @@ name=$1 cmake_version=$2 c_standard=$3 +# Finds the directory of this script +script_dir=$(cd "$( dirname "`readlink -f ${BASH_SOURCE[0]}`")" && pwd) + if [ -z $name ] then echo "Name must be specified" @@ -32,7 +35,6 @@ cmake_config=$name/CMakeLists.txt touch $cmake_config - echo "cmake_minimum_required(VERSION $cmake_version)" >> $cmake_config echo "project($name)" >> $cmake_config echo "" >> $cmake_config @@ -68,6 +70,13 @@ echo "ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)" >> $cmake_config echo "" >> $cmake_config echo "add_executable($name \${SOURCE} \${INCLUDE})" >> $cmake_config + +echo "Copying .clang-format..." +cp $script_dir/cgen_etc/template_clang_format $name/.clang-format + +echo "Copying .gitignore..." +cp $script_dir/cgen_etc/template_gitignore $name/.gitignore + sample_file=$name/src/main.c echo "#include " >> $sample_file diff --git a/dotfiles/bash/scripts/cgen_etc/template_clang_format b/dotfiles/bash/scripts/cgen_etc/template_clang_format new file mode 100644 index 0000000..94ff769 --- /dev/null +++ b/dotfiles/bash/scripts/cgen_etc/template_clang_format @@ -0,0 +1,13 @@ +AlignConsecutiveAssignments: 'true' +AlignTrailingComments: 'true' +AllowShortBlocksOnASingleLine: 'false' +AllowShortCaseLabelsOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: 'false' +BreakBeforeBraces: Allman +ColumnLimit: '120' +IndentWidth: '4' +PointerAlignment: Right +SortIncludes: 'false' + diff --git a/dotfiles/bash/scripts/cgen_etc/template_gitignore b/dotfiles/bash/scripts/cgen_etc/template_gitignore new file mode 100644 index 0000000..1d8cedd --- /dev/null +++ b/dotfiles/bash/scripts/cgen_etc/template_gitignore @@ -0,0 +1,83 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# VSCode + +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Vim + +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~