From b556e28496209611c6ee7fef6f6ac6109af5c199 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:06 -0500 Subject: [PATCH 1/4] outline x.py alternate invocations to the dev guide almost no one on windows builds from source unless they're contributing, and `./x.py` just works on most unix systems. --- README.md | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 41b135972af11..901213d2ca977 100644 --- a/README.md +++ b/README.md @@ -33,24 +33,13 @@ format: ``` This is how the documentation and examples assume you are running `x.py`. -Some alternative ways are: - -```sh -# On a Unix shell if you don't have the necessary `python3` command -./x [flags] - -# On the Windows Command Prompt (if .py files are configured to run Python) -x.py [flags] - -# You can also run Python yourself, e.g.: -python x.py [flags] -``` +See the [rustc dev guide][rustcguidebuild] if this does not work on your platform. More information about `x.py` can be found by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html -[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html +[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#what-is-xpy ### Dependencies From dd314f6533c94125d08220b1ba188c6cf68226c7 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 11:17:59 -0500 Subject: [PATCH 2/4] give more helpful suggestions for a missing feature gate test --- src/tools/tidy/src/features.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index 2fd4c797b43f1..7ad8f5c5c05f8 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -160,10 +160,10 @@ pub fn check( for &(name, _) in gate_untested.iter() { println!("Expected a gate test for the feature '{name}'."); println!( - "Hint: create a failing test file named 'feature-gate-{}.rs'\ - \n in the 'ui' test suite, with its failures due to\ - \n missing usage of `#![feature({})]`.", - name, name + "Hint: create a failing test file named 'tests/ui/feature-gates/feature-gate-{}.rs',\ + \n with its failures due to missing usage of `#![feature({})]`.", + name.replace("_", "-"), + name ); println!( "Hint: If you already have such a test and don't want to rename it,\ From fa7e965bf0af41ddd5865ee63782d3536263f964 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:09:48 -0500 Subject: [PATCH 3/4] Give a better error on Windows if python isn't installed Before: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 PS C:\Users\vboxuser\rust> ``` After: ``` PS C:\Users\vboxuser\rust> ./x x.ps1 C:\Users\vboxuser\rust\x.ps1 : C:\Users\vboxuser\rust\x.ps1: error: did not find python installed help: consider installing it from https://www.python.org/downloads/windows/ At line:1 char:1 + ./x + ~~~ + CategoryInfo : NotInstalled: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,x.ps1 ``` The existing message from the shell script is already decent and I decided not to change it: ``` $ ./x Python was not found but can be installed from the Microsoft Store: ms-windows-store://pdp/?productid=9NJ46SX7X90P ``` --- x.ps1 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/x.ps1 b/x.ps1 index a156017628db8..b036653e5b442 100755 --- a/x.ps1 +++ b/x.ps1 @@ -16,7 +16,13 @@ foreach ($arg in $args) { } function Get-Application($app) { - return Get-Command $app -ErrorAction SilentlyContinue -CommandType Application + $cmd = Get-Command $app -ErrorAction SilentlyContinue -CommandType Application | Select-Object -First 1 + if ($cmd.source -match '.*AppData\\Local\\Microsoft\\WindowsApps\\.*exe') { + # Windows for some reason puts a `python3.exe` executable in PATH that just opens the windows store. + # Ignore it. + return $false + } + return $cmd } function Invoke-Application($application, $arguments) { @@ -51,5 +57,7 @@ if (($null -ne $found) -and ($found.Length -ge 1)) { Invoke-Application $python $xpy_args } -Write-Error "${PSCommandPath}: error: did not find python installed" +$msg = "${PSCommandPath}: error: did not find python installed`n" +$msg += "help: consider installing it from https://www.python.org/downloads/" +Write-Error $msg -Category NotInstalled Exit 1 From 664ffa419eb4793d2c6e161d6f098b0104550ca2 Mon Sep 17 00:00:00 2001 From: jyn Date: Sat, 24 Jun 2023 13:16:39 -0500 Subject: [PATCH 4/4] Don't print "x.ps1" This is left over from adding `Get-Command -syntax`; it's not helpful. --- x.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x.ps1 b/x.ps1 index b036653e5b442..55f99901645cd 100755 --- a/x.ps1 +++ b/x.ps1 @@ -5,7 +5,7 @@ $ErrorActionPreference = "Stop" # syntax check -Get-Command -syntax ${PSCommandPath} +Get-Command -syntax ${PSCommandPath} >$null $xpy = Join-Path $PSScriptRoot x.py # Start-Process for some reason splits arguments on spaces. (Isn't powershell supposed to be simpler than bash?)