commit d466f372d4f66b8ee512c5557e5b70326933e304
parent 81ad911e441af3a7beedc897a820ab4f87b283f1
Author: Dave Townsend <dtownsend@oxymoronical.com>
Date: Thu, 30 Oct 2025 09:32:41 +0000
Bug 1996224: Allow overriding the default application data directory from `mach run`. r=firefox-build-system-reviewers,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D269947
Diffstat:
1 file changed, 22 insertions(+), 4 deletions(-)
diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py
@@ -1694,6 +1694,15 @@ def _get_desktop_run_parser():
help="Do not pass the --profile argument by default.",
)
group.add_argument(
+ "--appdata",
+ "-a",
+ nargs="?",
+ const=True,
+ default=False,
+ help="Overrides the application data storage area defaulting to a "
+ "temporary location in the object directory. Implies --noprofile.",
+ )
+ group.add_argument(
"--disable-e10s",
action="store_true",
help="Run the program with electrolysis disabled.",
@@ -2222,6 +2231,7 @@ def _run_desktop(
app,
background,
noprofile,
+ appdata,
disable_e10s,
enable_crash_reporter,
disable_fission,
@@ -2313,6 +2323,10 @@ def _run_desktop(
):
args.append("-wait-for-browser")
+ tmpdir = os.path.join(command_context.topobjdir, "tmp")
+ if not os.path.exists(tmpdir):
+ os.makedirs(tmpdir)
+
no_profile_option_given = all(
p not in params for p in ["-profile", "--profile", "-P"]
)
@@ -2323,6 +2337,7 @@ def _run_desktop(
no_profile_option_given
and no_backgroundtask_mode_option_given
and not noprofile
+ and not appdata
):
prefs = {
"browser.aboutConfig.showWarning": False,
@@ -2333,10 +2348,6 @@ def _run_desktop(
for pref in prefs:
prefs[pref] = Preferences.cast(prefs[pref])
- tmpdir = os.path.join(command_context.topobjdir, "tmp")
- if not os.path.exists(tmpdir):
- os.makedirs(tmpdir)
-
if temp_profile:
path = tempfile.mkdtemp(dir=tmpdir, prefix="profile-")
else:
@@ -2378,6 +2389,13 @@ def _run_desktop(
"RUST_BACKTRACE": "full",
}
+ if appdata:
+ if appdata is True:
+ appdata = tmpdir
+
+ extra_env["MOZ_APP_DATA"] = os.path.join(appdata, "AppData", "Roaming")
+ extra_env["MOZ_LOCAL_APP_DATA"] = os.path.join(appdata, "Local")
+
if not enable_crash_reporter:
extra_env["MOZ_CRASHREPORTER_DISABLE"] = "1"
else: