diff --git a/C++/scripts/build.sh b/C++/scripts/build.sh index bbdb7f6..0088e5b 100755 --- a/C++/scripts/build.sh +++ b/C++/scripts/build.sh @@ -1,4 +1,4 @@ -#Compiles the entire program then runs it, producing an executable. If the "test" argument is included, will try and run tests too (in the test folder) +#Compiles the entire program then runs it, producing an executable. If the "test" argument is included, will try and run tests too (in the test folder). If the "full" argument is included, it will recopmile the PixelGameEngine (should it change) #C++ printf "Running program...\n\n\n" output=$(dpkg -l | grep libx11-dev) @@ -6,16 +6,28 @@ if [[ -z $output ]] then sudo apt install libx11-dev libpulse-dev mesa-common-dev libpng-dev fi +if [ ! -f "pixelGameEngine.o" ] +then + printf "Pixel Game Engine compile object missing. Compiling for the first time..." + g++ -c pixelGameEngine.cpp +fi if [ "$1" = "test" ] then printf "Running tests...\n" echo "#define TEST_SUITE" > ./test/test.h - if g++ $(find . -type f -name "*.cpp") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then + if g++ $(find . -type f -name "*.cpp" -not -name "pixelGameEngine.cpp") pixelGameEngine.o ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then + ./${PROJECT_NAME} "$@" + fi +elif [ "$1" = "full" ] +then + echo "" > ./test/test.h + g++ -c pixelGameEngine.cpp + if g++ $(find . -type f -name "*.cpp" -not -path "./test/*" -not -name "pixelGameEngine.cpp") pixelGameEngine.o ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then ./${PROJECT_NAME} "$@" fi else echo "" > ./test/test.h - if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then + if g++ $(find . -type f -name "*.cpp" -not -path "./test/*" -not -name "pixelGameEngine.cpp") pixelGameEngine.o ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then ./${PROJECT_NAME} "$@" fi fi diff --git a/C++/scripts/md5 b/C++/scripts/md5 index 45f0dae..a8438a6 100644 --- a/C++/scripts/md5 +++ b/C++/scripts/md5 @@ -1,7 +1,7 @@ -build.sh:d5e4e98a6f677aa0a9759ba0afb2fb77 - +build.sh:f7da5b6f54c56658f5410e0df797b5a7 - commit.sh:d03a46e721060c22ccb146e19d27e70a - debug.sh:849488515cab075948653c15eec4177b - lines.sh:3b907786f7fc9204025993016c9080de - -release.sh:6a96fb84ba64ed60d31be436ec069f05 - +release.sh:0ab321c3fa2f1a1b2f03b1aec3bce816 - temp:d41d8cd98f00b204e9800998ecf8427e - -web.sh:b982212b88b80a59ad607b47d2ff3e94 - +web.sh:e317e1d492d00517a0ac0e460239daa0 - diff --git a/C++/scripts/release.sh b/C++/scripts/release.sh index 2f84395..c1a95a6 100755 --- a/C++/scripts/release.sh +++ b/C++/scripts/release.sh @@ -1,4 +1,4 @@ -#Creates a release build that focuses on high runtime performance. +#Creates a release build that focuses on high runtime performance. Use "full" argument to completely rebuild PGE. #C++ printf "Running program...\n\n\n" output=$(dpkg -l | grep libx11-dev) @@ -6,7 +6,15 @@ if [[ -z $output ]] then sudo apt install libx11-dev libpulse-dev mesa-common-dev libpng-dev fi -if g++ $(find . -type f -name "*.cpp" -not -path "./test/*") ${CUSTOM_PARAMS} -O3 -s -DNDEBUG -o ${PROJECT_NAME}; then +if [ "$1" == "full" ]; then + rm "pixelGameEngine.o" +fi +if [ ! -f "pixelGameEngine.o" ] +then + printf "Pixel Game Engine compile object missing. Compiling for the first time..." + g++ -c pixelGameEngine.cpp +fi +if g++ $(find . -type f -name "*.cpp" -not -path "./test/*" -not -name "pixelGameEngine.cpp") pixelGameEngine.o ${CUSTOM_PARAMS} -o ${PROJECT_NAME}; then ./${PROJECT_NAME} "$@" fi printf "\n\n" diff --git a/C++/scripts/web.sh b/C++/scripts/web.sh index c46d605..2ae0a7c 100755 --- a/C++/scripts/web.sh +++ b/C++/scripts/web.sh @@ -1,23 +1,30 @@ -#Compiles emscripten instance of this project for the web. +#Compiles emscripten instance of this project for the web. Use "full" argument if your PGE has to be completely rebuilt. Use "headless" argument for a headless version. #C++ output=$(dpkg -l | grep libx11-dev) if [[ -z $output ]] then sudo apt install libx11-dev libpulse-dev mesa-common-dev libpng-dev fi +if [[ "$1" == "full" || "$2" == "full" ]]; then + rm "pixelGameEngine_wasm.o" +fi +if [ ! -f "pixelGameEngine_wasm.o" ] +then + printf "Pixel Game Engine compile object missing. Compiling for the first time..." + em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 -c pixelGameEngine.cpp -o pixelGameEngine_wasm.o +fi 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_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h --preload-file ./assets + em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*" -not -name "pixelGameEngine.cpp") pixelGameEngine_wasm.o -o ${PROJECT_NAME}.html --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_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*") -o ${PROJECT_NAME}.html -I pixelGameEngine.h + em++ -std=c++17 -O2 -s ALLOW_MEMORY_GROWTH=1 -s MAX_WEBGL_VERSION=2 -s MIN_WEBGL_VERSION=2 -s USE_SDL_MIXER=2 -s USE_LIBPNG=1 $(find . -type f -name "*.cpp" -not -path "./test/*" -not -name "pixelGameEngine.cpp") pixelGameEngine_wasm.o -o ${PROJECT_NAME}.html fi cp buildtemplate.html ${PROJECT_NAME}.html sed -i "s/_REPLACEME_/$PROJECT_NAME.js/" ${PROJECT_NAME}.html -if [ "$1" == "headless" ]; then +if [[ "$1" == "headless" || "$2" == "headless" ]]; then echo "Running as headless web server" emrun --no_browser ${PROJECT_NAME}.html else emrun --serve_after_close ${PROJECT_NAME}.html -fi - +fi \ No newline at end of file