Skip to content

Instantly share code, notes, and snippets.

@rpavlik
Created November 8, 2011 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpavlik/1348546 to your computer and use it in GitHub Desktop.
Save rpavlik/1348546 to your computer and use it in GitHub Desktop.
Batch file for Eigen dashboard build on windows
@echo off
rem parameter 1: 32 or 64 to choose the desired build type
rem parameter 2: should be something like
rem "-DEIGEN_TEST_NOQT=ON -DEIGEN_TEST_OPENMP=ON -DEIGEN_DEFAULT_TO_ROW_MAJOR=ON"
rem NOTE: this parameter must be given with paranthesis
rem IMPORTANT: please adapt the following variable
set ARCH=x86
rem NOTE: Setting these variables is optional. In case you do not set them
rem the script will try to determine them automatically.
set SITE=anonymous
set OS_VERSION=unknown_os
set CXX_VERSION=unknown_compiler
rem Since we are switching directories, let's store the original one
set CURR_DIR=%~dp0
rem Set build variables
rem VSCOMNTOOLS...... MSVC location
rem GENERATOR_BASE... CMake generator
call :SetBuildVariables
rem Run the vcvarsall.bat file with the appropriate parameter.
rem The parameter defines whether we will actually perform a
rem 32 bit or 64 bit build.
rem
rem NOTE: On some systems, the batch file will bail out because
rem of white spaces in your path.
rem see: http://social.msdn.microsoft.com/forums/en-US/vssetup/thread/ccb680b7-d205-4f39-b2a2-a4cf1de91e1c/
call "%VSCOMNTOOLS%\..\..\VC\vcvarsall.bat" %VCVARS_PARAM%
echo.
call :SetSite
call :SetOSVersion
call :SetCXXVersion
rem Conigure whether we want a 32bit or 64bit build.
if "%~1"=="64" (
set ARCH_BIT=64
set GENERATOR_TYPE=%GENERATOR_BASE% Win64
set VCVARS_PARAM=AMD64
) else (
set ARCH_BIT=32
set GENERATOR_TYPE=%GENERATOR_BASE%
set VCVARS_PARAM=x86
)
rem Configure CMAKE_ARGS in case they are given.
set CMAKE_ARGS=
if "%~2"=="" goto NoCMakeArgs
set CMAKE_ARGS=%~2
:NoCMakeArgs
echo.
echo Configuring for generator %GENERATOR_TYPE%
echo Build type........: %ARCH_BIT% bit
echo CMake arguments...: %CMAKE_ARGS%
echo.
rem Parse the CMake arguments in %2 in order to create
rem a meaningful build string
set BUILD_INFO=
verify > NUL
echo "%~2" | find /i "-DEIGEN_DEFAULT_TO_ROW_MAJOR=ON" > NUL
if %ERRORLEVEL%==0 call :AppendBuildInfo row
verify > NUL
echo "%~2" | find /i "-DEIGEN_TEST_OPENMP=ON" > NUL
if %ERRORLEVEL%==0 call :AppendBuildInfo smp
rem The string that will identify the build on the dashboard
set BUILD_STRING=%OS_VERSION%-%ARCH%_%ARCH_BIT%-%CXX_VERSION%%BUILD_INFO%
rem eigen will be cloned here - the directory will exist once redundant
rem this is currently the most portable since wget does not ship with windows
set REPO_DIR=%CURR_DIR%eigen2
rem the directory in which the out of source build will be performed
set WORK_DIR=%CURR_DIR%eigen-x86_%ARCH_BIT%-bin
rem Retrieve the repository once since we need access to %WORK_DIR%\testsuite.cmake
rem and I have no idea how to pull a single file.
if not exist %REPO_DIR% hg clone https://bitbucket.org/eigen/eigen/ %REPO_DIR%
rem Even if it exists, let's check whether we need an update
echo Updating and copying the 'testsuite.cmake' to the build directory:
cd %REPO_DIR%
hg pull -u
cd %CURR_DIR%
rem Next check whether we already have a %WORK_DIR%, if not create it
rem and copy the %WORK_DIR%\testsuite.cmake file.
if not exist "%WORK_DIR%" mkdir "%WORK_DIR%"
copy "%REPO_DIR%\test\testsuite.cmake" "%WORK_DIR%\testsuite.cmake"
echo.
echo "%SITE%"
echo "%BUILD_STRING%"
echo "%GENERATOR_TYPE%"
echo "%CMAKE_ARGS%"
echo Start running CDash:
ctest -j 2 -VV -S %WORK_DIR%/testsuite.cmake,EIGEN_MODE=Experimental,EIGEN_SITE=%SITE%,EIGEN_BUILD_STRING="%BUILD_STRING%",EIGEN_EXPLICIT_VECTORIZATION=SSE2,EIGEN_GENERATOR_TYPE="%GENERATOR_TYPE%",EIGEN_CMAKE_ARGS="%CMAKE_ARGS%"
goto :EOF
rem ****************************************************
rem Helper functions ...
rem ****************************************************
rem This function is just used in order to prevent
rem ugly whitespaces when the flag is yet empty.
:AppendBuildInfo
if "%BUILD_INFO%"=="" (
set BUILD_INFO=-%~1
) else (
set BUILD_INFO=%BUILD_INFO%-%~1
)
goto :EOF
:SetOSVersion
if not "%OS_VERSION%"=="unknown_os" goto :EOF
for /f "tokens=4" %%a in ('ver') do @set OS_VERSION=%%a
for /f "tokens=1-3 delims=]" %%a in ("%OS_VERSION%") do @set OS_VERSION=%%a
set OS_VERSION=windows(%OS_VERSION%)
goto :EOF
:SetCXXVersion
if not "%CXX_VERSION%"=="unknown_compiler" goto :EOF
for /f "tokens=6" %%a in ('devenv /? ^| find /i "Studio Version"') do @set CXX_VERSION=%%a
for /f "tokens=1-4 delims=." %%a in ("%CXX_VERSION%") do set CXX_VERSION=%%a.%%b.%%c.%%d
set CXX_VERSION=msvc(%CXX_VERSION%)
goto :EOF
:SetSite
rem Try to fix the site variable in case it is still set to its default value
if not "%SITE%"=="anonymous" goto :EOF
for /f "tokens=1 delims= " %%i in ('hostname') do set SITE=%%i
goto :EOF
:SetBuildVariables
if exist "%VS100COMNTOOLS%" (
goto VC10
) else (
if exist "%VS90COMNTOOLS%" goto VC9
)
echo.
echo "Did not find Visual Studio, stopping testing."
exit /B
:VC10
set VSCOMNTOOLS=%VS100COMNTOOLS%
set GENERATOR_BASE=Visual Studio 10
goto :EOF
:VC9
set VSCOMNTOOLS=%VS90COMNTOOLS%
set GENERATOR_BASE=Visual Studio 9 2008
goto :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment