From 1d6e68bfdfaf9edacb498cb50f485dfb3bfdfebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 31 Mar 2026 08:32:57 -0700 Subject: [PATCH] Add `--xml` flag to persist xml artifacts for testing purposes (#56238) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56238 Currently, all xml artifacts generated by doxygen are stored in the tmp dir and deleted at the end of the snapshot generation. For debugging reasons, this diff adds `--xml` flag to persist generated artifacts, so that they can be analyzed. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D98289956 fbshipit-source-id: 73eb0185f7112389e589d3e8f8a2004efe325e8d --- scripts/cxx-api/parser/__main__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/cxx-api/parser/__main__.py b/scripts/cxx-api/parser/__main__.py index 7d8635f754c..4d6e724b61b 100644 --- a/scripts/cxx-api/parser/__main__.py +++ b/scripts/cxx-api/parser/__main__.py @@ -14,6 +14,7 @@ Usage: import argparse import concurrent.futures import os +import shutil import subprocess import sys import tempfile @@ -140,6 +141,7 @@ def build_snapshots( verbose: bool, view_filter: str | None = None, is_test: bool = False, + keep_xml: bool = False, ) -> None: if not is_test: configs_to_build = [ @@ -203,6 +205,7 @@ def build_snapshots( failed_views = ", ".join(name for name, _ in errors) raise RuntimeError(f"Failed to generate snapshots: {failed_views}") else: + work_dir = os.path.join(react_native_dir, "api") snapshot = build_snapshot_for_view( api_view="Test", react_native_dir=react_native_dir, @@ -213,8 +216,18 @@ def build_snapshots( codegen_dir=None, verbose=verbose, input_filter=input_filter, + work_dir=work_dir, ) + if keep_xml: + xml_src = os.path.join(work_dir, "xml") + xml_dst = os.path.join(output_dir, "xml") + if os.path.exists(xml_dst): + shutil.rmtree(xml_dst) + shutil.copytree(xml_src, xml_dst) + if verbose: + print(f"XML files saved to {xml_dst}") + if verbose: print(snapshot) @@ -252,6 +265,11 @@ def main(): action="store_true", help="Run on the local test directory instead of the react-native directory", ) + parser.add_argument( + "--xml", + action="store_true", + help="Keep the generated Doxygen XML files next to the .api output in a xml/ directory", + ) args = parser.parse_args() verbose = not args.check @@ -309,6 +327,7 @@ def main(): input_filter=input_filter, view_filter=args.view, is_test=args.test, + keep_xml=args.xml, ) if args.check: