Skip to content

Commit

Permalink
Add configureonly option to host native build (dotnet#60889)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Oct 27, 2021
1 parent ffa122a commit 760a76b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
8 changes: 5 additions & 3 deletions docs/workflow/editing-and-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ The repository has a number of Visual Studio Solutions files (`*.sln`) that are
* `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 <Arch> -c <BuildType>` from the root of the repository.
* `artifacts\obj\win-<Arch>.<BuildType>\corehost\ide\corehost.sln` - this solution contains the native (C++) projects for the [host components](../design/features/host-components)
* This project can be automatically generated and opened in Visual Studio by running `./build.cmd -vs corehost.sln -a <Arch> -c <BuildType>` 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
Thus opening one of these 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 with the `-msbuild` flag or run the `./build.cmd -vs CoreCLR.sln` command line with the specified architecture and configuration.
Notice that the CoreCLR and corehost solutions are under the `artifacts` directory. This is because they are created as part of the build.
Thus you can only launch these solutions after you have built at least once with the `-msbuild` flag or run the `./build.cmd -vs CoreCLR.sln` or `./build.cmd -vs corehost.sln` command line with the specified architecture and configuration.

* See [Debugging CoreCLR](debugging/coreclr/debugging.md)

Expand Down
2 changes: 1 addition & 1 deletion eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ if ($vs) {
elseif ($vs -ieq "corehost.sln") {
$vs = Split-Path $PSScriptRoot -Parent | Join-Path -ChildPath "artifacts\obj\" | Join-Path -ChildPath "win-$archToOpen.$((Get-Culture).TextInfo.ToTitleCase($configToOpen))" | Join-Path -ChildPath "corehost" | Join-Path -ChildPath "ide" | Join-Path -ChildPath "corehost.sln"
if (-Not (Test-Path $vs)) {
Invoke-Expression "& `"$repoRoot/eng/common/msbuild.ps1`" $repoRoot/src/native/corehost/corehost.proj /clp:nosummary /restore /p:Ninja=false"
Invoke-Expression "& `"$repoRoot/eng/common/msbuild.ps1`" $repoRoot/src/native/corehost/corehost.proj /clp:nosummary /restore /p:Ninja=false /p:Configuration=$configToOpen /p:TargetArchitecture=$archToOpen /p:ConfigureOnly=true"
if ($lastExitCode -ne 0) {
Write-Error "Failed to generate the CoreHost solution file."
exit 1
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="-cmakeargs &quot;$(CMakeArgs)&quot;" />
<_CoreClrBuildArg Include="-$(Configuration.ToLower())" />
<_CoreClrBuildArg Include="$(Compiler)" />
<_CoreClrBuildArg Condition="'$(ConfigureOnly)' == 'true'" Include="-configureonly" />
<_CoreClrBuildArg Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="-ci" />
<_CoreClrBuildArg Condition="'$(CrossBuild)' == 'true'" Include="-cross" />
<_CoreClrBuildArg Condition="'$(PortableBuild)' != 'true'" Include="-portablebuild=false" />
Expand Down
14 changes: 10 additions & 4 deletions src/native/corehost/build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ set __engNativeDir=%__sourceDir%\..\..\..\eng\native
set __CMakeBinDir=""
set __IntermediatesDir=""
set __BuildArch=x64
set __appContainer=""
set CMAKE_BUILD_TYPE=Debug
set "__LinkArgs= "
set "__LinkLibraries= "
set __PortableBuild=0
set __ConfigureOnly=0
set __IncrementalNativeBuild=0
set __Ninja=1

Expand All @@ -40,6 +38,7 @@ if /i [%1] == [fxrver] (set __HostFxrVersion=%2&&shift&&shift&goto Arg_Loop
if /i [%1] == [policyver] (set __HostPolicyVersion=%2&&shift&&shift&goto Arg_Loop)
if /i [%1] == [commit] (set __CommitSha=%2&&shift&&shift&goto Arg_Loop)

if /i [%1] == [configureonly] ( set __ConfigureOnly=1&&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)
Expand All @@ -63,7 +62,7 @@ set __binDir=%__rootDir%\artifacts\bin
set __objDir=%__rootDir%\artifacts\obj

:: Setup to cmake the native components
echo Commencing build of corehost
echo Configuring corehost native components
echo.

if %__CMakeBinDir% == "" (
Expand Down Expand Up @@ -109,7 +108,12 @@ call "%__engNativeDir%\gen-buildsys.cmd" "%__sourceDir%" "%__IntermediatesDir%"
if NOT [%errorlevel%] == [0] goto :Failure
popd

if [%__ConfigureOnly%] == [1] goto :Exit

:BuildNativeProj

echo Commencing build of corehost native components

:: Build the project created by Cmake
set __generatorArgs=
if [%__Ninja%] == [1] (
Expand Down Expand Up @@ -145,6 +149,8 @@ if "%__RuntimeFlavor%" NEQ "Mono" (
)

echo Done building Native components

:Exit
exit /B 0

:Failure
Expand Down
2 changes: 2 additions & 0 deletions src/native/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

<BuildArgs>$(Configuration) $(TargetArchitecture) -apphostver "$(AppHostVersion)" -hostver "$(HostVersion)" -fxrver "$(HostResolverVersion)" -policyver "$(HostPolicyVersion)" -commithash "$([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A'))" -os $(TargetOS)</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DVERSION_FILE_PATH=$(NativeVersionFile)"</BuildArgs>
<BuildArgs Condition="'$(ConfigureOnly)' == 'true'">$(BuildArgs) -configureonly</BuildArgs>
<BuildArgs Condition="'$(PortableBuild)' != 'true'">$(BuildArgs) -portablebuild=false</BuildArgs>
<BuildArgs Condition="'$(KeepNativeSymbols)' != 'false'">$(BuildArgs) -keepnativesymbols</BuildArgs>
<BuildArgs Condition="'$(CrossBuild)' == 'true'">$(BuildArgs) -cross</BuildArgs>
Expand Down Expand Up @@ -84,6 +85,7 @@
<BuildScript>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'build.cmd'))</BuildScript>

<BuildArgs>$(Configuration) $(TargetArchitecture) apphostver $(AppHostVersion) hostver $(HostVersion) fxrver $(HostResolverVersion) policyver $(HostPolicyVersion) commit $([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A')) rid $(OutputRid)</BuildArgs>
<BuildArgs Condition="'$(ConfigureOnly)' == 'true'">$(BuildArgs) configureonly</BuildArgs>
<BuildArgs Condition="'$(PortableBuild)' == 'true'">$(BuildArgs) portable</BuildArgs>
<BuildArgs Condition="'$(IncrementalNativeBuild)' == 'true'">$(BuildArgs) incremental-native-build</BuildArgs>
<BuildArgs>$(BuildArgs) rootdir $(RepoRoot)</BuildArgs>
Expand Down

0 comments on commit 760a76b

Please sign in to comment.