commit bfe8ed97fbf1f1ef63138fcda9e83c145c5603f3
parent 2ff3b56a028b2ea53fe041e24279b0a5d8dfa8a1
Author: Tom Ritter <tom@mozilla.com>
Date: Tue, 30 Sep 2025 12:35:27 +0000
Bug 1990514: Support Nightly ifdefs in RFPTargetDefaults.inc r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D266011
Diffstat:
3 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/toolkit/components/resistfingerprinting/RFPTargetsDefault.inc b/toolkit/components/resistfingerprinting/RFPTargetsDefault.inc
@@ -3,6 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+// #ifdef NIGHTLY_BUILD is supported as a preprocessor macro.
+// If any others are needed, update extract_rfp_targets.py
+
DESKTOP_DEFAULT(CanvasRandomization)
DESKTOP_DEFAULT(FontVisibilityLangPack)
DESKTOP_DEFAULT(JSMathFdlibm)
diff --git a/toolkit/components/resistfingerprinting/RFPTargetsDefaultBaseline.inc b/toolkit/components/resistfingerprinting/RFPTargetsDefaultBaseline.inc
@@ -3,4 +3,5 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
-// So far, just a placeholder file.
-\ No newline at end of file
+// #ifdef NIGHTLY_BUILD is supported as a preprocessor macro.
+// If any others are needed, update extract_rfp_targets.py
+\ No newline at end of file
diff --git a/toolkit/components/resistfingerprinting/extract_rfp_targets.py b/toolkit/components/resistfingerprinting/extract_rfp_targets.py
@@ -1,19 +1,37 @@
import re
from collections import defaultdict
+import buildconfig
-def parse_defaults(path):
+
+def parse_defaults(path, is_nightly: bool):
pattern = re.compile(r"(DESKTOP_DEFAULT|ANDROID_DEFAULT)\((.+)\)")
- contents = ""
with open(path) as f:
contents = f.read()
- defaults = defaultdict(lambda: [])
- for match in pattern.finditer(contents):
- platform = match.group(1)
- target = match.group(2)
- defaults[platform].append(target)
+ defaults = defaultdict(list)
+
+ inside_nightly = False
+ for line in contents.splitlines():
+ line = line.strip()
+
+ if line.startswith("#ifdef NIGHTLY_BUILD"):
+ inside_nightly = True
+ continue
+ if line.startswith("#endif"):
+ inside_nightly = False
+ continue
+
+ # Skip lines inside NIGHTLY_BUILD block if not nightly
+ if inside_nightly and not is_nightly:
+ continue
+
+ match = pattern.search(line)
+ if match:
+ platform = match.group(1)
+ target = match.group(2)
+ defaults[platform].append(target)
return defaults
@@ -63,13 +81,24 @@ def write_targets(output, targets):
def main(output, targets_path, defaults_base_path, defaults_fpp_path):
+ is_nightly = buildconfig.substs["MOZ_UPDATE_CHANNEL"] not in (
+ "beta",
+ "release",
+ "esr",
+ )
output.write("// This is a generated file. Please do not edit.\n")
output.write(
f"// See extract_rfp_targets.py, {targets_path}, {defaults_base_path}, {defaults_fpp_path} files instead.\n"
)
+ output.write(
+ "// Update channel is %s, classified as%s nightly\n\n"
+ % (buildconfig.substs["MOZ_UPDATE_CHANNEL"], "" if is_nightly else " not")
+ )
write_targets(output, parse_targets(targets_path))
output.write("\n")
write_defaults(
- output, parse_defaults(defaults_base_path), parse_defaults(defaults_fpp_path)
+ output,
+ parse_defaults(defaults_base_path, is_nightly),
+ parse_defaults(defaults_fpp_path, is_nightly),
)