generated from sigonasr2/CPlusPlusProjectTemplate
Initial commit
This commit is contained in:
commit
c806774ad2
7
C++/scripts/build.sh
Executable file
7
C++/scripts/build.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#Compiles the entire program then runs it, producing an executable.
|
||||||
|
#C++
|
||||||
|
printf "Running program...\n\n\n"
|
||||||
|
if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then
|
||||||
|
./${PROJECT_NAME} "$@"
|
||||||
|
fi
|
||||||
|
printf "\n\n"
|
20
C++/scripts/commit.sh
Executable file
20
C++/scripts/commit.sh
Executable file
@ -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
|
3
C++/scripts/filelist
Normal file
3
C++/scripts/filelist
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build.sh
|
||||||
|
commit.sh
|
||||||
|
web.sh
|
3
C++/scripts/md5
Normal file
3
C++/scripts/md5
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build.sh:530634457ea9041267c05d4ced95eee1 -
|
||||||
|
commit.sh:d03a46e721060c22ccb146e19d27e70a -
|
||||||
|
web.sh:3229cb0053cd0ca4ea08cc90e0d50ad0 -
|
14
C++/scripts/web.sh
Executable file
14
C++/scripts/web.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#Compiles emscripten instance of this project for the web.
|
||||||
|
#C++
|
||||||
|
if [ -d "assets" ]; then
|
||||||
|
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets
|
||||||
|
else
|
||||||
|
em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp") -o ${PROJECT_NAME}.html -I pixelGameEngine.h
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "headless" ]; then
|
||||||
|
echo "Running as headless web server"
|
||||||
|
emrun --no_browser ${PROJECT_NAME}.html
|
||||||
|
else
|
||||||
|
emrun --serve_after_close ${PROJECT_NAME}.html
|
||||||
|
fi
|
BIN
C++ProjectTemplate
Executable file
BIN
C++ProjectTemplate
Executable file
Binary file not shown.
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
This repository contains general build scripts and pipelines for all languages that I incorporate in my projects. The goal is to provide an easy retrieval and update system for the project. Each script will be a shell script containing the following template:
|
||||||
|
```bash
|
||||||
|
#Short description about what I do
|
||||||
|
#Language[Folder]
|
||||||
|
# #The script's code goes in here.
|
||||||
|
# rm -Rf out/*
|
||||||
|
# javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java
|
||||||
|
# printf "\n\n\nRunning Program...\n\n"
|
||||||
|
# cd $OUT_DIR
|
||||||
|
# java ${MAIN_CLASS} "$@"
|
||||||
|
# ../scripts/clean.sh
|
||||||
|
|
||||||
|
```
|
||||||
|
Each language will be in the following structure:
|
||||||
|
```
|
||||||
|
-<Language>
|
||||||
|
--<scripts>
|
||||||
|
---[script files.sh]
|
||||||
|
```
|
||||||
|
|
||||||
|
The `sig` script will display by default any scripts in the `scripts` folder, therefore when creating a project, copy over the scripts folder of the desired language into your project then the `sig` script handles the rest appropriately. If your project requires multiple languages and build setups, then you can use the `sig2` command, which has an additional parameter to specify the language when running it. When setting up a multi-language setup, you'll just copy the entire folder to include the programming language itself. So a multi-language project structure may look something like this:
|
||||||
|
```
|
||||||
|
-C
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---make.sh
|
||||||
|
-Java
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---jar.sh
|
||||||
|
```
|
46
main.cpp
Normal file
46
main.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#define OLC_PGE_APPLICATION
|
||||||
|
#include "pixelGameEngine.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
class Example : public olc::PixelGameEngine
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Example()
|
||||||
|
{
|
||||||
|
sAppName = "Example";
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool OnUserCreate() override
|
||||||
|
{
|
||||||
|
SetPixelMode(olc::Pixel::ALPHA);
|
||||||
|
ConsoleCaptureStdOut(true);
|
||||||
|
// Called once at the start, so create things here
|
||||||
|
for (int x = 0; x < ScreenWidth(); x++)
|
||||||
|
for (int y = 0; y < ScreenHeight(); y++)
|
||||||
|
Draw(x, y, olc::Pixel(rand() % 255, rand() % 255, rand()% 255));
|
||||||
|
for (int x=0;x<50;x++) {
|
||||||
|
for (int y=0;y<50;y++) {
|
||||||
|
Draw(x, y, olc::Pixel(255, 0, 0, 128));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnUserUpdate(float fElapsedTime) override
|
||||||
|
{
|
||||||
|
// called once per frame
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Example demo;
|
||||||
|
if (demo.Construct(256, 240, 4, 4))
|
||||||
|
demo.Start();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
6191
pixelGameEngine.h
Normal file
6191
pixelGameEngine.h
Normal file
File diff suppressed because it is too large
Load Diff
9
sig
Executable file
9
sig
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
export AUTO_UPDATE=true
|
||||||
|
|
||||||
|
source utils/define.sh
|
||||||
|
|
||||||
|
define PROJECT_NAME "C++ProjectTemplate"
|
||||||
|
define CUSTOM_PARAMS "-lpng -lGL -lX11"
|
||||||
|
define LANGUAGE "C++"
|
||||||
|
|
||||||
|
source utils/main.sh
|
1
utils/.coauthors
Normal file
1
utils/.coauthors
Normal file
@ -0,0 +1 @@
|
|||||||
|
sigonasr2 <sigonasr2@gmail.com>
|
5
utils/.updateDirectories
Normal file
5
utils/.updateDirectories
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
Java/
|
||||||
|
C/
|
||||||
|
C++/
|
||||||
|
scripts/
|
||||||
|
utils/
|
26
utils/define.sh
Executable file
26
utils/define.sh
Executable file
@ -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
|
5
utils/filelist
Normal file
5
utils/filelist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.coauthors
|
||||||
|
define.sh
|
||||||
|
main.sh
|
||||||
|
search.sh
|
||||||
|
.updateDirectories
|
28
utils/main.sh
Normal file
28
utils/main.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo " Usage: ./sig <command> {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}"
|
4
utils/md5
Normal file
4
utils/md5
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
define.sh:3ecab0dffe2adfb950f3eb7c7061b750 -
|
||||||
|
main.sh:4e6e9f0650ec790ce2c4364db94f0caa -
|
||||||
|
search.sh:30e1842e9a13452ea883bb6516d28e1c -
|
||||||
|
.updateDirectories:971afb892e8280cb4c9ad43fb72a46a0 -
|
103
utils/search.sh
Normal file
103
utils/search.sh
Normal file
@ -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: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1md5"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/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' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/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' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $1$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < /tmp/out
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -f "$1/filelist" ];
|
||||||
|
then
|
||||||
|
echo " filelist: http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1filelist"
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' -s "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/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' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/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' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/main/$1$g" --output $LANGUAGE/scripts/$g
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "++==Downloading $1$g..."
|
||||||
|
curl -H 'Cache-Control: no-cache, no-store' "http://sig.projectdivar.com/sigonasr2/SigScript/raw/branch/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
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user