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 5 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
6 changes: 6 additions & 0 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
@echo off
setlocal

:: Call setup_vs_tools with the '1' flag to tell it to only check for the
:: VS installation, and not launch the Dev Prompt. More details are in that
:: script source file.

call "%~dp0src\coreclr\setup_vs_tools.cmd" 1
Copy link
Member

Choose a reason for hiding this comment

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

That doesn't seem right. We don't want to call into a coreclr script from the repo root. Can you extract that and move it into eng/?

Copy link
Member

Choose a reason for hiding this comment

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

Also, isn't there an Arcade script that already does that?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did this in order to avoid code duplication, but now that you bring it up, it is probably better practice to keep root script functionality outside of any subsets of the repo. I can extract the checking functionality into a new script in eng. As far as I'm concerned, we do need to add this dependency check.

Copy link
Member

Choose a reason for hiding this comment

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

yes please do so.

Copy link
Member

Choose a reason for hiding this comment

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

and please check if Arcade already offers something useful to check dependencies. And if not, we might want to add it to Arcade.

Copy link
Member

Choose a reason for hiding this comment

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

We have #1251 opened on unifying this.

Arcade has https://github.com/dotnet/runtime/blob/master/eng/common/tools.ps1 that you probably had in mind. It is pretty far from what we need here.


set _args=%*
if "%~1"=="-?" set _args=-help

Expand Down
14 changes: 14 additions & 0 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ 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)
{
try {
Get-Command -Name $dependencyName -ErrorAction Stop >$null 2>&1
}
catch {
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
}
}

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

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.


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

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

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

if [ -z "$location" ]; 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
Member 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 'CMake'
assertInstalledDependency 'Git'
Copy link
Member

@ViktorHofer ViktorHofer Sep 30, 2020

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. Sourcebuild needs to work without git.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it is. The build uses it to extract it the commit hash that we embed into the binaries.

Copy link
Member

Choose a reason for hiding this comment

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

Is it done unconditionally, or can this behavior be suppressed by configuration? I believe that there are configuration options to suppress this behavior.

Copy link
Member

Choose a reason for hiding this comment

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

You are right, I've tried to uninstall git and the build completed ok, just no version info got embedded into the binaries.

Copy link
Member Author

Choose a reason for hiding this comment

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

So we just check for CMake then?

Copy link
Member

Choose a reason for hiding this comment

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

yes


arguments=''
cmakeargs=''
extraargs=''
Expand Down
19 changes: 19 additions & 0 deletions src/coreclr/setup_vs_tools.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ REM vs2017 or vs2019
:: Visual Studio available on the machine. Finally, we will fail the script if not supported
:: instance can be found.

:: This script is also called by the main build.cmd, located at the root of the
:: runtime repo. For this specific scenario, we want to check if there is a
:: valid VS installation, but not call the Developer Command Prompt. For this
:: purpose, we pass a flag labelled as the number '1' from said script and store
:: it in this variable "__VSOnlyCheck". This is then checked at the end to define
:: whether or not to call the VS Dev Prompt.
::
:: The original CoreCLR callers within this directory remain untouched. In this
:: case, they don't pass any flags and so since "__VSOnlyCheck" will be undefined
:: in those cases, execution will proceed as normally.

set __VSOnlyCheck=%1

if defined VisualStudioVersion (
if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
goto skip_setup
Expand All @@ -34,6 +47,12 @@ if not exist "%_VSCOMNTOOLS%" (
echo Please see https://github.com/dotnet/runtime/blob/master/docs/workflow/requirements/windows-requirements.md for build instructions.
exit /b 1
)

:: If called from runtime's build.cmd, we are done here and thus we proceed
:: to the exit.

if "%__VSOnlyCheck%" == "1" goto :skip_setup

echo %__MsgPrefix%"%_VSCOMNTOOLS%\VsDevCmd.bat"
call "%_VSCOMNTOOLS%\VsDevCmd.bat"

Expand Down