Skip to content

Commit

Permalink
Windows build.cmd doesn't support -cmakeargs. (dotnet#46195)
Browse files Browse the repository at this point in the history
build.sh supports -cmakeargs making it is possible to pass custom
cmake arguments down to native cmake steps, but this feature is missing
on Windows when using build.cmd. Trying to do:

.\build.cmd -subset clr -c release -cmakeargs "-DFEATURE_PERFTRACING_C_LIB=1"

on Windows will result in an error since -cmakeargs is not a known command
in build.ps1.

Commit adds support for -cmakeargs in build.cmd making sure it gets
passed down to runtime build on both CoreClr as well as Mono.
  • Loading branch information
lateralusX authored Jan 22, 2021
1 parent 2e42668 commit 51bf70e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Param(
[ValidateSet("Debug","Release")][string][Alias('lc')]$librariesConfiguration,
[ValidateSet("CoreCLR","Mono")][string][Alias('rf')]$runtimeFlavor,
[switch]$ninja,
[string]$cmakeargs,
[Parameter(ValueFromRemainingArguments=$true)][String[]]$properties
)

Expand Down Expand Up @@ -76,6 +77,7 @@ function Get-Help() {
Write-Host ""

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 "Command-line arguments not listed above are passed through to MSBuild."
Expand Down Expand Up @@ -229,6 +231,7 @@ foreach ($argument in $PSBoundParameters.Keys)
"allconfigurations" { $arguments += " /p:BuildAllConfigurations=true" }
"properties" { $arguments += " " + $properties }
"verbosity" { $arguments += " -$argument " + $($PSBoundParameters[$argument]) }
"cmakeargs" { $arguments += " /p:CMakeArgs=`"$($PSBoundParameters[$argument])`"" }
"ninja" { $arguments += " /p:Ninja=$($PSBoundParameters[$argument])" }
# configuration and arch can be specified multiple times, so they should be no-ops here
"configuration" {}
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
AfterTargets="Build">
<ItemGroup>
<_CoreClrBuildArg Condition="'$(TargetArchitecture)' != ''" Include="-$(TargetArchitecture)" />
<_CoreClrBuildArg Include="$(CMakeArgs)" />
<_CoreClrBuildArg Condition="!$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="$(CMakeArgs)" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and '$(CMakeArgs)' != ''" Include="-cmakeargs &quot;$(CMakeArgs)&quot;" />
<_CoreClrBuildArg Include="-$(Configuration.ToLower())" />
<_CoreClrBuildArg Include="$(Compiler)" />
<_CoreClrBuildArg Condition="'$(ContinuousIntegrationBuild)' == 'true'" Include="-ci" />
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_PREFIX=$(MonoObjDir)out"/>
<_MonoCMakeArgs Include="-DCMAKE_INSTALL_LIBDIR=lib"/>
<_MonoCMakeArgs Include="-DCMAKE_BUILD_TYPE=$(Configuration)"/>
<_MonoCMakeArgs Condition="'$(CMakeArgs)' != ''" Include="$(CMakeArgs)"/>
<_MonoCMakeArgs Condition="'$(MonoEnableLLVM)' == 'true'" Include="-DLLVM_PREFIX=$(MonoLLVMDir)" />
<_MonoCMakeArgs Include="-DGC_SUSPEND=$(MonoThreadSuspend)" />
</ItemGroup>
Expand Down

0 comments on commit 51bf70e

Please sign in to comment.