Skip to content

Commit 289277e

Browse files
coadometa-codesync[bot]
authored andcommitted
Add --xml flag to persist xml artifacts for testing purposes (#56238)
Summary: Pull Request resolved: #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] Differential Revision: D98289956
1 parent a79edd1 commit 289277e

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

scripts/cxx-api/parser/__main__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import argparse
1515
import concurrent.futures
1616
import os
17+
import shutil
1718
import subprocess
1819
import sys
1920
import tempfile
@@ -147,6 +148,7 @@ def build_snapshots(
147148
verbose: bool,
148149
view_filter: str | None = None,
149150
is_test: bool = False,
151+
keep_xml: bool = False,
150152
) -> None:
151153
if not is_test:
152154
configs_to_build = [
@@ -193,6 +195,7 @@ def build_snapshots(
193195
failed_views = ", ".join(name for name, _ in errors)
194196
raise RuntimeError(f"Failed to generate snapshots: {failed_views}")
195197
else:
198+
work_dir = os.path.join(react_native_dir, "api")
196199
snapshot = build_snapshot_for_view(
197200
api_view="Test",
198201
react_native_dir=react_native_dir,
@@ -203,8 +206,18 @@ def build_snapshots(
203206
codegen_platform=None,
204207
verbose=verbose,
205208
input_filter=input_filter,
209+
work_dir=work_dir,
206210
)
207211

212+
if keep_xml:
213+
xml_src = os.path.join(work_dir, "xml")
214+
xml_dst = os.path.join(output_dir, "xml")
215+
if os.path.exists(xml_dst):
216+
shutil.rmtree(xml_dst)
217+
shutil.copytree(xml_src, xml_dst)
218+
if verbose:
219+
print(f"XML files saved to {xml_dst}")
220+
208221
if verbose:
209222
print(snapshot)
210223

@@ -242,6 +255,11 @@ def main():
242255
action="store_true",
243256
help="Run on the local test directory instead of the react-native directory",
244257
)
258+
parser.add_argument(
259+
"--xml",
260+
action="store_true",
261+
help="Keep the generated Doxygen XML files next to the .api output in a xml/ directory",
262+
)
245263
args = parser.parse_args()
246264

247265
verbose = not args.check
@@ -299,6 +317,7 @@ def main():
299317
input_filter=input_filter,
300318
view_filter=args.view,
301319
is_test=args.test,
320+
keep_xml=args.xml,
302321
)
303322

304323
if args.check:

0 commit comments

Comments
 (0)