-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
277 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
REM @echo off | ||
setlocal enabledelayedexpansion | ||
|
||
set ROOT_PATH="%CD%" | ||
set TEMP_ROOT="%ROOT_PATH%\..\..\temporary" | ||
set CPP_VERSION="-std=c++14" | ||
set MODE="-DDEBUG" | ||
set DEBUGGER="-g" | ||
set SIMD="-march=native" | ||
set O_LEVEL="-O2" | ||
|
||
echo "ROOT_PATH is %ROOT_PATH%" | ||
echo "TEMP_ROOT is %TEMP_ROOT%" | ||
echo "CPP_VERSION is %CPP_VERSION%" | ||
echo "MODE is %MODE%" | ||
echo "DEBUGGER is %DEBUGGER%" | ||
echo "SIMD is %SIMD%" | ||
echo "O_LEVEL is %O_LEVEL%" | ||
|
||
REM Allow calling the build script | ||
call "%ROOT_PATH%\tools\build.bat" | ||
call "%ROOT_PATH%\tools\buildScripts\build.bat" "NONE" "NONE" "%ROOT_PATH%" "%TEMP_ROOT%" "NONE" "%MODE% %DEBUGGER% %SIMD% %CPP_VERSION% %O_LEVEL%" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
REM Get the specific temporary sub-folder for the compilation settings | ||
set TEMP_DIR="%MODE%_%DEBUGGER%_%SIMD%_%CPP_VERSION%_%O_LEVEL%" | ||
|
||
REM Remove previous test case and application | ||
del /f /q "%TEMP_DIR%\*_test.o" | ||
del /f /q "%TEMP_DIR%\application" | ||
|
||
REM Compile and run test cases | ||
for %%F in (.\test\tests\*.cpp) do ( | ||
if exist "%%F" ( | ||
set "name=%%~nxF" | ||
set "base=%%~nF" | ||
echo Compiling !name! | ||
g++ %CPP_VERSION% %MODE% %DEBUGGER% %SIMD% -c "%%F" -o "%TEMP_DIR%\!base!_test.o" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
REM Linking with frameworks | ||
echo Linking !name! | ||
g++ "%TEMP_DIR%\*.o" "%TEMP_DIR%\*.a" -lm -pthread -o "%TEMP_DIR%\application" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
REM Run the test case | ||
echo Executing !name! | ||
"%TEMP_DIR%\application" | ||
if errorlevel 0 ( | ||
echo Passed !name! | ||
) else ( | ||
echo Failed !name! | ||
REM Re-run with a memory debugger (gdb) | ||
gdb -ex "run" -ex "bt" -ex "quit" --args "%TEMP_DIR%\application" | ||
exit /b 1 | ||
) | ||
) | ||
) | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
REM @echo off | ||
setlocal enabledelayedexpansion | ||
|
||
REM Load arguments into named variables in order | ||
set PROJECT_FOLDERS=%1 REM Where your code is as a space separated list of folders in a quote | ||
set TARGET_FILE=%2 REM Your executable to build | ||
set ROOT_PATH=%3 REM The parent folder of DFPSR, SDK and tools | ||
set TEMP_ROOT=%4 REM Where your temporary objects should be | ||
set WINDOW_MANAGER=%5 REM Which library to use for creating a window | ||
set COMPILER_FLAGS=%6 REM -DDEBUG/-DNDEBUG -std=c++14/-std=c++17 -O2/-O3 | ||
set LINKER_FLAGS=%7 REM Additional linker flags for libraries and such | ||
|
||
REM Replace space with underscore | ||
set TEMP_SUB="%COMPILER_FLAGS: =_%" | ||
REM Replace + with p | ||
set TEMP_SUB="%TEMP_SUB:+=p%" | ||
REM Remove = | ||
set TEMP_STRING="" | ||
for /l %%i in (0,1,1000000) do ( | ||
set char=!TEMP_SUB:~%%i,1! | ||
if defined char ( | ||
if not !char! == = ( | ||
set TEMP_STRING=!TEMP_STRING!!char! | ||
) | ||
) else ( | ||
goto :done | ||
) | ||
) | ||
:done | ||
set TEMP_SUB=!TEMP_STRING! | ||
REM Remove - | ||
SET "TEMP_SUB=%TEMP_SUB:-=%" | ||
set TEMP_DIR="%TEMP_ROOT%\%TEMP_SUB%" | ||
echo Building version %TEMP_SUB% | ||
|
||
REM Allow calling other scripts | ||
chmod +x "%ROOT_PATH%\tools\buildScripts\clean.bat" | ||
chmod +x "%ROOT_PATH%\tools\buildScripts\buildLibrary.bat" | ||
|
||
REM Make a clean folder | ||
call "%ROOT_PATH%\tools\buildScripts\clean.bat" "%TEMP_DIR%" | ||
|
||
echo Compiling renderer framework. | ||
call "%ROOT_PATH%\tools\buildScripts\buildLibrary.bat" g++ "%ROOT_PATH%\DFPSR" "%TEMP_DIR%" "dfpsr" "%COMPILER_FLAGS%" LAZY | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
REM Abort if the project folder is replaced with the NONE keyword | ||
if "%PROJECT_FOLDERS%"=="NONE" ( | ||
exit /b 0 | ||
) | ||
|
||
echo Compiling application. | ||
call "%ROOT_PATH%\tools\buildScripts\buildLibrary.bat" g++ "%PROJECT_FOLDERS%" "%TEMP_DIR%" "application" "%COMPILER_FLAGS%" CLEAN | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
REM Select the base libraries needed by the framework itself | ||
set BASELIBS=-lm -pthread | ||
|
||
REM Select window manager to compile and libraries to link | ||
if "%WINDOW_MANAGER%"=="NONE" ( | ||
REM Embedded/terminal mode | ||
set WINDOW_SOURCE=%ROOT_PATH%\windowManagers\NoWindow.cpp | ||
set LIBS=%BASELIBS% %LINKER_FLAGS% | ||
) else ( | ||
REM Desktop GUI mode | ||
set WINDOW_SOURCE=%ROOT_PATH%\windowManagers\%WINDOW_MANAGER%Window.cpp | ||
set LIBS=%BASELIBS% %LINKER_FLAGS% -l%WINDOW_MANAGER% | ||
) | ||
|
||
echo Compiling window manager (%WINDOW_SOURCE%) | ||
g++ %COMPILER_FLAGS% -Wall -c "%WINDOW_SOURCE%" -o "%TEMP_DIR%\NativeWindow.o" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
echo Linking application with libraries (%LIBS%) | ||
REM Main must exist in the first library when linking | ||
g++ "%TEMP_DIR%\application.a" "%TEMP_DIR%\NativeWindow.o" %LIBS% "%TEMP_DIR%\dfpsr.a" -o "%TARGET_FILE%" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
REM @echo off | ||
setlocal enabledelayedexpansion | ||
|
||
REM Load arguments into named variables in order | ||
set PROJECT_FOLDERS=%1 REM Where your code is as a space separated list of folders in a quote | ||
set TARGET_FILE=%2 REM Your executable to build | ||
set ROOT_PATH=%3 REM The parent folder of DFPSR, SDK and tools | ||
set TEMP_ROOT=%4 REM Where your temporary objects should be | ||
set WINDOW_MANAGER=%5 REM Which library to use for creating a window | ||
set COMPILER_FLAGS=%6 REM -DDEBUG/-DNDEBUG -std=c++14/-std=c++17 -O2/-O3 | ||
set LINKER_FLAGS=%7 REM Additional linker flags for libraries and such | ||
|
||
REM Allow calling the build script | ||
call "%ROOT_PATH%\tools\buildScripts\build.bat" | ||
|
||
REM Compile and link | ||
call "%ROOT_PATH%\tools\buildScripts\build.bat" "%PROJECT_FOLDERS%" "%TARGET_FILE%" "%ROOT_PATH%" "%TEMP_ROOT%" "%WINDOW_MANAGER%" "%COMPILER_FLAGS%" "%LINKER_FLAGS%" | ||
if errorlevel 1 ( | ||
exit /b 1 | ||
) | ||
|
||
echo Starting application at %TARGET_FILE% | ||
"%TARGET_FILE%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
REM @echo off | ||
setlocal enabledelayedexpansion | ||
|
||
REM Compile all cpp files in a folder and all of its sub-folders into a static library using the GNU c++ compiler | ||
|
||
REM The global command for running the compiler (tested with g++ and clang++) | ||
set COMPILER=%1 | ||
REM The root of each folder containing source files | ||
set SOURCE_FOLDERS=%2 | ||
REM The target folder where the library will be created | ||
set TARGET=%3 | ||
REM The name of your library without any path nor extension | ||
set LIBRARY_NAME=%4 | ||
set OBJECT_POSTFIX=_%LIBRARY_NAME%_TEMP.o | ||
REM Compiler flags | ||
set COMPILER_FLAGS=%5 | ||
|
||
set LIBRARY_FILENAME=%TARGET%\%LIBRARY_NAME%.a | ||
set SUM_FILENAME=%TARGET%\%LIBRARY_NAME%.md5 | ||
|
||
REM Clean building, because lazy building is not yet implemented on MS-Windows. | ||
del /f /q "%LIBRARY_FILENAME%" | ||
|
||
REM Check if the target library already exists | ||
if not exist "%LIBRARY_FILENAME%" ( | ||
REM Argument: %1 as the folder to compile recursively | ||
call :compileFolder "%SOURCE_FOLDERS%" | ||
|
||
REM Assembling static library | ||
echo Assembling object files into %LIBRARY_NAME%.a. | ||
ar rcs "%LIBRARY_FILENAME%" "%TARGET%\*%OBJECT_POSTFIX%" | ||
|
||
REM Cleaning up temporary objects | ||
echo Cleaning up temporary %LIBRARY_NAME% object files. | ||
del /f /q "%TARGET%\*%OBJECT_POSTFIX%" | ||
) | ||
|
||
exit /b | ||
|
||
:compileFolder | ||
set FOLDER=%1 | ||
if not exist "!FOLDER!" ( | ||
echo Failed to compile files in !FOLDER! because the folder does not exist! | ||
exit /b 1 | ||
) | ||
|
||
REM Compile files in the folder | ||
for %%F in ("!FOLDER!\*.cpp") do ( | ||
if exist "%%F" ( | ||
set "name=%%~nxF" | ||
set "base=%%~nF" | ||
echo C++ %%F | ||
%COMPILER% %COMPILER_FLAGS% -Wall -c "%%F" -o "%TARGET%\!base!%OBJECT_POSTFIX%" | ||
if errorlevel 1 ( | ||
echo Failed to compile %%F! | ||
exit /b 1 | ||
) | ||
) | ||
) | ||
|
||
REM Recursively compile other folders | ||
for /d %%D in ("!FOLDER!\*") do ( | ||
call :compileFolder "%%D" | ||
) | ||
|
||
exit /b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@echo off | ||
setlocal | ||
|
||
REM Load arguments into named variables in order | ||
|
||
REM Which folder to create or clear | ||
set TEMP_DIR=%1 | ||
|
||
REM Create a temporary folder | ||
if not exist "%TEMP_DIR%" ( | ||
mkdir "%TEMP_DIR%" | ||
) | ||
|
||
REM Remove objects, but keep libraries | ||
del /f /q "%TEMP_DIR%\*.o" | ||
|
||
endlocal |