Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added checks for main dependencies on runtime's build scripts #39052

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ function Get-Help() {
Write-Host "For more information, check out https://github.com/dotnet/runtime/blob/master/docs/workflow/README.md"
}

function Assert-InstalledDependency($dependencyName)
{
$envPath = $Env:Path
ericstj marked this conversation as resolved.
Show resolved Hide resolved
if (-Not $envPath -Match $dependencyName)
{
Write-Host "$dependencyName is required to build this repo. Make sure to install it and try again."
Write-Host "For a full list of requirements, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md"
exit 1
}
}

function Assert-GitLongPathsEnabled()
{
# This needs to be in a variable. Otherwise, Invoke-Command complains about
# an incompatible cast.
$gitscript = [scriptblock]::Create("git config --get core.longpaths")
$longpaths = Invoke-Command -scriptblock $gitscript

if (-Not $longpaths) {
Write-Host "Git Long Paths must be enabled to build this repo."
Write-Host "For a full list of requirements, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md"
exit 1
}
}

if ($help -or (($null -ne $properties) -and ($properties.Contains('/help') -or $properties.Contains('/?')))) {
Get-Help
exit 0
Expand All @@ -110,6 +135,11 @@ if ($subset -eq 'help') {
exit 0
}

Assert-InstalledDependency("CMake")
Assert-InstalledDependency("Git")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git isn't a dependency. The repo should be buildable without any source control provider. #47298 tracks protecting this scenario in CI.

Assert-GitLongPathsEnabled
exit 0

if ($vs) {
. $PSScriptRoot\common\tools.ps1

Expand Down
14 changes: 14 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ showSubsetHelp()
"$scriptroot/common/build.sh" "-restore" "-build" "/p:Subset=help" "/clp:nosummary"
}

assertInstalledDependency()
{
dependency="$(echo "$1" | awk '{print tolower($0)}')"

if ! which $dependency > /dev/null; then
echo "$dependency is required to build this repo. Make sure to install it and try again."
echo "For a full list of requirements, see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/linux-requirements.md"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message refers to linux-requirements.md, but the current OS can be OSX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I will add a check and point to OSX when it's such case.

exit 1
fi
}

assertInstalledDependency 'git'
assertInstalledDependency 'cmake'

arguments=''
cmakeargs=''
extraargs=''
Expand Down