From f8ac5bbef56de08051dace78e9334af89de15da0 Mon Sep 17 00:00:00 2001 From: Matt Mitchell Date: Wed, 11 Mar 2015 11:45:35 -0700 Subject: [PATCH] Fixes for building tests alone This change fixes an issue where tests cannot be built alone as well as cleans up the paths. The general path cleanup was done so that the path format and variable names generally follow the main build of the coreclr repo. Some highlights are: * Don't use Cmake as a directory name for intermediates, use intermediates instead. * Disable 4820 warning (this is about padding) when building tests. Reduces noise in output significantly * Some fixes in typos and casing in the project files and build scripts --- build.cmd | 10 ++------- tests/CMakeLists.txt | 7 +++++++ tests/buildtest.cmd | 51 +++++++++++++++++++++++++++++----------------- tests/runtest.cmd | 2 +- tests/src/dir.common.props | 9 ++++---- tests/src/dir.targets | 19 +++++++++-------- tests/tests.targets | 2 +- 7 files changed, 58 insertions(+), 42 deletions(-) diff --git a/build.cmd b/build.cmd index 87b3702..19ec773 100644 --- a/build.cmd +++ b/build.cmd @@ -47,7 +47,7 @@ set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%" set "__IntermediatesDir=%__RootBinDir%\intermediates\%__BuildOS%.%__BuildArch%.%__BuildType%" set "__PackagesBinDir=%__BinDir%\.nuget" set "__ToolsDir=%__RootBinDir%\tools" -set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%" :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash set "__CMakeBinDir=%__BinDir%" @@ -64,12 +64,6 @@ set __MSBCleanBuildArgs=/t:rebuild :: Cleanup the binaries drop folder if exist "%__RootBinDir%" rd /s /q "%__RootBinDir%" -:: Cleanup the logs folder -if exist "%__LogsDir%" rd /s /q "%__LogsDir%" - -::Cleanup intermediates folder -if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%" - :MakeDirectories if not exist "%__BinDir%" md "%__BinDir%" if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%" @@ -188,7 +182,7 @@ goto :eof echo Repo successfully built. echo. echo Product binaries are available at !__BinDir! -echo Test binaries are available at !__TestWorkingDir! +echo Test binaries are available at !__TestBinDir! goto :eof :Usage diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f2d444c..408e029 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -6,6 +6,12 @@ if (WIN32) add_definitions(-DWINDOWS=1) endif() +# Compile options + +if (WIN32) + add_compile_options(-wd4820) +endif() + MACRO(SUBDIRLIST result curdir) FILE(GLOB children RELATIVE ${curdir} ${curdir}/*) SET(dirlist "") @@ -29,3 +35,4 @@ MACRO(ADDSUBDIR_REC curdir) ENDMACRO() ADDSUBDIR_REC(${CMAKE_CURRENT_SOURCE_DIR}) + diff --git a/tests/buildtest.cmd b/tests/buildtest.cmd index 4148892..173da4b 100644 --- a/tests/buildtest.cmd +++ b/tests/buildtest.cmd @@ -1,7 +1,16 @@ @echo off setlocal EnableDelayedExpansion -set "__ProjectFilesDir=%~dp0" +set "__ProjectDir=%~dp0..\" +:: remove trailing slash +if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%" +set "__SourceDir=%__ProjectDir%\src" +set "__TestDir=%__ProjectDir%\tests" +set "__ProjectFilesDir=%__TestDir%" +set "__PackagesDir=%__ProjectDir%\packages" +set "__RootBinDir=%__ProjectDir%\binaries" +set "__LogsDir=%__RootBinDir%\Logs" + :Arg_Loop if "%1" == "" goto ArgsDone if /i "%1" == "x64" (set __BuildArch=x64&shift&goto Arg_Loop) @@ -20,22 +29,22 @@ goto Usage if not defined __BuildArch set __BuildArch=x64 if not defined __BuildType set __BuildType=debug if not defined __BuildOS set __BuildOS=Windows_NT -if not defined __TestWorkingDir set "__TestWorkingDir=%__ProjectFilesDir%\..\binaries\tests\%__BuildOS%.%__BuildArch%.%__BuildType%" - -if not defined __LogsDir set "__LogsDir=%__ProjectFilesDir%..\binaries\Logs" -if not defined __ProductSourceDir set "__ProductSourceDir=%__ProjectFilesDir%..\src" +set "__TestBinDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%" +:: We have different managed and native intermediate dirs because the managed bits will include +:: the configuration information deeper in the intermediates path. +set "__NativeTestIntermediatesDir=%__RootBinDir%\tests\intermediates\%__BuildOS%.%__BuildArch%.%__BuildType%" +set "__ManagedTestIntermediatesDir=%__RootBinDir%\tests\intermediates" set "__TestManagedBuildLog=%__LogsDir%\Tests_Managed_%__BuildOS%__%__BuildArch%__%__BuildType%.log" set "__TestNativeBuildLog=%__LogsDir%\Tests_Native_%__BuildOS%__%__BuildArch%__%__BuildType%.log" set "__XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildOS%__%__BuildArch%__%__BuildType%.log" -set "__CMakeTestSlnDir=%__TestWorkingDir%\CMake\" -:: Switch to clean build mode if the binaries output folder does not exist -if not exist "%__TestWorkingDir%" set __CleanBuild=1 -if not exist "%__LogsDir%" md "%__LogsDir%" +:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash +set "__CMakeBinDir=%__TestBinDir%" +set "__CMakeBinDir=%__CMakeBinDir:\=/%" :: Configure environment if we are doing a clean build. -if not defined __CleanBuild goto CheckPrereqs +if not defined __CleanBuild goto MakeDirectories echo Doing a clean test build echo. @@ -43,8 +52,13 @@ echo. set __MSBCleanBuildArgs=/t:rebuild :: Cleanup the binaries drop folder -if exist "%__TestWorkingDir%" rd /s /q "%__TestWorkingDir%" +if exist "%__TestBinDir%" rmdir /S /Q "%__TestBinDir%" +:MakeDirectories +if not exist "%__TestBinDir%" md "%__TestBinDir%" +if not exist "%__NativeTestIntermediatesDir%" md "%__NativeTestIntermediatesDir%" +if not exist "%__ManagedTestIntermediatesDir%" md "%__ManagedTestIntermediatesDir%" +if not exist "%__LogsDir%" md "%__LogsDir%" :: Note: We've disabled node reuse because it causes file locking issues. :: The issue is that we extend the build with our own targets which @@ -56,7 +70,7 @@ if exist "%__TestWorkingDir%" rd /s /q "%__TestWorkingDir%" echo Checking pre-requisites... echo. :: Eval the output from probe-win1.ps1 -for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__ProductSourceDir%\pal\tools\probe-win.ps1"""') do %%a +for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a :: Check presence of VS if defined VS120COMNTOOLS goto CheckVSExistence @@ -94,19 +108,18 @@ goto :eof :GenVSSolution :: Regenerate the VS solution -if not exist "%__CMakeTestSlnDir%" md "%__CMakeTestSlnDir%" -pushd "%__CMakeTestSlnDir%" -call "%__ProductSourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectFilesDir%\" +pushd "%__NativeTestIntermediatesDir%" +call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectFilesDir%\" popd :BuildComponents -if exist "%__CMakeTestSlnDir%\install.vcxproj" goto BuildTestNativeComponents +if exist "%__NativeTestIntermediatesDir%\install.vcxproj" goto BuildTestNativeComponents echo Failed to generate test native component build project! goto :eof REM Build CoreCLR :BuildTestNativeComponents -%_msbuildexe% "%__CMakeTestSlnDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__TestNativeBuildLog%" +%_msbuildexe% "%__NativeTestIntermediatesDir%\install.vcxproj" %__MSBCleanBuildArgs% /nologo /maxcpucount /nodeReuse:false /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% /fileloggerparameters:Verbosity=diag;LogFile="%__TestNativeBuildLog%" IF NOT ERRORLEVEL 1 goto PerformManagedTestBuild echo Native component build failed. Refer !__TestNativeBuildLog! for details. goto :eof @@ -126,7 +139,7 @@ if not defined VSINSTALLDIR echo Error: build.cmd should be run from a Visual St :BuildTests -echo Starting the Manged Tests Build +echo Starting the Managed Tests Build echo. :: Log build command line set _buildprefix=echo @@ -144,7 +157,7 @@ goto :eof :build -%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix% +%_buildprefix% %_msbuildexe% "%__ProjectFilesDir%\build.proj" %__MSBCleanBuildArgs% /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=diag;LogFile="%__TestManagedBuildLog%";Append %* %_buildpostfix% IF ERRORLEVEL 1 echo Test build failed. Refer !__TestManagedBuildLog! for details && exit /b 1 endlocal diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 5bac632..55dc375 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -40,7 +40,7 @@ if not defined __BuildType set __BuildType=debug if not defined __BuildOS set __BuildOS=Windows_NT if not defined __BinDir set __BinDir=%__ProjectFilesDir%..\binaries\Product\%__BuildOS%.%__BuildArch%.%__BuildType% if not defined __TestWorkingDir set __TestWorkingDir=%__ProjectFilesDir%..\binaries\tests\%__BuildOS%.%__BuildArch%.%__BuildType% -if not defined __LogsDir set __LogsDir=%__ProjectFilesDir%..\binaries\Logs\ +if not defined __LogsDir set __LogsDir=%__ProjectFilesDir%..\binaries\Logs :: Default global test environmet variables if not defined XunitTestBinBase set XunitTestBinBase=%__TestWorkingDir%\ diff --git a/tests/src/dir.common.props b/tests/src/dir.common.props index 47c72dd..359acdf 100644 --- a/tests/src/dir.common.props +++ b/tests/src/dir.common.props @@ -30,13 +30,14 @@ $(ProjectDir)\..\binaries\tests\$(BuildOS).$(Platform).$(Configuration)\ - $(__TestWorkingDir)\ + $(__TestBinDir)\ $(BaseOutputPathWithConfig)\.. - $(BinDir)\intermediates\ - <__CMakeTestSlnDir Condition="'$(__CMakeTestSlnDir)' == ''">$(BaseOutputPathWithConfig)\CMake\ + $(ProjectDir)\..\binaries\tests\intermediates\ + $(__ManagedTestIntermediatesDir)\ + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\intermediates\$(BuildOS).$(Platform).$(Configuration)\)) $(MSBuildProjectName)\ $([System.String]::Copy('$(MSBuildProjectDirectory)').Replace($(SourceDir),'')) - $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir)\$(BuildOS).$(Platform).$(Configuration)\ + $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir) $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\ diff --git a/tests/src/dir.targets b/tests/src/dir.targets index a149ad5..bb05059 100644 --- a/tests/src/dir.targets +++ b/tests/src/dir.targets @@ -61,10 +61,10 @@ - + - - + - - - - - - + + + + + + + diff --git a/tests/tests.targets b/tests/tests.targets index 7fd0696..2bb2f16 100644 --- a/tests/tests.targets +++ b/tests/tests.targets @@ -18,7 +18,7 @@ - -- 2.7.4