mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1495394
- add mach install-moz-phab
command; r=firefox-build-system-reviewers,chmanchester
Install moz-phab using the correct command for the current operating system as per moz-phab's documentation. Differential Revision: https://phabricator.services.mozilla.com/D59139 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
52a6fe2427
commit
095ba09dda
@ -74,6 +74,7 @@ MACH_MODULES = [
|
||||
'tools/lint/mach_commands.py',
|
||||
'tools/mach_commands.py',
|
||||
'tools/moztreedocs/mach_commands.py',
|
||||
'tools/phabricator/mach_commands.py',
|
||||
'tools/power/mach_commands.py',
|
||||
'tools/tryselect/mach_commands.py',
|
||||
'tools/vcs/mach_commands.py',
|
||||
|
@ -206,6 +206,14 @@ like to opt out of data collection, select (N) at the prompt.
|
||||
Would you like to enable build system telemetry?'''
|
||||
|
||||
|
||||
MOZ_PHAB_ADVERTISE = '''
|
||||
If you plan on submitting changes to Firefox use the following command to
|
||||
install the review submission tool "moz-phab":
|
||||
|
||||
mach install-moz-phab
|
||||
'''
|
||||
|
||||
|
||||
def update_or_create_build_telemetry_config(path):
|
||||
"""Write a mach config file enabling build telemetry to `path`. If the file does not exist,
|
||||
create it. If it exists, add the new setting to the existing data.
|
||||
@ -526,6 +534,9 @@ class Bootstrapper(object):
|
||||
>= MODERN_RUST_VERSION):
|
||||
print("To build %s, please restart the shell (Start a new terminal window)" % name)
|
||||
|
||||
if not self.instance.which("moz-phab"):
|
||||
print(MOZ_PHAB_ADVERTISE)
|
||||
|
||||
# Like 'suggest_browser_mozconfig' or 'suggest_mobile_android_mozconfig'.
|
||||
getattr(self.instance, 'suggest_%s_mozconfig' % application)()
|
||||
|
||||
|
71
tools/phabricator/mach_commands.py
Normal file
71
tools/phabricator/mach_commands.py
Normal file
@ -0,0 +1,71 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, # You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from mach.decorators import CommandProvider, Command, CommandArgument
|
||||
from mozbuild.base import MachCommandBase
|
||||
|
||||
|
||||
@CommandProvider
|
||||
class PhabricatorCommandProvider(MachCommandBase):
|
||||
@Command(
|
||||
"install-moz-phab",
|
||||
category="misc",
|
||||
description="Install patch submission tool.",
|
||||
)
|
||||
@CommandArgument(
|
||||
"--force",
|
||||
"-f",
|
||||
action="store_true",
|
||||
help="Force installation even if already installed.",
|
||||
)
|
||||
def install_moz_phab(self, force=False):
|
||||
import logging
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
existing = shutil.which("moz-phab")
|
||||
if existing and not force:
|
||||
self.log(
|
||||
logging.ERROR,
|
||||
"already_installed",
|
||||
{},
|
||||
"moz-phab is already installed in %s." % existing,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
command = ["pip3", "install", "--upgrade", "MozPhab"]
|
||||
|
||||
if (
|
||||
sys.platform.startswith("linux")
|
||||
or sys.platform.startswith("openbsd")
|
||||
or sys.platform.startswith("dragonfly")
|
||||
or sys.platform.startswith("freebsd")
|
||||
):
|
||||
# On all Linux and BSD distros we default to a user installation.
|
||||
command.append("--user")
|
||||
|
||||
elif sys.platform.startswith("darwin"):
|
||||
# On MacOS we require brew or ports, which work better without --user.
|
||||
pass
|
||||
|
||||
elif sys.platform.startswith("win32") or sys.platform.startswith("msys"):
|
||||
# Likewise for Windows we assume a system level install is preferred.
|
||||
pass
|
||||
|
||||
else:
|
||||
# Unsupported, default to --user.
|
||||
self.log(
|
||||
logging.WARNING,
|
||||
"unsupported_platform",
|
||||
{},
|
||||
"Unsupported platform (%s), assuming per-user installation."
|
||||
% sys.platform,
|
||||
)
|
||||
command.append("--user")
|
||||
|
||||
self.log(logging.INFO, "run", {}, "Installing moz-phab")
|
||||
subprocess.run(command)
|
Loading…
Reference in New Issue
Block a user