From: Gaurav Khanna Date: Tue, 22 Mar 2016 08:18:21 +0000 (-0700) Subject: Enable support to precompile the FX assemblies at test invocation time. X-Git-Tag: accepted/tizen/base/20180629.140029~5220^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6afc14de44435422e59b81493e561256ea756f8c;p=platform%2Fupstream%2Fcoreclr.git Enable support to precompile the FX assemblies at test invocation time. --- diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 35ff794..7625486 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -54,6 +54,7 @@ if /i "%1" == "Exclude" (set __Exclude=%2&shift&shift&goto Arg_Loop) if /i "%1" == "Exclude0" (set __Exclude0=%2&shift&shift&goto Arg_Loop) if /i "%1" == "TestEnv" (set __TestEnv=%2&shift&shift&goto Arg_Loop) if /i "%1" == "sequential" (set __BuildSequential=1&shift&goto Arg_Loop) +if /i "%1" == "crossgen" (set __DoCrossgen=1&shift&goto Arg_Loop) if /i "%1" == "GenerateLayoutOnly" (set __GenerateLayoutOnly=1&set __SkipWrapperGeneration=true&shift&goto Arg_Loop) if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs @@ -158,6 +159,11 @@ if errorlevel 1 exit /b 1 call :ResolveDependecies +if not defined __DoCrossgen goto :SkipPrecompileFX +call :PrecompileFX + +:SkipPrecompileFX + if defined __GenerateLayoutOnly ( exit /b 1 ) @@ -203,6 +209,32 @@ REM === Helper routines REM === REM ========================================================================================= +REM Compile the managed assemblies in Core_ROOT before running the tests +:PrecompileAssembly + +REM Skip mscorlib since it is already precompiled. +if /I "%3" == "mscorlib.dll" exit /b 0 +if /I "%3" == "mscorlib.ni.dll" exit /b 0 + +"%1\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" "%2" >nul 2>nul +set /a __exitCode = %errorlevel% +if "%__exitCode%" == "-2146230517" ( + echo %2 is not a managed assembly. + exit /b 0 +) + +if %__exitCode% neq 0 ( + echo Unable to precompile %2 + exit /b 0 +) + +echo Successfully precompiled %2 +exit /b 0 + +:PrecompileFX +for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%CORE_ROOT%" "%%F" %%~nF%%~xF +exit /b 0 + :msbuild @REM Subroutine to invoke msbuild. All arguments are passed to msbuild. The first argument should be the @REM .proj file to invoke. @@ -261,7 +293,7 @@ echo %__MsgPrefix% Created the runtime layout with all dependencies in:%CORE_ROO exit /b 0 if errorlevel 1 ( - echo Test Depenedevy Resolution Failed + echo Test Dependency Resolution Failed exit /b 1 ) diff --git a/tests/runtest.sh b/tests/runtest.sh index 41a5f71..1bd7bff 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -343,11 +343,38 @@ function create_core_overlay { cp -f "$coreFxNativeBinDir/Native/"*."$libExtension" "$coreOverlayDir/" 2>/dev/null cp -f "$coreClrBinDir/"* "$coreOverlayDir/" 2>/dev/null - cp -f "$mscorlibDir/mscorlib.dll" "$coreOverlayDir/" cp -n "$testDependenciesDir"/* "$coreOverlayDir/" 2>/dev/null - if [ -f "$coreOverlayDir/mscorlib.ni.dll" ]; then - rm -f "$coreOverlayDir/mscorlib.ni.dll" - fi +} + +function precompile_overlay_assemblies { + + if [ $doCrossgen == 1 ]; then + + local overlayDir=$CORE_ROOT + + filesToPrecompile=$(ls -trh $overlayDir/*.dll) + for fileToPrecompile in ${filesToPrecompile} + do + local filename=${fileToPrecompile} + # Precompile any assembly except mscorlib since we already have its NI image available. + if [[ "$filename" != *"mscorlib.dll"* ]]; then + if [[ "$filename" != *"mscorlib.ni.dll"* ]]; then + echo Precompiling $filename + $overlayDir/crossgen /Platform_Assemblies_Paths $overlayDir $filename 2>/dev/null + local exitCode=$? + if [ $exitCode == -2146230517 ]; then + echo $filename is not a managed assembly. + elif [ $exitCode != 0 ]; then + echo Unable to precompile $filename. + else + echo Successfully precompiled $filename + fi + fi + fi + done + else + echo Skipping crossgen of FX assemblies. + fi } function copy_test_native_bin_to_test_root { @@ -627,6 +654,8 @@ coverageOutputDir= # Handle arguments verbose=0 +doCrossGen=0 + for i in "$@" do case $i in @@ -637,6 +666,9 @@ do -v|--verbose) verbose=1 ;; + --crossgen) + doCrossgen=1 + ;; --testRootDir=*) testRootDir=${i#*=} ;; @@ -752,6 +784,7 @@ fi xunit_output_begin create_core_overlay +precompile_overlay_assemblies copy_test_native_bin_to_test_root load_unsupported_tests load_failing_tests