Sparky
Sparky copied to clipboard
Flexable Emscripten bat
TL;DR : Made a auto cpp adding batch file.
Not sure if you are going to keep using a batch file but since I was having a look at emscripten with SDL2 and got sick of adding the cpp files every time I made a new one I decided to make the batch file that I was working with slightly better.
This allowed me to quickly adapt it to the sparky engine. while testing it on my machine tho it was saying something about the bc files not matching so I couldn't see if it worked. (it should work just as if you had wrote them unless i buggered up somehow) EDIT: fixed for folders with spaces. EDIT2: Updated to reflect changes in ep 26 ?
@echo off
SETLOCAL enabledelayedexpansion enableextensions
CALL:Setup
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Automatically add all Sparky base files.
:: ::::::::::::::::::::: :::::::::::::::::::::
CALL:SearchForSourceFiles ..\Sparky-core\src
SET "SparkyFiles=%returnString%"
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Get Game files.
:: ::::::::::::::::::::: :::::::::::::::::::::
CALL:SearchForSourceFiles ..\Sparky-core\examples
SET "GameFiles=%returnString%"
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Compile everything.
:: ::::::::::::::::::::: :::::::::::::::::::::
CALL:Compile
goto:eof
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Setup needed variables
:: ::::::::::::::::::::: :::::::::::::::::::::
:Setup
:: Grab parent directory
pushd "%~dp0%"
pushd ..
SET parentFolder=%cd%
popd
popd
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Settings for emscripten
:: ::::::::::::::::::::: :::::::::::::::::::::
SET returnString=
SET AddedJavaScript= --post-js SoundManager.js
SET MemoryFileGen= --memory-init-file 0
SET OptimizationLevel= -O3
SET EmbedFolders= res
SET LibraryBinFiles= freetype.bc freeimage.bc
SET OutputName= Web\sparky.html
goto:eof
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Find all .cpp files, trim them for the
:: | right paths and concatinate them.
:: | @Param <string> folder location
:: | @Return <string> returnString
:: ::::::::::::::::::::: :::::::::::::::::::::
:SearchForSourceFiles
SETLOCAL
SET FolderLocation=%1
SET FoundFiles=
SET REPLACETEXT=..
FOR /F "delims=" %%i in ('dir /b /s "%FolderLocation%\*.cpp"') DO (
SET "string=%%i"
SET modFilePath=!string:%parentFolder%=%REPLACETEXT%!
SET "FoundFiles=!FoundFiles! !modFilePath!"
)
ENDLOCAL & SET returnString=%FoundFiles%
goto:eof
:: ::::::::::::::::::::: :::::::::::::::::::::
:: Combine all files found in locations
:: ::::::::::::::::::::: :::::::::::::::::::::
:Compile
call emcc -std=c++11 -I"../Dependencies/Freeimage/include" %SparkyFiles% %GameFiles% %LibraryBinFiles% -s USE_GLFW=3 -s FULL_ES3=1 %EmbedFolders% %AddedJavaScript% %MemoryFileGen% %OptimizationLevel% -o %OutputName% & PAUSE
goto:eof
I placed the pause in there so you can just run the .bat file without having to open cmd it will stay open and give errors
Also on the note of debugging remember you can use
-g4 will give you better debugging ;D