commit 4685d005316c57c95017eb714923d7f1730a3a0b
parent fed6070bfbe7cb605ab3860797c5c4042d01e9fa
Author: serge-sans-paille <sguelton@mozilla.com>
Date: Tue, 9 Dec 2025 11:36:45 +0000
Bug 988938 - Replace toolkit/components/telemetry/Makefile.in by moz.build (s) r=glandium,toolkit-telemetry-reviewers
The idea is to rely on existing support for XPI packaging, adding a
flavor for test files in the process.
Differential Revision: https://phabricator.services.mozilla.com/D273009
Diffstat:
9 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/config/rules.mk b/config/rules.mk
@@ -901,11 +901,15 @@ $(4):: $$(abspath $(3))/$(1).xpi
endef
+ifdef XPI_TESTDIR
+$(eval $(call xpi_package_rule,$(XPI_PKGNAME),$(srcdir),$(XPI_TESTDIR),misc))
+else
# When you move this out of the tools tier, please remove the corresponding
# hacks in recursivemake.py that check if Makefile.in sets the variable.
ifdef XPI_PKGNAME
$(eval $(call xpi_package_rule,$(XPI_PKGNAME),$(FINAL_TARGET),$(FINAL_TARGET)/..,tools realchrome))
endif
+endif
#############################################################################
# MDDEPDIR is the subdirectory where all the dependency files are placed.
diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -528,6 +528,8 @@ class RecursiveMakeBackend(MakeBackend):
# skipped and must run during the 'tools' tier.
if "XPI_PKGNAME" in obj.variables:
self._no_skip["tools"].add(backend_file.relobjdir)
+ if "XPI_TESTDIR" in obj.variables:
+ self._no_skip["misc"].add(backend_file.relobjdir)
elif isinstance(obj, HostDefines):
self._process_defines(obj, backend_file, which="HOST_DEFINES")
diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py
@@ -2318,6 +2318,14 @@ VARIABLES = {
Override the name of the package generated for an XPI extension.
""",
),
+ "XPI_TESTDIR": (
+ ObjDirPath,
+ str,
+ """The name of the directory where the associated test XPI package must be generated.
+
+ XPI_PKGNAME must be set for this variable to matter.
+ """,
+ ),
"DIST_SUBDIR": (
str,
str,
diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -1249,11 +1249,15 @@ class TreeMetadataEmitter(LoggingMixin):
"USE_EXTENSION_MANIFEST",
"WASM_LIBS",
"XPI_PKGNAME",
+ "XPI_TESTDIR",
]
for v in varlist:
if v in context and context[v]:
passthru.variables[v] = context[v]
+ if "XPI_TESTDIR" in context and "XPI_PKGNAME" not in context:
+ raise SandboxValidationError("XPI_TESTDIR set but XPI_PKGNAME not set")
+
if (
context.config.substs.get("OS_TARGET") == "WINNT"
and context["DELAYLOAD_DLLS"]
diff --git a/toolkit/components/telemetry/Makefile.in b/toolkit/components/telemetry/Makefile.in
@@ -1,11 +0,0 @@
-#
-# 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/.
-
-include $(topsrcdir)/config/rules.mk
-
-# This is so hacky. Waiting on bug 988938.
-addondir = $(srcdir)/tests/addons
-testdir = $(topobjdir)/_tests/xpcshell/toolkit/components/telemetry/tests/unit
-$(foreach dir,$(wildcard $(addondir)/*),$(eval $(call xpi_package_rule,$(notdir $(dir)),$(dir),$(testdir),misc)))
diff --git a/toolkit/components/telemetry/tests/addons/long-fields/moz.build b/toolkit/components/telemetry/tests/addons/long-fields/moz.build
@@ -0,0 +1,8 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+XPI_PKGNAME = "long-fields"
+XPI_TESTDIR = "!/_tests/xpcshell/toolkit/components/telemetry/tests/unit"
diff --git a/toolkit/components/telemetry/tests/addons/restartless/moz.build b/toolkit/components/telemetry/tests/addons/restartless/moz.build
@@ -0,0 +1,8 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+XPI_PKGNAME = "restartless"
+XPI_TESTDIR = "!/_tests/xpcshell/toolkit/components/telemetry/tests/unit"
diff --git a/toolkit/components/telemetry/tests/addons/system/moz.build b/toolkit/components/telemetry/tests/addons/system/moz.build
@@ -0,0 +1,8 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+XPI_PKGNAME = "system"
+XPI_TESTDIR = "!/_tests/xpcshell/toolkit/components/telemetry/tests/unit"
diff --git a/toolkit/components/telemetry/tests/moz.build b/toolkit/components/telemetry/tests/moz.build
@@ -18,6 +18,12 @@ TESTING_JS_MODULES += [
"utils/TelemetryTestUtils.sys.mjs",
]
+TEST_DIRS += [
+ "addons/long-fields",
+ "addons/restartless",
+ "addons/system",
+]
+
if CONFIG["COMPILE_ENVIRONMENT"]:
shared_library = "!%smodules-test%s" % (CONFIG["DLL_PREFIX"], CONFIG["DLL_SUFFIX"])
TEST_HARNESS_FILES.xpcshell.toolkit.components.telemetry.tests.unit += [