mach_commands.py (1215B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import argparse 6 import sys 7 from pathlib import Path 8 9 from mach.decorators import Command, CommandArgument 10 11 12 @Command("xpcshell", category="misc", description="Run the xpcshell binary") 13 @CommandArgument( 14 "args", nargs=argparse.REMAINDER, help="Arguments to provide to xpcshell" 15 ) 16 def xpcshell(command_context, args): 17 dist_bin = Path(command_context.topobjdir, "dist", "bin") 18 browser_dir = dist_bin / "browser" 19 20 if sys.platform == "win32": 21 xpcshell = dist_bin / "xpcshell.exe" 22 else: 23 xpcshell = dist_bin / "xpcshell" 24 25 command = [ 26 str(xpcshell), 27 "-g", 28 str(dist_bin), 29 "-a", 30 str(browser_dir), 31 ] 32 33 # Disable the socket process (see https://bugzilla.mozilla.org/show_bug.cgi?id=1903631). 34 env = { 35 "MOZ_DISABLE_SOCKET_PROCESS": "1", 36 } 37 38 if args: 39 command.extend(args) 40 41 return command_context.run_process( 42 command, 43 pass_thru=True, 44 ensure_exit_code=False, 45 append_env=env, 46 )