-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Make build scripts' -help information more helpful #37377
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
Conversation
Tagging subscribers to this area: @ViktorHofer |
Can you please paste in the new output so we can see what it looks like? |
else | ||
passedSubset="$(echo "$2" | awk '{print tolower($0)}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have detection on the first argument to parse it as a subset: https://github.com/dotnet/runtime/pull/37377/files#diff-75d32cbca8eddea951ce0484aa996d8fR130
So we also need to consider the case where people passes down:
.\build.sh help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested it. It works and shows the new subset message, but it shows the metrics. Let me add a handler for that case as well.
Sure, here are the outputs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big improvement; thanks.
Thank you for adding examples. We have gotten a lot of feedback that it's too hard to figure out how to build. I often have to go back to the docs and I'm just copy/pasting examples from there. Whenever a command line tool has this many parameters and concepts, examples are super valuable. Are there any other common use cases it's worth adding examples for? I think it's fine to have more. |
eng/build.sh
Outdated
echo "Build CoreCLR on Linux for x64 on release configuration:" | ||
echo "./build.sh clr --os linux --arch x64 --configuration release" | ||
echo "" | ||
echo "Build Debug libraries with a Release runtime." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo "Build Debug libraries with a Release runtime." | |
echo "Build Debug libraries for Linux with a Release runtime." |
echo "" | ||
echo "Build Debug libraries with a Release runtime." | ||
echo "./build.sh --subset clr+libs --os linux --arch x64 --runtimeConfiguration release" | ||
echo "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding build -subset clr+libs -runtimeConfiguration Release
(it's what we suggest for library work in docs\workflow\building\libraries\README.md)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And note that that one picks the same target platform you are building on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW the shortest form (that most of us use) is build clr+libs -rc Release
.
eng/build.sh
Outdated
echo " --clang Optional argument to build using clang in PATH (default)" | ||
echo " --clangx.y Optional argument to build using clang version x.y" | ||
echo " --clang Optional argument to build using clang in PATH (default)." | ||
echo " --clangx.y Optional argument to build using clang version x.y." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an example, eg., (e.g., --clang11.0)
(is that right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for gcc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--clang11.0
would not be a good example, clang versions from 7 on use only major version numbers. So we could put in e.g. --clang9
Which actually reveals that the help is slightly incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivdiazsa I think this is still wrong? sounds like it should be --clangx
?
eng/build.sh
Outdated
echo "Cross-compile CoreCLR runtime on Linux for ARM64." | ||
echo "./build.sh -subset clr.runtime --os linux --arch arm64 --configuration release --cross" | ||
echo "" | ||
echo "However, for this last example, you need to already have ROOTFS_DIR set up." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more examples (5? ) would be great -- eg., a mono one.
eng/build.ps1
Outdated
$argumentsForHelp = "-restore -build /p:subset=help /clp:nosummary" | ||
Invoke-Expression "& `"$PSScriptRoot/common/build.ps1`" $argumentsForHelp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: inline $argumentsForHelp into the Invoke-Expression statement.
eng/build.sh
Outdated
argumentsForHelp="-restore -build /p:subset=help /clp:nosummary" | ||
"$scriptroot/common/build.sh" $argumentsForHelp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about inlining.
eng/build.ps1
Outdated
Write-Host " Pass a comma-separated list to build for multiple architectures." | ||
Write-Host " [Default: Your machine's architecture.]" | ||
Write-Host " -binaryLog (-bl) Output binary log." | ||
Write-Host " -configuration (-c) Build configuration: Debug, Release or [CoreCLR]Checked." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't casing matter (at least on Unix)? @safern should it be consistently lower case or upper? We should note that in the help, and fix the help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The casing doesn't matter as we are upper-casing passed-in configurations in the scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. In a previous PR I made (35642) it no longer matters if you pass --os LINUX
or --os linux
. It gets handled internally and converted to the casing MSBuild expects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistently using lower case in examples seems better but I can't put my finger on why so it's probably just me :)
eng/build.ps1
Outdated
Write-Host ".\build.cmd -subset clr.runtime -os Windows_NT -arch arm64 -configuration Release" | ||
Write-Host "" | ||
Write-Host "Build Debug libraries with a Release runtime." | ||
Write-Host ".\build.cmd -subset clr+libs -os Windows_NT -arch x64 -runtimeConfiguration Release" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super verbose and I don't know anyone specifying the defaults for OS and Arch.
Write-Host ".\build.cmd -subset clr+libs -os Windows_NT -arch x64 -runtimeConfiguration Release" | |
Write-Host ".\build.cmd clr+libs -rc Release" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I never specify -os or -arch explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I do specify arch sometime when I want to do a cross build, but it is very rare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I often specify arch when building on Windows x64 to build arm/arm64/x86.
One thing that is very confusing to me is: when do I need to specify -cross
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what the docs say and my past experiences, --cross
is a flag specified when you are doing a cross-build, like building for ARM64 on x64. Worth mentioning it's only necessary on Unix (i.e. build.sh
)
eng/build.ps1
Outdated
Write-Host " [Default: Builds the entire repo.]" | ||
Write-Host " -verbosity (-v) MSBuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]." | ||
Write-Host " [Default: Minimal]" | ||
Write-Host " -vs Open the solution with VS using the locally acquired SDK. Path or solution name." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Host " -vs Open the solution with VS using the locally acquired SDK. Path or solution name." | |
Write-Host " -vs Open the solution with Visual Studio using the locally acquired SDK. Path or solution name." |
Does this work with .csproj or only .sln @ViktorHofer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use it to open anything that works inside VS :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then we should say solution or project file.
Write-Host " -allconfigurations Build packages for all build configurations" | ||
Write-Host " -allconfigurations Build packages for all build configurations." | ||
Write-Host " -coverage Collect code coverage when testing." | ||
Write-Host " -framework (-f) Build framework: net5.0 or net472." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Host " -framework (-f) Build framework: net5.0 or net472." | |
Write-Host " -framework (-f) Target framework: net5.0 or net472. Defaults to net5.0." |
Write-Host " -sign Sign build outputs" | ||
Write-Host " -publish Publish artifacts (e.g. symbols)" | ||
Write-Host " -clean Clean the solution" | ||
Write-Host " -build (-b) Build all source projects." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Host " -build (-b) Build all source projects." | |
Write-Host " -build (-b) Build all source projects. (Assumes you already ran -restore)" |
I made this mistake in the past
Write-Host " -build (-b) Build all source projects." | ||
Write-Host " -clean Clean the solution." | ||
Write-Host " -pack Package build outputs into NuGet packages." | ||
Write-Host " -publish Publish artifacts (e.g. symbols)." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write-Host " -publish Publish artifacts (e.g. symbols)." | |
Write-Host " -publish Publish artifacts (e.g. symbols - assumes you already ran -build)." |
eng/build.ps1
Outdated
Write-Host " -rebuild Rebuild all source projects." | ||
Write-Host " -restore Restore dependencies." | ||
Write-Host " -sign Sign build outputs." | ||
Write-Host " -test (-t) Build and run tests." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this actually build tests, or just run?
Also, does it build the library under test, or just the test library?
good to note this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's an interesting observation and something worth including. I believe it just builds the test library, but I've not used it much so I'm not sure. Can you clarify this @janvorli?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the target test just runs the tests. In order to build you need to do -build
and passing the right subset that includes tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The -test
switch incrementally restores and builds the test projects. You can specify -test -testnobuild
to only run the tests.
Lines 108 to 113 in 6176924
# Check if an action is passed in | |
$actions = "b","build","r","restore","rebuild","sign","testnobuild","publish","clean" | |
$actionPassedIn = @(Compare-Object -ReferenceObject @($PSBoundParameters.Keys) -DifferenceObject $actions -ExcludeDifferent -IncludeEqual).Length -ne 0 | |
if ($null -ne $properties -and $actionPassedIn -ne $true) { | |
$actionPassedIn = @(Compare-Object -ReferenceObject $properties -DifferenceObject $actions.ForEach({ "-" + $_ }) -ExcludeDifferent -IncludeEqual).Length -ne 0 | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarifying!
Thanks for doing this, one thing already clear from the community survey is that build is intimidating, and good help text has to help. |
One thing that it would be useful to describe in more detail, although in the documentation on GitHub and not in this help message, is the difference between |
I agree with this. It is not clear what are the implications of using each one, and under which scenarios somebody would use one or the other. I would gladly make this change but I'd need some guidance on how these flags work :) |
As @BruceForstall described, passing in a configuration via So specifying |
Thank you very much to everyone for the feedback on this! Now I have a clearer picture on the most common use cases for these build scripts, and how they work. I will recap the proposed changes in the following list, and please let me know if I missed something. Changes to be done:
|
It would be great to see the updated output before we merge. |
so do all of the following do the same thing?
|
Correct. |
Here are the new updated versions of the help messages (updated with Bruce's latest observations):
|
eng/build.ps1
Outdated
Write-Host " [Default: Your machine's architecture.]" | ||
Write-Host " -binaryLog (-bl) Output binary log." | ||
Write-Host " -configuration (-c) Build configuration: Debug, Release or Checked." | ||
Write-Host " Checked is exclusive to the CLR subset. Use it for optimized code with asserts and" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect: Checked
flavor also sets the DEBUG
macro. The only difference between Debug
and Checked
flavors is that the Checked
flavor is compiled with compiler and linker optimizations, so it runs faster. I would write (here and elsewhere):
Checked is exclusive to the CLR subset. It is the same as Debug, but is compiled with optimizations enabled so runs faster.
The downside of being compiled with optimizations is it is sometimes harder to debug. But we don't need to write a novel here :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. I had misunderstood how the DEBUG macro is enabled. Thanks for the clarification!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it. I also updated the previous comment with the latest output.
@stephentoub any other feedback on the output? |
showSubsetHelp | ||
exit 0 | ||
fi | ||
|
||
arguments="$arguments /p:Subset=$1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you're touching this, should /p:Subset=$1
be /p:Subset=$opt
? don't know if that'll make a difference, but it is weird to check if $opt matches the regex, if opt is == help and then use $1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right and using $opt
would make the code look cleaner. Just before making this change, the arguments for MSBuild are not case-sensitive right? In the sense that /p:Subset=CLR
would work just fine like /p:Subset=clr
? Just making sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it is case sensitive in Unix, but we lowercase the subsets before processing them:
Line 46 in 8f1c72d
<_subset Condition="'$(Subset)' != ''">+$(Subset.ToLowerInvariant())+</_subset> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except for --clangx.y
seems like it should be --clangx
Thanks for improving this!
Perhaps more clearly, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this up!
It depends on the clang version. Versions <= 6.0 use the x.y versioning schema, versions >=7 use just single number. LLVM has changed the versioning this way. |
For the sake of keeping "good historical track", I believe we should leave both in this case. I'll correct |
don't know |
Yes, gcc version is always x.y |
Fixes #33167.
This PR slightly changes the layout and information shown when asking for help to runtime's build scripts. The following changes were made:
-subset help
. This is to optimize and avoid passing unnecessary data as this command does not want to trigger any build. Also, it adds a specific flag to prevent MSBuild from showing build metrics in this case.These changes were applied to both,
build.cmd
andbuild.sh
.In addition to these changes, the "error" message shown when requesting
-subset help
was reworded to reassure the user it is not an error as such. The reason this mechanism is kept, is that since subset information is printed directly by MSBuild, there needs to be a way to stop it right after showing the subsets' descriptions. If we remove this, then restore finishes doing its thing and the descriptions are printed thrice. We don't want to spam the user either. If-restore
is removed from the MSBuild command, it fails unless the build script has invoked restore in the past. This would cause an unknown error to appear when working with a clean repository, which is fairly often.