Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ endif()
function(SetupTarget target_name)
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD 11)
target_compile_options(${target_name} PRIVATE -Wall -pedantic -Wextra -Werror)
if(USE_ADDRESS_SANITIZER)
target_compile_options(${target_name} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address>)
target_link_options(${target_name} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address>)
if (NOT WIN32)
if(USE_ADDRESS_SANITIZER)
target_compile_options(${target_name} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address>)
target_link_options(${target_name} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address>)
endif()
endif()
if(USE_COVERAGE_ANALYSIS)
target_compile_options(${target_name} PRIVATE $<$<CONFIG:Debug>:-fprofile-arcs>)
Expand Down Expand Up @@ -94,6 +96,10 @@ endif()
add_executable(${PROJECT_NAME}_bbtest ${REAL_BBTEST_SOURCES})
SetupTarget(${PROJECT_NAME}_bbtest)
target_link_libraries(${PROJECT_NAME}_bbtest ${PROJECT_NAME} gtest_main)
if(WIN32)
set(CMAKE_EXE_LINKER_FLAGS " -static")
target_link_libraries(${PROJECT_NAME}_bbtest -static-libgcc -static-libstdc++)
endif()
if(Threads_FOUND)
target_link_libraries(${PROJECT_NAME}_bbtest ${CMAKE_THREAD_LIBS_INIT})
endif()
Expand All @@ -103,7 +109,12 @@ add_test(NAME ${PROJECT_NAME}_bbtest COMMAND ${PROJECT_NAME}_bbtest)
add_executable(${PROJECT_NAME}_wbtest ${REAL_WBTEST_SOURCES})
SetupTarget(${PROJECT_NAME}_wbtest)
target_include_directories(${PROJECT_NAME}_wbtest PRIVATE "src")
target_link_libraries(${PROJECT_NAME}_wbtest ${PROJECT_NAME}_static gtest_main)
if(WIN32)
target_link_libraries(${PROJECT_NAME}_wbtest ${PROJECT_NAME}_static gtest_main -static-libgcc -static-libstdc++)
else()
target_link_libraries(${PROJECT_NAME}_wbtest ${PROJECT_NAME}_static gtest_main)
endif()

if(Threads_FOUND)
target_link_libraries(${PROJECT_NAME}_wbtest ${CMAKE_THREAD_LIBS_INIT})
endif()
Expand Down
3 changes: 3 additions & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo OFF
echo Executing end-user build...
./devbuild.bat -dir build -mode Release
171 changes: 171 additions & 0 deletions devbuild.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
@echo OFF
SETLOCAL EnableDelayedExpansion

set GENERATOR=Ninja
set NINJAFLAGS=
set DIR=
set MODE=
set NODOCS=
set COVERAGE=OFF


:while
if NOT "%~1" == "" (
if "%~1" == "-h" (
call :Help
goto :endscript
)
if "%~1" == "--help" (
call :Help
goto :endscript
)
if "%~1" == "-G" (
shift
call set GENERATOR=%%~1
echo Using !GENERATOR! as generator.
if x!GENERATOR:inja^=!==x!GENERATOR! (
echo Note, that the automatic build will not be successful without a ninja compatible generator.
)
goto :break
)
if "%~1" == "-ci" (
set NINJAFLAGS=-v -k 99
goto :break
)
if "%~1" == "-dir" (
shift
call set DIR=%%~1
echo Using !DIR! as build directory.
goto :break
)
if "%~1" == "-mode" (
shift
call set MODE=%%~1
echo Using !MODE! as build mode.
goto :break
)
if "%~1" == "-nodocs" (
set NODOCS=YEAH
echo Will not generate documentation.
goto :break
)
echo Unknown parameter %~1. Use -h for help.
EXIT /B 1

:break
shift
goto :while
)

echo Running PipeRT build...
set result=false
if "%DIR%" == "" set result=true
if "%MODE%" == "" set result=true
if %result% == true (
echo Running standard Debug build into build_debug folder...
set NODOCS=YEAH
call :RunCMake build_debug , Debug
echo Running standard Release build into build_release folder...
set NODOCS=
call :RunCMake build_release , Release
) else (
call :RunCMake %DIR% , %MODE%
)
echo Build successful.
:endscript
EXIT /B 0


:RunCMake
set DIR=%~1
set MODE=%~2
set COVERAGE=OFF
if "%MODE%" == "Debug" (
if "%NINJAFLAGS%" == "" (
set COVERAGE=HTML
) else (
set COVERAGE=ON
)
)
set CMAKE_OK=cmake.ok
if exist %DIR%\%CMAKE_OK% (
echo %DIR% already exists, skipping CMake run.
cd %DIR%
) else (
if exist %DIR% (
echo Detected previous failed CMake run, removing...
rmdir /S /Q %DIR%
)
echo Running CMake for %DIR%...
mkdir %DIR%
cd %DIR%
cmake -G %GENERATOR% -DCMAKE_BUILD_TYPE=%MODE% -DUSE_COVERAGE_ANALYSIS=%COVERAGE% ..
if ERRORLEVEL 1 (
echo CMake failed, exiting.
EXIT /B 1
)
echo. 2>%CMAKE_OK%
)
call :RunBuild
cd ..
EXIT /B 0

:RunBuild
echo Running compilation...
ninja %NINJAFLAGS%
if ERRORLEVEL 1 (
echo Compilation failed, exiting.
EXIT /B 1
)
call :RunTest
EXIT /B 0

:RunTest
echo Running tests...
set CTEST_OUTPUT_ON_FAILURE=1
ninja %NINJAFLAGS% test
if ERRORLEVEL 1 (
echo Tests failed, exiting.
EXIT /B 1
)
call :GenerateCoverage
EXIT /B 0

:GenerateCoverage
for %%X in (gcovr.exe) do (set CFOUND=%%~$PATH:X)
if defined CFOUND (
if NOT %COVERAGE% == OFF (
echo Generating coverage report...
ninja %NINJAFLAGS% coverage
if ERRORLEVEL 1 (
echo Coverage report generation failed, exiting.
EXIT /B 1
)
)
)
call :GenerateDocs
EXIT /B 0

:GenerateDocs
for %%X in (doxygen.exe) do (set DFOUND=%%~$PATH:X)
if defined DFOUND (
if "%NODOCS%" == "" (
echo Generating documentation...
ninja %NINJAFLAGS% docs
if ERRORLEVEL 1 (
echo Documentation generation failed, exiting.
EXIT /B 1
)
)
)
EXIT /B 0

:Help
echo Options:
echo -h or --help Give this help
echo -G ^<cmake_generator^> Use CMake generator instead of Ninja
echo -ci CI mode: log more, do not stop on errors
echo -dir ^<build_dir^> Use build_dir folder for this build
echo -mode ^<mode^> CMake build mode (Debug / Release)
echo -nodocs Do not generate HTML documentation
EXIT /B 1