From 1ffcf98bc8fceff36b52cd97f9228af4a3748f08 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Fri, 3 May 2019 17:56:20 -0700 Subject: Use our local-built instances of tools from Microsoft.DotNet.BuildTools.CoreClr instead of using the package. (#24347) * Use our local-built instances of tools from Microsoft.DotNet.BuildTools.CoreClr instead of using the package. * Fix const-correctness in InjectResource. * Build cross-arch native components before building native components for target arch. * Build InjectResource and GenClrDebugResource for the host arch when cross-building and import the targets into the cross-build. * install(EXPORT) in the directory where the target is created --- build.cmd | 127 ++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 65 insertions(+), 62 deletions(-) (limited to 'build.cmd') diff --git a/build.cmd b/build.cmd index bd6d355fd9..e9669ca36a 100644 --- a/build.cmd +++ b/build.cmd @@ -459,152 +459,155 @@ if %__BuildCrossArchNative% EQU 1 ( REM ========================================================================================= REM === -REM === Build the CLR VM +REM === Build Cross-Architecture Native Components (if applicable) REM === REM ========================================================================================= -if %__BuildNative% EQU 1 ( +if %__BuildCrossArchNative% EQU 1 ( REM Scope environment changes start { setlocal - echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType% + echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType% - REM Set the environment for the native build + REM Set the environment for the cross-arch native build set __VCBuildArch=x86_amd64 - if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 ) - if /i "%__BuildArch%" == "arm" ( - set __VCBuildArch=x86_arm - - REM Make CMake pick the highest installed version in the 10.0.* range - set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" - ) - if /i "%__BuildArch%" == "arm64" ( - set __VCBuildArch=x86_arm64 - - REM Make CMake pick the highest installed version in the 10.0.* range - set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" - ) + if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 ) echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! @if defined _echo @echo on - if not defined VSINSTALLDIR ( - echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined. - exit /b 1 - ) - if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA - - if defined __SkipConfigure goto SkipConfigure - - echo %__MsgPrefix%Regenerating the Visual Studio solution + if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%" + if defined __SkipConfigure goto SkipConfigureCrossBuild - pushd "%__IntermediatesDir%" - set __ExtraCmakeArgs=!___SDKVersion! "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PACKAGES_DIR=%__PackagesDir%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_VERSION=%__PgoOptDataVersion%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" - call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! + pushd "%__CrossCompIntermediatesDir%" + set __CMakeBinDir=%__CrossComponentBinDir% + set "__CMakeBinDir=!__CMakeBinDir:\=/!" + set __ExtraCmakeArgs="-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PACKAGES_DIR=%__PackagesDir%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_VERSION=%__PgoOptDataVersion%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCMAKE_SYSTEM_VERSION=10.0" + call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! @if defined _echo @echo on popd -:SkipConfigure - if not exist "%__IntermediatesDir%\install.vcxproj" ( - echo %__MsgPrefix%Error: failed to generate native component build project! +:SkipConfigureCrossBuild + if not exist "%__CrossCompIntermediatesDir%\install.vcxproj" ( + echo %__MsgPrefix%Error: failed to generate cross-arch components build project! exit /b 1 ) - if defined __ConfigureOnly goto SkipNativeBuild + if defined __ConfigureOnly goto SkipCrossCompBuild - set __BuildLogRootName=CoreCLR + set __BuildLogRootName=Cross set __BuildLog="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.log" set __BuildWrn="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn" set __BuildErr="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.err" set __MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog! set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! - set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! + set __Logging=!_MsbuildLog! !__MsbuildWrn! !__MsbuildErr! call %__ProjectDir%\cmake_msbuild.cmd /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^ /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^ /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^ - /p:UsePartialNGENOptimization=false /maxcpucount %__IntermediatesDir%\install.vcxproj^ - !__Logging! /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% %__CommonMSBuildArgs% /m:2 %__UnprocessedBuildArgs% + /p:UsePartialNGENOptimization=false /maxcpucount^ + %__CrossCompIntermediatesDir%\install.vcxproj^ + !__Logging! /p:Configuration=%__BuildType% /p:Platform=%__CrossArch% %__CommonMSBuildArgs% /m:2 %__UnprocessedBuildArgs% if not !errorlevel! == 0 ( - echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details: + echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details: echo !__BuildLog! echo !__BuildWrn! echo !__BuildErr! exit /b 1 ) -:SkipNativeBuild +:SkipCrossCompBuild REM } Scope environment changes end endlocal ) REM ========================================================================================= REM === -REM === Build Cross-Architecture Native Components (if applicable) +REM === Build the CLR VM REM === REM ========================================================================================= -if %__BuildCrossArchNative% EQU 1 ( +if %__BuildNative% EQU 1 ( REM Scope environment changes start { setlocal - echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType% + echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType% - REM Set the environment for the cross-arch native build + REM Set the environment for the native build set __VCBuildArch=x86_amd64 - if /i "%__CrossArch%" == "x86" ( set __VCBuildArch=x86 ) + if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 ) + if /i "%__BuildArch%" == "arm" ( + set __VCBuildArch=x86_arm + REM Make CMake pick the highest installed version in the 10.0.* range + set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" + set ___CrossBuildDefine="-DCLR_CMAKE_CROSS_ARCH=1" "-DCLR_CMAKE_CROSS_HOST_ARCH=%__CrossArch%" + ) + if /i "%__BuildArch%" == "arm64" ( + set __VCBuildArch=x86_arm64 + + REM Make CMake pick the highest installed version in the 10.0.* range + set ___SDKVersion="-DCMAKE_SYSTEM_VERSION=10.0" + set ___CrossBuildDefine="-DCLR_CMAKE_CROSS_ARCH=1" "-DCLR_CMAKE_CROSS_HOST_ARCH=%__CrossArch%" + ) echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! call "%__VCToolsRoot%\vcvarsall.bat" !__VCBuildArch! @if defined _echo @echo on - if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%" - if defined __SkipConfigure goto SkipConfigureCrossBuild + if not defined VSINSTALLDIR ( + echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined. + exit /b 1 + ) + if not exist "!VSINSTALLDIR!DIA SDK" goto NoDIA - pushd "%__CrossCompIntermediatesDir%" - set __CMakeBinDir=%__CrossComponentBinDir% - set "__CMakeBinDir=!__CMakeBinDir:\=/!" - set __ExtraCmakeArgs="-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%" "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PACKAGES_DIR=%__PackagesDir%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_VERSION=%__PgoOptDataVersion%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" "-DCMAKE_SYSTEM_VERSION=10.0" - call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% !__ExtraCmakeArgs! + if defined __SkipConfigure goto SkipConfigure + + echo %__MsgPrefix%Regenerating the Visual Studio solution + + echo Cross Arch Defines !___CrossBuildDefine! + + pushd "%__IntermediatesDir%" + set __ExtraCmakeArgs=!___SDKVersion! !___CrossBuildDefine! "-DCLR_CMAKE_TARGET_OS=%__BuildOS%" "-DCLR_CMAKE_PACKAGES_DIR=%__PackagesDir%" "-DCLR_CMAKE_PGO_INSTRUMENT=%__PgoInstrument%" "-DCLR_CMAKE_OPTDATA_VERSION=%__PgoOptDataVersion%" "-DCLR_CMAKE_PGO_OPTIMIZE=%__PgoOptimize%" + call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! @if defined _echo @echo on popd -:SkipConfigureCrossBuild - if not exist "%__CrossCompIntermediatesDir%\install.vcxproj" ( - echo %__MsgPrefix%Error: failed to generate cross-arch components build project! +:SkipConfigure + if not exist "%__IntermediatesDir%\install.vcxproj" ( + echo %__MsgPrefix%Error: failed to generate native component build project! exit /b 1 ) - if defined __ConfigureOnly goto SkipCrossCompBuild + if defined __ConfigureOnly goto SkipNativeBuild - set __BuildLogRootName=Cross + set __BuildLogRootName=CoreCLR set __BuildLog="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.log" set __BuildWrn="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn" set __BuildErr="%__LogsDir%\!__BuildLogRootName!_%__BuildOS%__%__BuildArch%__%__BuildType%.err" set __MsbuildLog=/flp:Verbosity=normal;LogFile=!__BuildLog! set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! - set __Logging=!_MsbuildLog! !__MsbuildWrn! !__MsbuildErr! + set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! call %__ProjectDir%\cmake_msbuild.cmd /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^ /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^ /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^ - /p:UsePartialNGENOptimization=false /maxcpucount^ - %__CrossCompIntermediatesDir%\install.vcxproj^ - !__Logging! /p:Configuration=%__BuildType% /p:Platform=%__CrossArch% %__CommonMSBuildArgs% /m:2 %__UnprocessedBuildArgs% + /p:UsePartialNGENOptimization=false /maxcpucount %__IntermediatesDir%\install.vcxproj^ + !__Logging! /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% %__CommonMSBuildArgs% /m:2 %__UnprocessedBuildArgs% if not !errorlevel! == 0 ( - echo %__MsgPrefix%Error: cross-arch components build failed. Refer to the build log files for details: + echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details: echo !__BuildLog! echo !__BuildWrn! echo !__BuildErr! exit /b 1 ) -:SkipCrossCompBuild +:SkipNativeBuild REM } Scope environment changes end endlocal ) -- cgit v1.2.3