Browse Source

Upgrade cgen to also create a .gitignore and .clang-format

master
Taylor Bockman 5 years ago
parent
commit
9f00efe281
  1. 11
      dotfiles/bash/scripts/cgen.sh
  2. 13
      dotfiles/bash/scripts/cgen_etc/template_clang_format
  3. 83
      dotfiles/bash/scripts/cgen_etc/template_gitignore

11
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 <stdio.h>" >> $sample_file

13
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'

83
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~
Loading…
Cancel
Save