summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt39
-rw-r--r--build.cmd79
-rw-r--r--src/pal/tools/gen-buildsys-win.bat36
3 files changed, 90 insertions, 64 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22433c8c5e..56c22838df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -542,43 +542,4 @@ if(CLR_CMAKE_BUILD_TESTS)
add_subdirectory(tests)
endif(CLR_CMAKE_BUILD_TESTS)
-#----------------------------------------------------
-# Build the project again for cross target components
-# - intermediates will be placed at %__IntermediatesDir%\crosscomponents
-# - final binaries will be placed at %__CMakeBinDir%\<hostArch>
-#----------------------------------------------------
-
-if(CLR_CMAKE_PLATFORM_ARCH_ARM64 AND WIN32)
- # Cross target component build only enabled for win arm64
- set(CLR_CROSS_COMPONENTS_BUILD_ENABLED 1)
-endif()
-
-# To avoid recursion when building cross target components
-if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD AND CLR_CROSS_COMPONENTS_BUILD_ENABLED)
-
- # Set host arch for cross target components
- if(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- set(CLR_CROSS_BUILD_HOST_ARCH x64)
- elseif(CLR_CMAKE_PLATFORM_ARCH_ARM)
- set(CLR_CROSS_BUILD_HOST_ARCH x86)
- endif()
-
- include(ExternalProject)
-
- # Add the source root again as external project but with CLR_CROSS_COMPONENTS_BUILD flag set
- ExternalProject_Add(
- crosscomponents
- SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
- # Arm64 builds currently pollute the env by setting private toolset dirs. Get rid of that.
- CMAKE_COMMAND "$ENV{__VSToolsRoot}\\..\\..\\VC\\vcvarsall.bat" COMMAND cmake
- CMAKE_ARGS -DCLR_CROSS_COMPONENTS_BUILD=1
- -DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}/${CLR_CROSS_BUILD_HOST_ARCH}
- -DCMAKE_USER_MAKE_RULES_OVERRIDE=${CLR_DIR}/src/pal/tools/windows-compiler-override.txt
- -DCLR_CMAKE_HOST_ARCH=${CLR_CROSS_BUILD_HOST_ARCH}
- -DCLR_CMAKE_TARGET_ARCH=${CLR_CMAKE_HOST_ARCH}
- BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/crosscomponents
- INSTALL_DIR $ENV{__CMakeBinDir}/${CLR_CROSS_BUILD_HOST_ARCH}
- )
-endif()
-
include(definitionsconsistencycheck.cmake)
diff --git a/build.cmd b/build.cmd
index 3167d53fb2..0e4b1c4540 100644
--- a/build.cmd
+++ b/build.cmd
@@ -113,7 +113,7 @@ if /i "%1" == "osxmscorlib" (set __CoreLibOnly=1&set __BuildOS=OSX&set p
if /i "%1" == "windowsmscorlib" (set __CoreLibOnly=1&set __BuildOS=Windows_NT&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "vs2015" (set __VSVersion=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
-if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __SkipCoreLibBuild=1&set __SkipTestBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
+if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __SkipCoreLibBuild=1&set __SkipBuildPackages=1&set __SkipTestBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "skipmscorlib" (set __SkipCoreLibBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
if /i "%1" == "skipnative" (set __SkipNativeBuild=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
@@ -187,7 +187,7 @@ set "__TestRootDir=%__RootBinDir%\tests"
set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
set "__CrossComponentBinDir=%__BinDir%"
-if defined __CrossArch set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%
+if NOT "%__CrossArch%" == "" set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%
:: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
set "__CMakeBinDir=%__BinDir%"
@@ -379,10 +379,77 @@ if errorlevel 1 (
exit /b 1
)
+:SkipNativeBuild
+
REM endlocal to rid us of environment changes from vcvarsall.bat
endlocal
-:SkipNativeBuild
+REM =========================================================================================
+REM ===
+REM === Build Cross-Architecture Native Components (if applicable)
+REM ===
+REM =========================================================================================
+
+REM cross-arch build only enabled for arm64
+if "%__CrossArch%" == "" goto SkipCrossCompBuild
+
+echo %__MsgPrefix%Commencing build of cross architecture native components for %__BuildOS%.%__BuildArch%.%__BuildType%
+
+REM Use setlocal to restrict environment changes form vcvarsall.bat and more to just this native components build section.
+setlocal EnableDelayedExpansion EnableExtensions
+
+:: Set the environment for the native build
+set __VCBuildArch=x86_amd64
+if /i "%__CrossArch%" == "x86" (set __VCBuildArch=x86)
+call "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" %__VCBuildArch%
+@if defined __echo @echo on
+
+set __CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen
+if not exist "%__CrossCompIntermediatesDir%" md "%__CrossCompIntermediatesDir%"
+
+pushd "%__CrossCompIntermediatesDir%"
+
+set __CMakeBinDir=%__CrossComponentBinDir%
+set "__CMakeBinDir=%__CMakeBinDir:\=/%"
+set __ExtraCmakeArgs="-DCLR_CROSS_COMPONENTS_BUILD=1" "-DCLR_CMAKE_TARGET_ARCH=%__BuildArch%"
+call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__CrossArch% %__ExtraCmakeArgs%
+@if defined __echo @echo on
+popd
+
+if not exist "%__CrossCompIntermediatesDir%\install.vcxproj" (
+ echo %__MsgPrefix%Error: failed to generate cross-arch components build project!
+ exit /b 1
+)
+
+if defined __ConfigureOnly goto SkipCrossCompBuild
+
+echo %__MsgPrefix%Invoking msbuild
+
+set "__BuildLog=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
+set "__BuildWrn=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
+set "__BuildErr=%__LogsDir%\CrossComp_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
+set __msbuildLogArgs=^
+/fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
+/fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
+/fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
+/consoleloggerparameters:Summary ^
+/verbosity:minimal
+
+set __msbuildArgs="%__CrossCompIntermediatesDir%\install.vcxproj" %__msbuildCommonArgs% %__msbuildLogArgs% /p:Configuration=%__BuildType% /p:Platform=%__CrossArch%
+
+%_msbuildexe% %__msbuildArgs%
+if errorlevel 1 (
+ 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
+)
+
+REM endlocal to rid us of environment changes from vcvarsall.bat
+endlocal
+
+:SkipCrossCompBuild
REM =========================================================================================
REM ===
@@ -445,7 +512,7 @@ echo %__MsgPrefix%Generating native image of System.Private.CoreLib for %__Build
set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
"%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\System.Private.CoreLib.ni.dll" "%__BinDir%\System.Private.CoreLib.dll" > "%__CrossGenCoreLibLog%" 2>&1
-if %errorlevel% NEQ 0 (
+if NOT %errorlevel% == 0 (
echo %__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to the build log file for details:
echo %__CrossGenCoreLibLog%
exit /b 1
@@ -456,7 +523,7 @@ echo %__MsgPrefix%Generating native image of MScorlib facade for %__BuildOS%.%__
set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenMSCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
"%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\mscorlib.ni.dll" "%__BinDir%\mscorlib.dll" > "%__CrossGenCoreLibLog%" 2>&1
-if %errorlevel% NEQ 0 (
+if NOT %errorlevel% == 0 (
echo %__MsgPrefix%Error: CrossGen mscorlib facade build failed. Refer to the build log file for details:
echo %__CrossGenCoreLibLog%
exit /b 1
@@ -465,7 +532,7 @@ if %errorlevel% NEQ 0 (
:SkipCoreLibBuild
:GenerateNuget
-if /i "%__SkipBuildPackages%" == 1 goto :SkipNuget
+if /i "%__SkipBuildPackages%" == "1" goto :SkipNuget
set "__BuildLog=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
set "__BuildWrn=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
diff --git a/src/pal/tools/gen-buildsys-win.bat b/src/pal/tools/gen-buildsys-win.bat
index 5592fe5930..3e9e4c24c5 100644
--- a/src/pal/tools/gen-buildsys-win.bat
+++ b/src/pal/tools/gen-buildsys-win.bat
@@ -5,7 +5,7 @@ rem This file invokes cmake and generates the build system for windows.
set argC=0
for %%x in (%*) do Set /A argC+=1
-if NOT %argC%==3 if NOT %argC%==4 GOTO :USAGE
+if %argC% lss 3 GOTO :USAGE
if %1=="/?" GOTO :USAGE
setlocal
@@ -15,13 +15,21 @@ set "basePath=%basePath:"=%"
:: remove trailing slash
if %basePath:~-1%==\ set "basePath=%basePath:~0,-1%"
-set __VSString=12 2013
-set __UseVS=1
-if /i "%2" == "vs2015" (set __VSString=14 2015)
-if /i "%3" == "x64" (set __VSString=%__VSString% Win64)
-if /i "%3" == "arm64" (set UseVS=0)
-
-set __BuildJit32=%4
+set __SourceDir=%1
+set __VSVersion=%2
+set __Arch=%3
+set __CmakeGenerator=Visual Studio
+if /i "%__VSVersion%" == "vs2015" (set __CmakeGenerator=%__CmakeGenerator% 14 2015)
+if /i "%__Arch%" == "x64" (set __CmakeGenerator=%__CmakeGenerator% Win64)
+if /i "%__Arch%" == "arm64" (set __CmakeGenerator=%__CmakeGenerator% Win64)
+if /i "%__Arch%" == "arm" (set __CmakeGenerator=%__CmakeGenerator% ARM)
+
+:loop
+if [%4] == [] goto end_loop
+set __ExtraCmakeParams=%__ExtraCmakeParams% %4
+shift
+goto loop
+:end_loop
if defined CMakePath goto DoGen
@@ -29,11 +37,7 @@ if defined CMakePath goto DoGen
for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& "%basePath%\probe-win.ps1""') do %%a
:DoGen
-if "%UseVS%" == "0" (
- "%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%3" -G "Visual Studio %__VSString% Win64" %1
-) else (
- "%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%3" %__BuildJit32% -G "Visual Studio %__VSString%" %1
-)
+"%CMakePath%" "-DCMAKE_USER_MAKE_RULES_OVERRIDE=%basePath%\windows-compiler-override.txt" "-DCMAKE_INSTALL_PREFIX:PATH=$ENV{__CMakeBinDir}" "-DCLR_CMAKE_HOST_ARCH=%__Arch%" %__ExtraCmakeParams% -G "%__CmakeGenerator%" %__SourceDir%
endlocal
GOTO :DONE
@@ -46,9 +50,3 @@ GOTO :DONE
:DONE
EXIT /B 0
-
-
-
-
-
-