diff --git a/docs/workflow/debugging/coreclr/debugging.md b/docs/workflow/debugging/coreclr/debugging.md index 0eda9dc3727381..4e8d8c00b95dbc 100644 --- a/docs/workflow/debugging/coreclr/debugging.md +++ b/docs/workflow/debugging/coreclr/debugging.md @@ -8,28 +8,32 @@ SOS has moved to the diagnostics repo. For more information on SOS, installation Debugging CoreCLR on Windows ============================ -1. Perform a build of the repo. -2. Open solution \\artifacts\obj\coreclr\windows.\.\\CoreCLR.sln in Visual Studio. \ and \ are based +1. Open the CoreCLR solution in Visual Studio. + - Method 1: Use the build scripts to open the solution. + 1. Run `./build.cmd -vs coreclr.sln -a -c `. This will create and launch the CoreCLR solution in VS for the specified architecture and configuration. + - Method 2: Manually build and open the solution. + 1. Perform a build of the repo with the `-msbuild` flag. + 2. Open solution `\\artifacts\obj\coreclr\windows.\.\\ide\CoreCLR.sln` in Visual Studio. `` and `` are based on type of build you did. By default they are 'x64' and 'Debug'. -3. Right-click the INSTALL project and choose ‘Set as StartUp Project’ -4. Bring up the properties page for the INSTALL project -5. Select Configuration Properties->Debugging from the left side tree control -6. Set Command=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)\corerun.exe` +2. Right-click the INSTALL project and choose ‘Set as StartUp Project’ +3. Bring up the properties page for the INSTALL project +4. Select Configuration Properties->Debugging from the left side tree control +5. Set Command=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)\corerun.exe` 1. This points to the folder where the built runtime binaries are present. -7. Set Command Arguments=`` (e.g. HelloWorld.dll) -8. Set Working Directory=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)` +6. Set Command Arguments=`` (e.g. HelloWorld.dll) +7. Set Working Directory=`$(SolutionDir)\..\..\..\bin\coreclr\windows.$(Platform).$(Configuration)` 1. This points to the folder containing CoreCLR binaries. -9. Set Environment=`CORE_LIBRARIES=$(SolutionDir)\..\..\..\bin\runtime\-windows-$(Configuration)-$(Platform)`, +8. Set Environment=`CORE_LIBRARIES=$(SolutionDir)\..\..\..\bin\runtime\-windows-$(Configuration)-$(Platform)`, where '\' is the target framework of current branch, for example `netcoreapp3.1` `net5.0`. 1. This points to the folder containing core libraries except `System.Private.CoreLib`. 2. This step can be skipped if you are debugging CLR tests that references only `System.Private.CoreLib`. Otherwise, it's required to debug a realworld application that references anything else, including `System.Runtime`. -10. Right-click the INSTALL project and choose 'Build' +9. Right-click the INSTALL project and choose 'Build' 1. This will load necessary information from cmake to Visual Studio. -11. Press F11 to start debugging at wmain in corerun (or set a breakpoint in source and press F5 to run to it) +10. Press F11 to start debugging at wmain in corerun (or set a breakpoint in source and press F5 to run to it) 1. As an example, set a breakpoint for the EEStartup function in ceemain.cpp to break into CoreCLR startup. -Steps 1-10 only need to be done once, and then (11) can be repeated whenever you want to start debugging. The above can be done with Visual Studio 2019 as writing. +Steps 1-9 only need to be done once as long as there's been no changes to the CMake files in the repository. Afterwards, step 10 can be repeated whenever you want to start debugging. The above can be done with Visual Studio 2019 as writing. Keeping with latest version of Visual Studio is recommended. ### Using SOS with windbg or cdb on Windows ### diff --git a/docs/workflow/editing-and-debugging.md b/docs/workflow/editing-and-debugging.md index 50213150e4b9de..46e3d0b5e58fbc 100644 --- a/docs/workflow/editing-and-debugging.md +++ b/docs/workflow/editing-and-debugging.md @@ -19,19 +19,20 @@ The repository has a number of Visual Studio Solutions files (`*.sln`) that are * `src\coreclr\System.Private.CoreLib\System.Private.CorLib.sln` - This solution is for all managed (C#) code that is defined in the runtime itself. This is all class library support of one form or another. - * `artifacts\obj\coreclr\windows..\CoreCLR.sln` - this solution contains most native (C++) projects + * `artifacts\obj\coreclr\windows..\ide\CoreCLR.sln` - this solution contains most native (C++) projects associated with the repository, including * `coreclr` - This is the main runtime DLL (the GC, class loader, interop are all here) * `corjit` - This is the Just In Time (JIT) compiler that compiles .NET Intermediate language to native code. * `corerun` - This is the simple host program that can run a .NET application * `crossgen` - This is the host program that runs the JIT compiler and produces .NET Native images (`*.ni.dll`) for C# code. + * This project can be automatically generated and opened in Visual Studio by running `./build.cmd -vs CoreCLR.sln -a -c ` from the root of the repository. Thus opening one of these two solution files (double clicking on them in Explorer) is typically all you need to do most editing. Notice that the CoreCLR solution is under the `artifacts` directory. This is because it is created as part of the build. -Thus you can only launch this solution after you have built at least once. +Thus you can only launch this solution after you have built at least once with the `-msbuild` flag or run the `./build.cmd -vs CoreCLR.sln` command line with the specified architecture and configuration. * See [Debugging CoreCLR](debugging/coreclr/debugging.md) diff --git a/eng/build.ps1 b/eng/build.ps1 index bcd9c9e2475131..5c61e1d1613d19 100644 --- a/eng/build.ps1 +++ b/eng/build.ps1 @@ -17,6 +17,7 @@ Param( [ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration, [ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor, [switch]$ninja, + [switch]$msbuild, [string]$cmakeargs, [switch]$pgoinstrument, [Parameter(ValueFromRemainingArguments=$true)][String[]]$properties @@ -51,7 +52,7 @@ function Get-Help() { Write-Host " [Default: Minimal]" Write-Host " -vs Open the solution with Visual Studio using the locally acquired SDK." Write-Host " Path or any project or solution name is accepted." - Write-Host " (Example: -vs Microsoft.CSharp)" + Write-Host " (Example: -vs Microsoft.CSharp or -vs CoreCLR.sln)" Write-Host "" Write-Host "Actions (defaults to -restore -build):" @@ -79,7 +80,8 @@ function Get-Help() { Write-Host "Native build settings:" Write-Host " -cmakeargs User-settable additional arguments passed to CMake." - Write-Host " -ninja Use Ninja instead of MSBuild to run the native build." + Write-Host " -ninja Use Ninja to drive the native build. (default)" + Write-Host " -msbuild Use MSBuild to drive the native build. This is a no-op for Mono." Write-Host " -pgoinstrument Build the CLR with PGO instrumentation." Write-Host "Command-line arguments not listed above are passed through to MSBuild." @@ -133,10 +135,10 @@ if ($vs) { if ($runtimeConfiguration) { $configToOpen = $runtimeConfiguration } - $vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\coreclr" | Join-Path -ChildPath "windows.$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | Join-Path -ChildPath "CoreCLR.sln" + $vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\coreclr" | Join-Path -ChildPath "windows.$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | Join-Path -ChildPath "ide" | Join-Path -ChildPath "CoreCLR.sln" if (-Not (Test-Path $vs)) { $repoRoot = Split-Path $PSScriptRoot -Parent - Invoke-Expression "& `"$repoRoot/src/coreclr/build-runtime.cmd`" -configureonly -$archToOpen -$configToOpen" + Invoke-Expression "& `"$repoRoot/src/coreclr/build-runtime.cmd`" -configureonly -$archToOpen -$configToOpen -msbuild" if ($lastExitCode -ne 0) { Write-Error "Failed to generate the CoreCLR solution file." exit 1 @@ -234,7 +236,9 @@ foreach ($argument in $PSBoundParameters.Keys) "properties" { $arguments += " " + $properties } "verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) } "cmakeargs" { $arguments += " /p:CMakeArgs=`"$($PSBoundParameters[$argument])`"" } - "ninja" { $arguments += " /p:Ninja=$($PSBoundParameters[$argument])" } + # The -ninja switch is a no-op since Ninja is the default generator on Windows. + "ninja" { } + "msbuild" { $arguments += " /p:Ninja=false" } "pgoinstrument" { $arguments += " /p:PgoInstrument=$($PSBoundParameters[$argument])"} # configuration and arch can be specified multiple times, so they should be no-ops here "configuration" {} @@ -270,4 +274,8 @@ if ($failedBuilds.Count -ne 0) { exit 1 } +if ($ninja) { + Write-Host "The -ninja option has no effect on Windows builds since the Ninja generator is the default generator." +} + exit 0 diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index 8e8a1f1e3bf1e9..cd97b87c85e904 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -471,7 +471,11 @@ if (MSVC) # Compile options for targeting windows add_compile_options($<$:/nologo>) # Suppress Startup Banner - add_compile_options($<$:/W3>) # set warning level to 3 + # /W3 is added by default by CMake, so remove it + string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + # set default warning level to 3 but allow targets to override it. + add_compile_options($<$:/W$>,$,3>>>) add_compile_options($<$:/WX>) # treat warnings as errors add_compile_options($<$:/Oi>) # enable intrinsics add_compile_options($<$:/Oy->) # disable suppressing of the creation of frame pointers on the call stack for quicker function calls diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index 3e01c275025132..ae4c66091d3838 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -466,34 +466,6 @@ function(add_executable_clr) _add_executable(${ARGV}) endfunction() -function(generate_module_index Target ModuleIndexFile) - if(CLR_CMAKE_HOST_WIN32) - set(scriptExt ".cmd") - else() - set(scriptExt ".sh") - endif() - - set(index_timestamp ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${Target}_index.timestamp) - - add_custom_command( - OUTPUT ${index_timestamp} - COMMAND ${CLR_ENG_NATIVE_DIR}/genmoduleindex${scriptExt} $ ${ModuleIndexFile} - COMMAND ${CMAKE_COMMAND} -E touch ${index_timestamp} - DEPENDS ${Target} - COMMENT "Generating ${Target} module index file -> ${ModuleIndexFile}" - ) - - set_source_files_properties( - ${ModuleIndexFile} - PROPERTIES GENERATED TRUE - ) - - add_custom_target( - ${Target}_module_index_header - DEPENDS ${index_timestamp} - ) -endfunction(generate_module_index) - # add_linker_flag(Flag [Config1 Config2 ...]) function(add_linker_flag Flag) if (ARGN STREQUAL "") diff --git a/eng/pipelines/coreclr/templates/build-job.yml b/eng/pipelines/coreclr/templates/build-job.yml index d857a6fd375954..4766c5c9a7292f 100644 --- a/eng/pipelines/coreclr/templates/build-job.yml +++ b/eng/pipelines/coreclr/templates/build-job.yml @@ -132,12 +132,6 @@ jobs: - name: clrBuildPALTestsBuildArg value: '-paltests ' - - name: ninjaArg - value: '' - - ${{ if eq(parameters.osGroup, 'windows') }}: - - name: ninjaArg - value: '-ninja' - - name: pgoInstrumentArg value: '' - ${{ if eq(parameters.pgoType, 'PGO' )}}: @@ -194,10 +188,10 @@ jobs: # Build CoreCLR Runtime - ${{ if ne(parameters.osGroup, 'windows') }}: - - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(ninjaArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: $(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) $(crossArg) $(osArg) -ci $(compilerArg) $(clrBuildPALTestsBuildArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) displayName: Build CoreCLR Runtime - ${{ if eq(parameters.osGroup, 'windows') }}: - - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(ninjaArg) $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) + - script: set __TestIntermediateDir=int&&$(Build.SourcesDirectory)/src/coreclr/build-runtime$(scriptExt) $(buildConfig) $(archType) -ci $(enforcePgoArg) $(pgoInstrumentArg) $(officialBuildIdArg) $(clrInterpreterBuildArg) displayName: Build CoreCLR Runtime - ${{ if in(parameters.osGroup, 'OSX', 'iOS', 'tvOS') }}: diff --git a/eng/pipelines/global-build.yml b/eng/pipelines/global-build.yml index 239f8bb0b9de7b..0d8aedc98d8d2c 100644 --- a/eng/pipelines/global-build.yml +++ b/eng/pipelines/global-build.yml @@ -45,6 +45,21 @@ jobs: buildArgs: -c release -runtimeConfiguration debug timeoutInMinutes: 90 +# +# Build with Release config and runtimeConfiguration with MSBuild generator +# +- template: /eng/pipelines/common/platform-matrix.yml + parameters: + jobTemplate: /eng/pipelines/common/global-build-job.yml + buildConfig: release + platforms: + - windows_x86 + jobParameters: + testGroup: innerloop + nameSuffix: MSBuild_CMake + buildArgs: -c Release -msbuild + timeoutInMinutes: 90 + # # Build with Debug config and Release runtimeConfiguration # diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 7e9c6b8a656b4d..8dc3564a781ea2 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -12,8 +12,6 @@ include(../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) if(MSVC) - string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - add_compile_options($<$:/EHa>) # enable C++ EH (w/ SEH exceptions) set(CMAKE_CXX_STANDARD_LIBRARIES "") # do not link against standard win32 libs i.e. kernel32, uuid, user32, etc. endif (MSVC) @@ -48,6 +46,21 @@ endif(CLR_CROSS_COMPONENTS_BUILD) #------------------- include(pgosupport.cmake) +#--------------------------- +# Build the single file host +#--------------------------- +if(CLR_CMAKE_BUILD_SUBSET_RUNTIME AND NOT CLR_CROSS_COMPONENTS_BUILD) + add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) +endif() + +#------------------------- +# Enable C++ EH with SEH +#------------------------- +if (MSVC) + string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + add_compile_options($<$:/EHa>) # enable C++ EH (w/ SEH exceptions) +endif() + #------------------------------- # Include libraries native shims #------------------------------- @@ -130,10 +143,6 @@ if(FEATURE_STANDALONE_GC) endif (CLR_CMAKE_BUILD_SUBSET_RUNTIME) endif(FEATURE_STANDALONE_GC) -if(CLR_CMAKE_BUILD_SUBSET_RUNTIME AND NOT CLR_CROSS_COMPONENTS_BUILD) - add_subdirectory(${CLR_SRC_NATIVE_DIR}/corehost/apphost/static Corehost.Static) -endif() - if (CLR_CMAKE_HOST_UNIX) include_directories("pal/inc") include_directories("pal/inc/rt") diff --git a/src/coreclr/build-runtime.cmd b/src/coreclr/build-runtime.cmd index 89cce1aa1d11fe..e31d9b7b81282d 100644 --- a/src/coreclr/build-runtime.cmd +++ b/src/coreclr/build-runtime.cmd @@ -78,7 +78,7 @@ set __CrossArch2= set __CrossOS=0 set __PgoOptDataPath= set __CMakeArgs= -set __Ninja=0 +set __Ninja=1 @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 @@ -152,7 +152,9 @@ if /i "%1" == "-skipnative" (set __BuildNative=0&set processedArgs=!pro if /i "%1" == "-skipcrossarchnative" (set __SkipCrossArchNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skipgenerateversion" (set __SkipGenerateVersion=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skiprestoreoptdata" (set __RestoreOptData=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-ninja" (set __Ninja=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +REM -ninja is a no-op option since Ninja is now the default generator on Windows. +if /i "%1" == "-ninja" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-msbuild" (set __Ninja=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-pgoinstrument" (set __PgoInstrument=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-enforcepgo" (set __EnforcePgo=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-nopgooptimize" (set __PgoOptimize=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -284,7 +286,7 @@ set "__IntermediatesDir=%__RootBinDir%\obj\coreclr\%__TargetOS%.%__BuildArch%.%_ set "__LogsDir=%__RootBinDir%\log\!__BuildType!" set "__MsbuildDebugLogsDir=%__LogsDir%\MsbuildDebugLogs" set "__ArtifactsIntermediatesDir=%__RepoRootDir%\artifacts\obj\coreclr\" -if "%__Ninja%"=="1" (set "__IntermediatesDir=%__RootBinDir%\nmakeobj\%__TargetOS%.%__BuildArch%.%__BuildType%") +if "%__Ninja%"=="0" (set "__IntermediatesDir=%__IntermediatesDir%\ide") set "__PackagesBinDir=%__BinDir%\.nuget" set "__CrossComponentBinDir=%__BinDir%" set "__CrossCompIntermediatesDir=%__IntermediatesDir%\crossgen" @@ -707,6 +709,7 @@ REM ============================================================================ echo %__MsgPrefix%Build succeeded. Finished at %TIME% echo %__MsgPrefix%Product binaries are available at !__BinDir! + exit /b 0 REM ========================================================================================= diff --git a/src/coreclr/debug/runtimeinfo/CMakeLists.txt b/src/coreclr/debug/runtimeinfo/CMakeLists.txt index a7811d6ce2c2e0..c4ad348e6b736f 100644 --- a/src/coreclr/debug/runtimeinfo/CMakeLists.txt +++ b/src/coreclr/debug/runtimeinfo/CMakeLists.txt @@ -6,11 +6,34 @@ set(RUNTIMEINFO_SOURCES add_library_clr(runtimeinfo STATIC ${RUNTIMEINFO_SOURCES}) -add_dependencies(runtimeinfo coreclr_module_index_header) +function(generate_module_index Target ModuleIndexFile) + if(CLR_CMAKE_HOST_WIN32) + set(scriptExt ".cmd") + else() + set(scriptExt ".sh") + endif() -if (NOT (CLR_CMAKE_TARGET_WIN32 AND (CLR_CMAKE_TARGET_ARCH_I386 OR CLR_CMAKE_TARGET_ARCH_ARM) AND CLR_CMAKE_HOST_ARCH_AMD64)) - add_dependencies(runtimeinfo mscordaccore_module_index_header) - add_dependencies(runtimeinfo mscordbi_module_index_header) + add_custom_command( + OUTPUT ${ModuleIndexFile} + COMMAND ${CLR_ENG_NATIVE_DIR}/genmoduleindex${scriptExt} $ ${ModuleIndexFile} + DEPENDS ${Target} + COMMENT "Generating ${Target} module index file -> ${ModuleIndexFile}" + ) + + set_source_files_properties( + ${ModuleIndexFile} + PROPERTIES GENERATED TRUE + ) + + add_dependencies(runtimeinfo ${Target}) + target_sources(runtimeinfo PRIVATE ${ModuleIndexFile}) +endfunction(generate_module_index) + +generate_module_index(coreclr ${CMAKE_CURRENT_BINARY_DIR}/runtimemoduleindex.h) +if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + add_dependencies(runtimeinfo inject_debug_resources_coreclr) + generate_module_index(mscordaccore ${CMAKE_CURRENT_BINARY_DIR}/dacmoduleindex.h) + generate_module_index(mscordbi ${CMAKE_CURRENT_BINARY_DIR}/dbimoduleindex.h) endif() # publish runtimeinfo lib diff --git a/src/coreclr/dlls/mscordac/CMakeLists.txt b/src/coreclr/dlls/mscordac/CMakeLists.txt index 91e4d66c9244ef..3ec2b96445421c 100644 --- a/src/coreclr/dlls/mscordac/CMakeLists.txt +++ b/src/coreclr/dlls/mscordac/CMakeLists.txt @@ -192,12 +192,6 @@ endif(CLR_CMAKE_HOST_UNIX) target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES}) -# Create the DAC module index header file containing the DAC build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(mscordaccore ${GENERATED_INCLUDE_DIR}/dacmoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - # add the install targets install_clr(TARGETS mscordaccore ADDITIONAL_DESTINATIONS sharedFramework) diff --git a/src/coreclr/dlls/mscordbi/CMakeLists.txt b/src/coreclr/dlls/mscordbi/CMakeLists.txt index a0fae4948469ff..f000748bee0d4c 100644 --- a/src/coreclr/dlls/mscordbi/CMakeLists.txt +++ b/src/coreclr/dlls/mscordbi/CMakeLists.txt @@ -119,11 +119,5 @@ elseif(CLR_CMAKE_HOST_UNIX) endif(CLR_CMAKE_HOST_WIN32) -# Create the DBI module index header file containing the DBI build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(mscordbi ${GENERATED_INCLUDE_DIR}/dbimoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - # add the install targets install_clr(TARGETS mscordbi ADDITIONAL_DESTINATIONS sharedFramework) diff --git a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt index b22ccf1a6bc580..09897cd7753819 100644 --- a/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt +++ b/src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt @@ -173,12 +173,6 @@ target_sources(coreclr_static PUBLIC $) target_link_libraries(coreclr_static PUBLIC ${CORECLR_LIBRARIES} clrjit_static cee_wks_mergeable) target_compile_definitions(coreclr_static PUBLIC CORECLR_EMBEDDED) -# Create the runtime module index header file containing the coreclr build id -# for xplat and the timestamp/size on Windows. -if(FEATURE_SINGLE_FILE_DIAGNOSTICS) - generate_module_index(coreclr ${GENERATED_INCLUDE_DIR}/runtimemoduleindex.h) -endif(FEATURE_SINGLE_FILE_DIAGNOSTICS) - if(CLR_CMAKE_TARGET_WIN32) # Add dac table & debug resource to coreclr get_include_directories(INC_DIR) @@ -204,32 +198,48 @@ if(CLR_CMAKE_TARGET_WIN32) endif() add_custom_command( - DEPENDS coreclr singlefilehost mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp + DEPENDS coreclr mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/debug/daccess/daccess.cpp # make and inject dactable for coreclr COMMAND cmd /c ${CLR_REPO_ROOT_DIR}/dotnet.cmd exec ${CMAKE_INSTALL_PREFIX}/DacTableGen/DacTableGen.dll /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:$ /dll:$ /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/wks.bin /dll:$ + # make CLRDEBUGINFO resource and inject into coreclr + COMMAND GenClrDebugResource /dac:$ /dbi:$ /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin + COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO + + # inject MINIDUMP_AUXILIARY_PROVIDER into coreclr + COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$ /name:MINIDUMP_AUXILIARY_PROVIDER + + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp + COMMENT Add dactable, debug resources, and dump helper resources to coreclr + ) + + if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) + add_custom_target(inject_debug_resources_coreclr ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_coreclr.timestamp) + endif() + + add_custom_command( + DEPENDS singlefilehost mscordaccore mscordbi ${CLR_DIR}/debug/daccess/daccess.cpp + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp + COMMAND ${CMAKE_CXX_COMPILER} /P /EP /TP ${PREPROCESS_DEFINITIONS} ${INC_DIR} /Fi${CMAKE_CURRENT_BINARY_DIR}/daccess.i ${CLR_DIR}/debug/daccess/daccess.cpp + # make and inject dactable for singlefilehost COMMAND cmd /c ${CLR_REPO_ROOT_DIR}/dotnet.cmd exec ${CMAKE_INSTALL_PREFIX}/DacTableGen/DacTableGen.dll /dac:${CMAKE_CURRENT_BINARY_DIR}/daccess.i /pdb:$ /dll:$ /bin:${CMAKE_CURRENT_BINARY_DIR}/sfh.bin COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/sfh.bin /dll:$ - # make CLRDEBUGINFO resource and inject into coreclr and singlefilehost + # make CLRDEBUGINFO resource and inject into singlefilehost COMMAND GenClrDebugResource /dac:$ /dbi:$ /sku:onecoreclr /out:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin - COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO COMMAND InjectResource /bin:${CMAKE_CURRENT_BINARY_DIR}/clrDebugResource.bin /dll:$ /name:CLRDEBUGINFO - # inject MINIDUMP_AUXILIARY_PROVIDER into coreclr - COMMAND InjectResource /bin:${CMAKE_CURRENT_SOURCE_DIR}/dump_helper_resource.bin /dll:$ /name:MINIDUMP_AUXILIARY_PROVIDER - - COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp - COMMENT Add dactable, debug resources, and dump helper resources to coreclr and singlefilehost + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp + COMMENT Add dactable, debug resources, and dump helper resources to singlefilehost ) if(NOT DEFINED CLR_CROSS_COMPONENTS_BUILD) - add_custom_target(inject_debug_resources ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources.timestamp) + add_custom_target(inject_debug_resources_singlefilehost ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/inject_debug_resources_singlefilehost.timestamp) endif() endif(CLR_CMAKE_TARGET_WIN32) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 3eb595b9eaded0..7401264cf16f59 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -8,8 +8,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") add_compile_options(-Wno-error) endif() -add_compile_options($<$:-W4>) - function(create_standalone_jit) set(oneValueArgs TARGET OS ARCH) @@ -447,6 +445,7 @@ function(add_jit jitName) set_property(TARGET ${jitName} APPEND_STRING PROPERTY LINK_FLAGS ${JIT_EXPORTS_LINKER_OPTION}) set_property(TARGET ${jitName} APPEND_STRING PROPERTY LINK_DEPENDS ${JIT_EXPORTS_FILE}) + set_target_properties(${jitName} PROPERTIES MSVC_WARNING_LEVEL 4) target_link_libraries(${jitName} ${JIT_LINK_LIBRARIES} diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj index c6f96405f4d25a..eb29aa04397f5c 100644 --- a/src/coreclr/runtime.proj +++ b/src/coreclr/runtime.proj @@ -26,7 +26,8 @@ '$(PgoInstrument)' != 'true'" Include="-enforcepgo" /> <_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CrossDac)' != ''" Include="-$(CrossDac)dac" /> - <_CoreClrBuildArg Condition="'$(Ninja)' == 'true'" Include="-ninja" /> + <_CoreClrBuildArg Condition="'$(Ninja)' == 'true' and !$([MSBuild]::IsOsPlatform(Windows))" Include="-ninja" /> + <_CoreClrBuildArg Condition="'$(Ninja)' == 'false' and $([MSBuild]::IsOsPlatform(Windows))" Include="-msbuild" /> <_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' != 'true'" Include="-skipruntime" /> <_CoreClrBuildArg Condition="'$(ClrJitSubset)' != 'true'" Include="-skipjit" /> <_CoreClrBuildArg Condition="'$(ClrILToolsSubset)' != 'true'" Include="-skipiltools" /> diff --git a/src/installer/corehost.proj b/src/installer/corehost.proj index 6ba56f27aec807..09d6bc7ebb6bf2 100644 --- a/src/installer/corehost.proj +++ b/src/installer/corehost.proj @@ -84,7 +84,7 @@ $(BuildArgs) incremental-native-build $(BuildArgs) rootdir $(RepoRoot) $(BuildArgs) coreclrartifacts $(CoreCLRArtifactsPath) - $(BuildArgs) ninja + $(BuildArgs) msbuild $(BuildArgs) runtimeflavor $(RuntimeFlavor) $(BuildArgs) runtimeconfiguration $(RuntimeConfiguration) diff --git a/src/libraries/Native/Windows/CMakeLists.txt b/src/libraries/Native/Windows/CMakeLists.txt index 3f9924adb0a9d2..77b6d979c7a82c 100644 --- a/src/libraries/Native/Windows/CMakeLists.txt +++ b/src/libraries/Native/Windows/CMakeLists.txt @@ -49,9 +49,8 @@ string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_compile_options(/EHa) # enable C++ EH (w/ SEH exceptions) add_compile_options(/Zp8) # pack structs on 8-byte boundary add_compile_options(/Gy) # separate functions for linker -add_compile_options(/Zc:wchar_t-) # C++ language conformance: wchar_t is NOT the native type, but a typedef add_compile_options(/Zc:forScope) # C++ language conformance: enforce Standard C++ for scoping rules -string(REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +string(REPLACE "/GR " " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") add_compile_options(/GR-) # disable C++ RTTI add_compile_options(/FC) # use full pathnames in diagnostics add_compile_options(/MP) # Build with Multiple Processes (number of processes equal to the number of processors) @@ -80,7 +79,6 @@ list(APPEND __SharedLinkArgs /GUARD:CF) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") add_compile_options($<$:/GL>) -add_compile_options($<$:/O1>) list(APPEND __LinkLibraries $<$:libcmtd.lib>) list(APPEND __LinkLibraries $<$:libcmt.lib>) diff --git a/src/libraries/Native/build-native.cmd b/src/libraries/Native/build-native.cmd index 29037e2ef91253..15389a55f24d67 100644 --- a/src/libraries/Native/build-native.cmd +++ b/src/libraries/Native/build-native.cmd @@ -15,7 +15,7 @@ set __TargetOS=windows set CMAKE_BUILD_TYPE=Debug set "__LinkArgs= " set "__LinkLibraries= " -set __Ninja=0 +set __Ninja=1 :Arg_Loop :: Since the native build requires some configuration information before msbuild is called, we have to do some manual args parsing @@ -37,7 +37,7 @@ if /i [%1] == [Browser] ( set __TargetOS=Browser&&shift&goto Arg_Loop) if /i [%1] == [rebuild] ( set __BuildTarget=rebuild&&shift&goto Arg_Loop) -if /i [%1] == [ninja] ( set __Ninja=1&&shift&goto Arg_Loop) +if /i [%1] == [msbuild] ( set __Ninja=0&&shift&goto Arg_Loop) shift goto :Arg_Loop @@ -67,6 +67,9 @@ if %__CMakeBinDir% == "" ( if %__IntermediatesDir% == "" ( set "__IntermediatesDir=%__artifactsDir%\obj\native\%__outConfig%" ) +if %__Ninja% == 0 ( + set "__IntermediatesDir=%__IntermediatesDir%\ide" +) set "__CMakeBinDir=%__CMakeBinDir:\=/%" set "__IntermediatesDir=%__IntermediatesDir:\=/%" diff --git a/src/libraries/Native/build-native.proj b/src/libraries/Native/build-native.proj index 900d7f0ad7262a..edba5f1fbddb75 100644 --- a/src/libraries/Native/build-native.proj +++ b/src/libraries/Native/build-native.proj @@ -6,7 +6,6 @@ $(BuildTargetFramework) $(NetCoreAppCurrent) <_BuildNativeArgs>$(TargetArchitecture) $(Configuration) outconfig $(TargetFramework)-$(TargetOS)-$(Configuration)-$(TargetArchitecture) -os $(TargetOS) - <_BuildNativeArgs Condition="'$(Ninja)' == 'true'">$(_BuildNativeArgs) ninja @@ -18,6 +17,7 @@ BeforeTargets="Build" Condition="!$([MSBuild]::IsOsPlatform(Windows))"> + <_BuildNativeArgs Condition="'$(Ninja)' == 'true'">$(_BuildNativeArgs) ninja + + <_BuildNativeArgs Condition="'$(Ninja)' == 'false'">$(_BuildNativeArgs) msbuild + + diff --git a/src/native/corehost/CMakeLists.txt b/src/native/corehost/CMakeLists.txt index 3ce1d78bec72cd..d7784410ed03d1 100644 --- a/src/native/corehost/CMakeLists.txt +++ b/src/native/corehost/CMakeLists.txt @@ -16,7 +16,7 @@ if (MSVC) add_compile_options($<$:/wd4200>) add_compile_options($<$:/wd4244>) # Host components don't try to handle asynchronous exceptions - add_compile_options(/EHsc) + add_compile_options($<$:/EHsc>) elseif (CMAKE_CXX_COMPILER_ID MATCHES GNU) # Prevents libc from calling pthread_cond_destroy on static objects in # dlopen()'ed library which we dlclose() in pal::unload_library. diff --git a/src/native/corehost/build.cmd b/src/native/corehost/build.cmd index d346198a6603ef..6239d5df9507b0 100644 --- a/src/native/corehost/build.cmd +++ b/src/native/corehost/build.cmd @@ -17,7 +17,7 @@ set "__LinkArgs= " set "__LinkLibraries= " set __PortableBuild=0 set __IncrementalNativeBuild=0 -set __Ninja=0 +set __Ninja=1 :Arg_Loop if [%1] == [] goto :InitVSEnv @@ -43,7 +43,7 @@ if /i [%1] == [commit] (set __CommitSha=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [incremental-native-build] ( set __IncrementalNativeBuild=1&&shift&goto Arg_Loop) if /i [%1] == [rootDir] ( set __rootDir=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [coreclrartifacts] (set __CoreClrArtifacts=%2&&shift&&shift&goto Arg_Loop) -if /i [%1] == [ninja] (set __Ninja=1) +if /i [%1] == [msbuild] (set __Ninja=0) if /i [%1] == [runtimeflavor] (set __RuntimeFlavor=%2&&shift&&shift&goto Arg_Loop) if /i [%1] == [runtimeconfiguration] (set __RuntimeConfiguration=%2&&shift&&shift&goto Arg_Loop) @@ -73,6 +73,9 @@ if %__CMakeBinDir% == "" ( if %__IntermediatesDir% == "" ( set "__IntermediatesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\corehost" ) +if %__Ninja% == 0 ( + set "__IntermediatesDir=%__IntermediatesDir%\ide" +) set "__ResourcesDir=%__objDir%\%__TargetRid%.%CMAKE_BUILD_TYPE%\hostResourceFiles" set "__CMakeBinDir=%__CMakeBinDir:\=/%" set "__IntermediatesDir=%__IntermediatesDir:\=/%" diff --git a/src/tests/Common/dir.common.props b/src/tests/Common/dir.common.props index 3a60c77ea93fa7..afac3e7ae459cf 100644 --- a/src/tests/Common/dir.common.props +++ b/src/tests/Common/dir.common.props @@ -24,7 +24,9 @@ for the lock file, and props/targets from nuget packages. --> $(BaseOutputPath)/obj/$(OSPlatformConfig)/Managed/$(BuildProjectRelativeDir) $(BaseIntermediateOutputPath) - <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ + true + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == '' and '$(UseVisualStudioNativeBinariesLayout)' != 'true'">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == '' and '$(UseVisualStudioNativeBinariesLayout)' == 'true'">$(BaseOutputPath)\obj\$(OSPlatformConfig)\Native\ide\ $(BaseOutputPath)\packages\$(BuildProjectRelativeDir) $([System.IO.Path]::GetFullPath($(IntermediateOutputPath)\$(PackageRuntimeIdentifier))) diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 80bda0ec6fc5bc..cf36a8cdf61b02 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -114,48 +114,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -271,7 +285,7 @@ %(Identity) - + @@ -367,7 +381,7 @@ - + diff --git a/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt b/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt index 2708ce303ae6ff..51c8ecd4aed44a 100644 --- a/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt +++ b/src/tests/Interop/COM/Dynamic/Server/CMakeLists.txt @@ -11,7 +11,7 @@ add_custom_command( COMMAND ${MIDL} ${MIDL_INCLUDE_DIRECTORIES} /h ${IDL_OUTPUT_DIRECTORY}/${IDL_NAME}.h ${MIDL_DEFINITIONS} /out ${IDL_OUTPUT_DIRECTORY} - /tlb ${CMAKE_CURRENT_BINARY_DIR}/$/DynamicTestServer.tlb + /tlb $/DynamicTestServer.tlb ${IDL_SOURCE} DEPENDS ${IDL_SOURCE} COMMENT "Compiling ${IDL_SOURCE}") @@ -37,7 +37,7 @@ add_library (${PROJECT_NAME} SHARED ${SOURCES}) target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARIES_ADDITIONAL}) # Copy manifest file to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/DynamicTestServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/DynamicTestServer.X.manifest) +file(GENERATE OUTPUT $/DynamicTestServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/DynamicTestServer.X.manifest) # add the install targets install (TARGETS ${PROJECT_NAME} DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt index 38954f3d1d2352..b5eb8e0a557f97 100644 --- a/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/DefaultInterfaces/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientDefaultInterfaces ${SOURCES}) target_link_libraries(COMClientDefaultInterfaces ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientDefaultInterfaces DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt index a8a8bba03ccfa0..d377599d0856e8 100644 --- a/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Dispatch/CMakeLists.txt @@ -10,7 +10,7 @@ add_executable (COMClientDispatch ${SOURCES}) target_link_libraries(COMClientDispatch ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientDispatch DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt index 43063bd532d3af..d80b993c18f3c2 100644 --- a/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Events/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientEvents ${SOURCES}) target_link_libraries(COMClientEvents ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientEvents DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt index d850c7ee067a16..70b85b0cb0e59a 100644 --- a/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Licensing/CMakeLists.txt @@ -11,7 +11,7 @@ add_executable (COMClientLicensing ${SOURCES}) target_link_libraries(COMClientLicensing ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientLicensing DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt b/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt index 57af5d8af9b7bd..62ca91cd4288c2 100644 --- a/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeClients/Primitives/CMakeLists.txt @@ -16,7 +16,7 @@ add_executable (COMClientPrimitives ${SOURCES}) target_link_libraries(COMClientPrimitives ${LINK_LIBRARIES_ADDITIONAL}) # Copy CoreShim manifest to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) +file(GENERATE OUTPUT $/CoreShim.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/CoreShim.X.manifest) # add the install targets install (TARGETS COMClientPrimitives DESTINATION bin) diff --git a/src/tests/Interop/COM/NativeServer/CMakeLists.txt b/src/tests/Interop/COM/NativeServer/CMakeLists.txt index 9f661bfb9e6227..1f757d8e9cdf6c 100644 --- a/src/tests/Interop/COM/NativeServer/CMakeLists.txt +++ b/src/tests/Interop/COM/NativeServer/CMakeLists.txt @@ -13,7 +13,7 @@ add_library (COMNativeServer SHARED ${SOURCES}) target_link_libraries(COMNativeServer ${LINK_LIBRARIES_ADDITIONAL}) # Copy manifest file to project output -file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/COMNativeServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/COMNativeServer.X.manifest) +file(GENERATE OUTPUT $/COMNativeServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/COMNativeServer.X.manifest) # add the install targets install (TARGETS COMNativeServer DESTINATION bin) diff --git a/src/tests/build.cmd b/src/tests/build.cmd index 176dd07297447f..b4f9a7b0702a41 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -55,6 +55,7 @@ set __CopyNativeTestBinaries=0 set __CopyNativeProjectsAfterCombinedTestBuild=true set __SkipGenerateLayout=0 set __GenerateLayoutOnly=0 +set __Ninja=1 @REM CMD has a nasty habit of eating "=" on the argument list, so passing: @REM -priority=1 @@ -97,6 +98,7 @@ if /i "%1" == "copynativeonly" (set __CopyNativeTestBinaries=1&set __Skip if /i "%1" == "generatelayoutonly" (set __SkipManaged=1&set __SkipNative=1&set __CopyNativeProjectsAfterCombinedTestBuild=false&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "buildtestwrappersonly" (set __SkipNative=1&set __SkipManaged=1&set __BuildTestWrappersOnly=1&set __SkipGenerateLayout=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-msbuild" (set __Ninja=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "buildagainstpackages" (echo error: Remove /BuildAgainstPackages switch&&exit /b1) if /i "%1" == "crossgen" (set __DoCrossgen=1&set __TestBuildMode=crossgen&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "crossgen2" (set __DoCrossgen2=1&set __TestBuildMode=crossgen2&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -159,6 +161,7 @@ if not defined __TestIntermediateDir ( set "__TestIntermediateDir=tests\coreclr\obj\%__TargetOS%.%__BuildArch%.%__BuildType%" ) set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native" +if "%__Ninja%"=="0" (set "__NativeTestIntermediatesDir=%__NativeTestIntermediatesDir%\ide") set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed" REM Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash @@ -211,7 +214,13 @@ echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildA call "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch% @if defined _echo @echo on -set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" +set __ExtraCmakeArgs= + +if %__Ninja% EQU 1 ( + set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0 -DCMAKE_BUILD_TYPE=!__BuildType!" +) else ( + set __ExtraCmakeArgs="-DCMAKE_SYSTEM_VERSION=10.0" +) call "%__RepoRootDir%\eng\native\gen-buildsys.cmd" "%__ProjectFilesDir%" "%__NativeTestIntermediatesDir%" %__VSVersion% %__BuildArch% !__ExtraCmakeArgs! if not !errorlevel! == 0 ( @@ -237,8 +246,16 @@ set __MsbuildWrn=/flp1:WarningsOnly;LogFile=!__BuildWrn! set __MsbuildErr=/flp2:ErrorsOnly;LogFile=!__BuildErr! set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! -REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. -"%CMakePath%" --build %__NativeTestIntermediatesDir% --target install --config %__BuildType% -- /nologo /m !__Logging! +set __CmakeBuildToolArgs= + +if %__Ninja% EQU 1 ( + set __CmakeBuildToolArgs= +) else ( + REM We pass the /m flag directly to MSBuild so that we can get both MSBuild and CL parallelism, which is fastest for our builds. + set __CmakeBuildToolArgs=/nologo /m !__Logging! +) + +"%CMakePath%" --build %__NativeTestIntermediatesDir% --target install --config %__BuildType% -- !__CmakeBuildToolArgs! if errorlevel 1 ( echo %__ErrMsgPrefix%%__MsgPrefix%Error: native test build failed. @@ -310,6 +327,12 @@ echo %__MsgPrefix%Building tests divided into %__NumberOfTestGroups% test groups set __CommonMSBuildCmdPrefix=powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -Command "!__RepoRootDir!\eng\common\msbuild.ps1" !__ArcadeScriptArgs! +set __NativeBinariesLayoutTypeArg= + +if %__Ninja% == 0 ( + set __NativeBinariesLayoutTypeArg=/p:UseVisualStudioNativeBinariesLayout=true +) + for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%";Append=!__AppendToLog! @@ -330,6 +353,7 @@ for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( set __MSBuildBuildArgs=!__MSBuildBuildArgs! !__UnprocessedBuildArgs! set __MSBuildBuildArgs=!__MSBuildBuildArgs! /p:CopyNativeProjectBinaries=!__CopyNativeProjectsAfterCombinedTestBuild! set __MSBuildBuildArgs=!__MSBuildBuildArgs! /p:__SkipPackageRestore=true + set __MSBuildBuildArgs=!__MSBuildBuildArgs! !__NativeBinariesLayoutTypeArg! echo Running: msbuild !__MSBuildBuildArgs! !__CommonMSBuildCmdPrefix! !__MSBuildBuildArgs! @@ -344,7 +368,7 @@ for /l %%G in (1, 1, %__NumberOfTestGroups%) do ( goto :Exit_Failure ) ) else ( - set __MSBuildBuildArgs=!__RepoRootDir!\src\tests\build.proj -warnAsError:0 /nodeReuse:false !__Logging! !TargetsWindowsMsbuildArg! !__msbuildArgs! !__PriorityArg! !__BuildNeedTargetArg! !__UnprocessedBuildArgs! "/t:CopyAllNativeProjectReferenceBinaries" + set __MSBuildBuildArgs=!__RepoRootDir!\src\tests\build.proj -warnAsError:0 /nodeReuse:false !__Logging! !TargetsWindowsMsbuildArg! !__msbuildArgs! !__PriorityArg! !__BuildNeedTargetArg! !__NativeBinariesLayoutTypeArg! !__UnprocessedBuildArgs! "/t:CopyAllNativeProjectReferenceBinaries" echo Running: msbuild !__MSBuildBuildArgs! !__CommonMSBuildCmdPrefix! !__MSBuildBuildArgs!