tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit ff35a035f6521642db602b984e7bc51e46f8226a
parent e7948ea257d143e4f44771d0d2a59b07df9931b1
Author: serge-sans-paille <sguelton@mozilla.com>
Date:   Mon, 24 Nov 2025 10:37:58 +0000

Bug 2001601 - Avoid redundant loading of buildconfig in mozbuild/backend/mach_commands.py r=ahochheiden

Do not recompute topsrcdir when it's already available in command context.

This saves ~10ms on my setup for every mach command :-)

Differential Revision: https://phabricator.services.mozilla.com/D273560

Diffstat:
Mpython/mozbuild/mozbuild/backend/mach_commands.py | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/python/mozbuild/mozbuild/backend/mach_commands.py b/python/mozbuild/mozbuild/backend/mach_commands.py @@ -9,7 +9,6 @@ import subprocess import sys import mozpack.path as mozpath -from buildconfig import topsrcdir from mach.decorators import Command, CommandArgument from mozfile import which @@ -49,7 +48,9 @@ def run(command_context, ide, no_interactive, args): return 1 if ide == "vscode": - result = subprocess.run([sys.executable, "mach", "configure"], cwd=topsrcdir) + result = subprocess.run( + [sys.executable, "mach", "configure"], cwd=command_context.topsrcdir + ) if result.returncode: return result.returncode @@ -58,7 +59,7 @@ def run(command_context, ide, no_interactive, args): # export target, because we can't do anything better. result = subprocess.run( [sys.executable, "mach", "build", "pre-export", "export", "pre-compile"], - cwd=topsrcdir, + cwd=command_context.topsrcdir, ) if result.returncode: return result.returncode @@ -66,7 +67,9 @@ def run(command_context, ide, no_interactive, args): # Here we refresh the whole build. 'build export' is sufficient here and is # probably more correct but it's also nice having a single target to get a fully # built and indexed project (gives a easy target to use before go out to lunch). - result = subprocess.run([sys.executable, "mach", "build"], cwd=topsrcdir) + result = subprocess.run( + [sys.executable, "mach", "build"], cwd=command_context.topsrcdir + ) if result.returncode: return result.returncode @@ -82,7 +85,8 @@ def run(command_context, ide, no_interactive, args): if backend: # Generate or refresh the IDE backend. result = subprocess.run( - [sys.executable, "mach", "build-backend", "-b", backend], cwd=topsrcdir + [sys.executable, "mach", "build-backend", "-b", backend], + cwd=command_context.topsrcdir, ) if result.returncode: return result.returncode