fune/mach.ps1
Mitchell Hentges 0492b82b77 Bug 1750874: Support launching Mach with py instead of python r=glandium
When installing from Python.org, the `python` command isn't available by
default (in favour of `py`). Support using `py` instead.

There were issues running `hg` when `python` isn't added to the `PATH`,
so the docs are being updated accordingly.
Of course, it's still worth supporting `py`-instead-of-`python`
workflows for `git` users who won't be impacted by that bug.

Differential Revision: https://phabricator.services.mozilla.com/D136286
2022-01-21 18:22:58 +00:00

42 lines
963 B
PowerShell

$mypath = $MyInvocation.MyCommand.Path
$machpath = $mypath.substring(0, $mypath.length - 4)
if (Get-Command py) {
$python_executable = "py"
} else {
$python_executable = "python"
}
if (-not (test-path env:MACH_PS1_USE_MOZILLABUILD)) {
&$python_executable $machpath $args
exit $lastexitcode
}
if (-not (test-path env:MOZILLABUILD)) {
echo "No MOZILLABUILD environment variable found, terminating."
exit 1
}
$machpath = ($machpath -replace '\\', '/')
if ($machpath.contains(' ')) {
echo @'
The repository path contains whitespace which currently isn't supported in mach.ps1.
Please run MozillaBuild manually for now.
'@
exit 1
}
for ($i = 0; $i -lt $args.length; $i++) {
$arg = $args[$i]
if ($arg.contains(' ')) {
echo @'
The command contains whitespace which currently isn't supported in mach.ps1.
Please run MozillaBuild manually for now.
'@
exit 1
}
}
& "$env:MOZILLABUILD/start-shell.bat" $machpath $args
exit $lastexitcode