diff --git a/C/scripts/build.sh b/C/scripts/build.sh new file mode 100755 index 0000000..654271e --- /dev/null +++ b/C/scripts/build.sh @@ -0,0 +1,7 @@ +#Compiles the entire program then runs it, producing an executable. +#C +printf "Running program...\n\n\n" +if gcc $(find . -type f -name "*.c") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then + ./${PROJECT_NAME} +fi +printf "\n\n" diff --git a/C/scripts/commit.sh b/C/scripts/commit.sh new file mode 100755 index 0000000..0f56a8f --- /dev/null +++ b/C/scripts/commit.sh @@ -0,0 +1,20 @@ +#Adds a commit message and pushes project to github repository. +#C +COMMIT_MESSAGE="$*" +FIRST_LINE=true +while IFS= read -r line +do +if [ "$FIRST_LINE" = true ]; then + COMMIT_MESSAGE+=" + +Co-authored-by: $line" +FIRST_LINE=false +else + COMMIT_MESSAGE+=" +Co-authored-by: $line" +fi +done < utils/.coauthors +git add -u +git add * +git commit -m "$COMMIT_MESSAGE" +git push \ No newline at end of file diff --git a/C/scripts/filelist b/C/scripts/filelist new file mode 100644 index 0000000..e0fa154 --- /dev/null +++ b/C/scripts/filelist @@ -0,0 +1,2 @@ +build.sh +commit.sh diff --git a/C/scripts/md5 b/C/scripts/md5 new file mode 100644 index 0000000..203bf2d --- /dev/null +++ b/C/scripts/md5 @@ -0,0 +1,2 @@ +build.sh:dbb1880f6b747ec208d6f277c0be61c2 - +commit.sh:89783d2e6a165aa9612c79cfbd804a35 - diff --git a/CProjectTemplate b/CProjectTemplate new file mode 100755 index 0000000..deadea3 Binary files /dev/null and b/CProjectTemplate differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc55afb --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +This repository provides a template for starting a new C project using Sig's build system! Updates are automatically propogated. Run `./sig` for a list of commands and then use follow the instructions given to invoke them. Adjust variables as necessary in the `sig` command file. + +``` +@sigonasr2 ➜ /workspaces/CProjectTemplate (main) $ ./sig +Dev build, no checks required. + + Usage: ./sig {args} + +==== Current Configuration ===================== + PROJECT_NAME CProjectTemplate + BUILD_OPTIONS -lncurses + LANGUAGE C +===================================================== + + Command List: + + build Compiles the entire program then runs it, producing an executable. + commit Adds a commit message and pushes project to github repository. +'`` \ No newline at end of file diff --git a/install b/install new file mode 100755 index 0000000..cf8dc5d --- /dev/null +++ b/install @@ -0,0 +1,15 @@ +echo "Initializing..." +FILES=$(ls -dA */) +LANGUAGES=() +for f in $FILES +do + if [ "$f" != "scripts/" ] && [ "$f" != "utils/" ]; + then + LANGUAGES+=(""${f::-1}"") + fi +done +echo "Languages Detected:" +for f in "${LANGUAGES[@]}" +do + printf "\t%-15s\n" $f +done \ No newline at end of file diff --git a/main b/main index 19612d0..9e02579 100755 Binary files a/main and b/main differ diff --git a/main.c b/main.c index 8dc52d3..80dd67b 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,7 @@ #include #include #include "extras.h" +#include "utils/utils.h" int main(int argc,char**argv) { int rows,cols; @@ -21,6 +22,7 @@ int main(int argc,char**argv) { addch(ACS_BTEE); addch(' '); writeExtras(); + testReach(); mvaddch(5,17,ACS_DARROW); attron(COLOR_PAIR(1)); diff --git a/sig b/sig new file mode 100755 index 0000000..92f6cdb --- /dev/null +++ b/sig @@ -0,0 +1,9 @@ +export AUTO_UPDATE=true + +source utils/define.sh + +define PROJECT_NAME "main" +define CUSTOM_PARAMS "-lncurses" +define LANGUAGE "C" + +source utils/main.sh \ No newline at end of file diff --git a/utils/.coauthors b/utils/.coauthors new file mode 100644 index 0000000..b904d0f --- /dev/null +++ b/utils/.coauthors @@ -0,0 +1 @@ +sigonasr2 diff --git a/utils/.updateDirectories b/utils/.updateDirectories new file mode 100644 index 0000000..0c078d1 --- /dev/null +++ b/utils/.updateDirectories @@ -0,0 +1,4 @@ +Java/ +C/ +scripts/ +utils/ \ No newline at end of file diff --git a/utils/define.sh b/utils/define.sh new file mode 100755 index 0000000..214fc50 --- /dev/null +++ b/utils/define.sh @@ -0,0 +1,26 @@ +export VARS=("") + +export LANGUAGE="" + +function define() { + VARS+=("$1") + value="${*:2}" + eval export "$1"='$value' +} + +if [[ $(pwd) != *"SigScript" && $AUTO_UPDATE = "true" && $1 != "update" ]]; then + source utils/search.sh + + find . -type f -name md5 -delete + find . -type f -name filelist -delete + + #Check for hashes + FILES=$(cat utils/.updateDirectories) + for f in $FILES + do + search $f + check $f + done +else + echo "Dev build, no checks required." +fi \ No newline at end of file diff --git a/utils/filelist b/utils/filelist new file mode 100644 index 0000000..3e39f04 --- /dev/null +++ b/utils/filelist @@ -0,0 +1,7 @@ +.coauthors +define.sh +main.sh +search.sh +.updateDirectories +utils.c +utils.h diff --git a/utils/main.sh b/utils/main.sh new file mode 100644 index 0000000..d299d6b --- /dev/null +++ b/utils/main.sh @@ -0,0 +1,28 @@ +if [ -z "$1" ] + then + echo "" + echo " Usage: ./sig {args}" + echo "" + printf "====\tCurrent Configuration" + printf "\t=====================" + for t in ${VARS[@]} + do + printf "\n\t%-15s%20s" $t ${!t} + done + printf "\n=====================================================" + echo "" + echo "" + echo " Command List:" + FILES=$(ls -1A ./$LANGUAGE/scripts 2>/dev/null | sed -e 's/\.sh$//' | sed -e 's/^/ /') + for f in $FILES + do + if [ -f "./$LANGUAGE/scripts/$f.sh" ]; then + DESC="$(head -n1 ./$LANGUAGE/scripts/$f.sh)" + printf "\n\t%-15s%-65s" $f "${DESC:1}" + fi + done + echo "" + exit +fi + +./$LANGUAGE/scripts/$1.sh "${*:2}" \ No newline at end of file diff --git a/utils/md5 b/utils/md5 new file mode 100644 index 0000000..1608562 --- /dev/null +++ b/utils/md5 @@ -0,0 +1,6 @@ +define.sh:3ecab0dffe2adfb950f3eb7c7061b750 - +main.sh:d3d1bd0b56d8114eb7479964227f8576 - +search.sh:81d08f5ff48e8a44b5f68387d426da05 - +.updateDirectories:fa5e95db12be22ae8aed7ecbc560e38c - +utils.c:dda26981cc7c9e9a62110e8db54e582f - +utils.h:324dca30e95cbdf1effb042813da858d - diff --git a/utils/search.sh b/utils/search.sh new file mode 100644 index 0000000..99a69b3 --- /dev/null +++ b/utils/search.sh @@ -0,0 +1,103 @@ +function search() { + FILES2=$(ls -A $1 2>/dev/null) + for g in $FILES2 + do + if [ -d $1$g ]; + then + echo "$1$g is a directory" + search $1$g/ + else + echo "$1$g is a file" + if [ $g != "md5" ] && [ $g != "filelist" ] && [ $g != ".package.files" ]; then + if [ $g != ".coauthors" ] && [ $g != "version_info" ]; then + SUM=$(md5sum < $1$g) + echo "$g:$SUM" >> $1md5 + fi + echo "$g" >> $1filelist + else + echo " ignoring $g..." + fi + fi + done +} + +function check() { + echo "Check $1" + FILES2=$(ls -A $1 2>/dev/null) + if [ -f "$1/md5" ]; + then + echo " md5: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1md5" --output /tmp/out + cmp -s $1/md5 /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + if [ -f "$1/filelist" ]; + then + echo " filelist: https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" + curl -H 'Cache-Control: no-cache, no-store' -s "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1filelist" --output /tmp/out + cmp -s $1/filelist /tmp/out + if [ "$?" -ne 0 ] + then + echo " Differences detected!" + cat /tmp/out + while IFS= read -r line + do + IFS=':' read -ra split <<< $line + g="${split[0]}" + echo "LINE -- $g" + if [ "$g" != "md5" ] && [ "$g" != "filelist" ] && [ "$g" != ".package.files" ]; then + if [ -f $1$g ]; + then + if [ "$g" != ".coauthors" ] && [ "$g" != "version_info" ]; then + echo "++Redownload $1$g..." + if [ -f "$1$g" ]; then + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + else + echo "===Could not find directory, assuming regular scripts directory exists." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $LANGUAGE/scripts/$g + fi + fi + else + echo "++==Downloading $1$g..." + curl -H 'Cache-Control: no-cache, no-store' "https://raw.githubusercontent.com/sigonasr2/SigScript/main/$1$g" --output $1$g + fi + fi + done < /tmp/out + fi + fi + for g in $FILES2 + do + if [ -d $1$g ]; + then + echo "$1$g is a directory" + check $1$g/ + fi + done +} diff --git a/utils/utils.c b/utils/utils.c new file mode 100644 index 0000000..2f20b91 --- /dev/null +++ b/utils/utils.c @@ -0,0 +1,6 @@ +#include +#include "utils.h" + +void testReach() { + addch(ACS_DEGREE); +} \ No newline at end of file diff --git a/utils/utils.h b/utils/utils.h new file mode 100644 index 0000000..4828daf --- /dev/null +++ b/utils/utils.h @@ -0,0 +1 @@ +void testReach(); \ No newline at end of file