From bdaf176a21455ccabca984b141b6a8ee5e673a8e Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Tue, 3 Mar 2026 01:00:16 -0800 Subject: [PATCH] Make doxygen binary location configurable (#55842) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55842 Changelog: [Internal] Updates the C++ API snapshot generator so that it tries to read doxygen binary location from the env variable before falling back to relying on PATH. Reviewed By: cipolleschi Differential Revision: D94901517 fbshipit-source-id: 48c770f9b80597304f3323fd0c00a9a68ebf889a --- scripts/cxx-api/parser/__main__.py | 23 ++++++++++++++++------- scripts/cxx-api/tests/test_snapshots.py | 7 ++++++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/scripts/cxx-api/parser/__main__.py b/scripts/cxx-api/parser/__main__.py index d2a3d48a229..25df8a1ae67 100644 --- a/scripts/cxx-api/parser/__main__.py +++ b/scripts/cxx-api/parser/__main__.py @@ -87,31 +87,32 @@ def build_snapshot_for_view( definitions=definitions, ) - print("Running Doxygen") - # If there is already a doxygen output directory, delete it if os.path.exists(os.path.join(react_native_dir, "api")): print("Deleting existing output directory") subprocess.run(["rm", "-rf", os.path.join(react_native_dir, "api")]) + print("Running Doxygen") + # Run doxygen with the config file + doxygen_bin = os.environ.get("DOXYGEN_BIN", "doxygen") result = subprocess.run( - ["doxygen", DOXYGEN_CONFIG_FILE], + [doxygen_bin, DOXYGEN_CONFIG_FILE], cwd=react_native_dir, capture_output=True, text=True, ) - # Delete the Doxygen config file - print("Deleting Doxygen config file") - subprocess.run(["rm", DOXYGEN_CONFIG_FILE], cwd=react_native_dir) - # Check the result if result.returncode != 0: print(f"Doxygen finished with error: {result.stderr}") else: print("Doxygen finished successfully") + # Delete the Doxygen config file + print("Deleting Doxygen config file") + subprocess.run(["rm", DOXYGEN_CONFIG_FILE], cwd=react_native_dir) + # build snapshot, convert to string, and save to file snapshot = build_snapshot(os.path.join(react_native_dir, "api", "xml")) snapshot_string = snapshot.to_string() @@ -145,6 +146,14 @@ def main(): ) args = parser.parse_args() + doxygen_bin = os.environ.get("DOXYGEN_BIN", "doxygen") + version_result = subprocess.run( + [doxygen_bin, "--version"], + capture_output=True, + text=True, + ) + print(f"Using Doxygen {version_result.stdout.strip()} ({doxygen_bin})") + # Define the path to the react-native directory react_native_dir = ( os.path.join(get_react_native_dir(), "packages", "react-native") diff --git a/scripts/cxx-api/tests/test_snapshots.py b/scripts/cxx-api/tests/test_snapshots.py index 44ee8a41566..c78687904d4 100644 --- a/scripts/cxx-api/tests/test_snapshots.py +++ b/scripts/cxx-api/tests/test_snapshots.py @@ -49,10 +49,15 @@ def _assert_text_equal_with_diff( tc.fail(diff) +def _get_doxygen_bin() -> str: + return os.environ.get("DOXYGEN_BIN", "doxygen") + + def _generate_doxygen_api(case_dir_path: str, doxygen_config_path: str) -> None: """Run doxygen to generate XML API documentation.""" + doxygen_bin = _get_doxygen_bin() result = subprocess.run( - ["doxygen", doxygen_config_path], + [doxygen_bin, doxygen_config_path], cwd=case_dir_path, capture_output=True, text=True,