Skip to content

Commit ea4332e

Browse files
coadofacebook-github-bot
authored andcommitted
Add global exclude patterns to the cxx api config
Summary: Refactor and add global exclude patterns to the C++ stable API snapshot config. This enables better modularization of shared exclude patterns coming from the assumption that ReactAndroid and ReactApple consists of ReactCommon in their inputs and some paths should not be processed on each platform. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D97465431
1 parent bdb3f95 commit ea4332e

3 files changed

Lines changed: 345 additions & 232 deletions

File tree

scripts/cxx-api/config.yml

Lines changed: 81 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,82 @@
1-
ReactCommon:
2-
codegen:
3-
inputs:
4-
- packages/react-native/ReactCommon
5-
exclude_patterns:
6-
- "*/test_utils/*"
7-
- "*/test/*"
8-
- "*/jni/*"
9-
- "*/platform/cxx/*" # Should this be included in ReactCommon?
10-
- "*/platform/windows/*"
11-
- "*/platform/macos/*"
12-
- "*/platform/ios/*"
13-
- "*/platform/android/*"
14-
input_filter: false
15-
definitions:
16-
variants:
17-
debug:
18-
definitions:
19-
DEBUG: 1
20-
REACT_NATIVE_DEBUG: 1
21-
release:
22-
definitions:
23-
NDEBUG: 1
24-
REACT_NATIVE_PRODUCTION: 1
1+
exclude_patterns:
2+
- "*/test_utils/*"
3+
- "*/test/*"
254

26-
ReactAndroid:
27-
codegen:
28-
platform: android
29-
inputs:
30-
- packages/react-native/ReactCommon
31-
- packages/react-native/ReactAndroid
32-
exclude_patterns:
33-
- "*/test_utils/*"
34-
- "*/test/*"
35-
- "*/platform/cxx/*"
36-
- "*/platform/windows/*"
37-
- "*/platform/macos/*"
38-
- "*/platform/ios/*"
39-
input_filter: false
40-
definitions:
41-
RN_SERIALIZABLE_STATE: 1
42-
ANDROID: 1
43-
variants:
44-
debug:
45-
definitions:
46-
DEBUG: 1
47-
REACT_NATIVE_DEBUG: 1
48-
release:
49-
definitions:
50-
NDEBUG: 1
51-
REACT_NATIVE_PRODUCTION: 1
52-
53-
# ReactIOS?
54-
ReactApple:
55-
codegen:
56-
platform: ios
57-
inputs:
58-
- packages/react-native/ReactCommon
59-
- packages/react-native/React
60-
- packages/react-native/ReactApple
61-
- packages/react-native/Libraries
62-
exclude_patterns:
63-
- "*/test_utils/*"
64-
- "*/test/*"
65-
- "*/jni/*"
66-
- "*/platform/cxx/*"
67-
- "*/platform/windows/*"
68-
- "*/platform/macos/*"
69-
- "*/platform/android/*"
70-
- "*+Private.h"
71-
- "*+Internal.h"
72-
- "*/scripts/*"
73-
- "*/templates/*"
74-
input_filter: true
75-
definitions:
76-
__cplusplus: 1
77-
variants:
78-
debug:
79-
definitions:
80-
DEBUG: 1
81-
REACT_NATIVE_DEBUG: 1
82-
release:
83-
definitions:
84-
NDEBUG: 1
85-
REACT_NATIVE_PRODUCTION: 1
5+
platforms:
6+
ReactCommon:
7+
codegen:
8+
inputs:
9+
- packages/react-native/ReactCommon
10+
exclude_patterns:
11+
- "*/jni/*"
12+
- "*/platform/cxx/*" # Should this be included in ReactCommon?
13+
- "*/platform/windows/*"
14+
- "*/platform/macos/*"
15+
- "*/platform/ios/*"
16+
- "*/platform/android/*"
17+
input_filter: false
18+
definitions:
19+
variants:
20+
debug:
21+
definitions:
22+
DEBUG: 1
23+
REACT_NATIVE_DEBUG: 1
24+
release:
25+
definitions:
26+
NDEBUG: 1
27+
REACT_NATIVE_PRODUCTION: 1
28+
ReactAndroid:
29+
codegen:
30+
platform: android
31+
inputs:
32+
- packages/react-native/ReactCommon
33+
- packages/react-native/ReactAndroid
34+
exclude_patterns:
35+
- "*/platform/cxx/*"
36+
- "*/platform/windows/*"
37+
- "*/platform/macos/*"
38+
- "*/platform/ios/*"
39+
input_filter: false
40+
definitions:
41+
RN_SERIALIZABLE_STATE: 1
42+
ANDROID: 1
43+
variants:
44+
debug:
45+
definitions:
46+
DEBUG: 1
47+
REACT_NATIVE_DEBUG: 1
48+
release:
49+
definitions:
50+
NDEBUG: 1
51+
REACT_NATIVE_PRODUCTION: 1
52+
# ReactIOS?
53+
ReactApple:
54+
codegen:
55+
platform: ios
56+
inputs:
57+
- packages/react-native/ReactCommon
58+
- packages/react-native/React
59+
- packages/react-native/ReactApple
60+
- packages/react-native/Libraries
61+
exclude_patterns:
62+
- "*/jni/*"
63+
- "*/platform/cxx/*"
64+
- "*/platform/windows/*"
65+
- "*/platform/macos/*"
66+
- "*/platform/android/*"
67+
- "*+Private.h"
68+
- "*+Internal.h"
69+
- "*/scripts/*"
70+
- "*/templates/*"
71+
input_filter: true
72+
definitions:
73+
__cplusplus: 1
74+
variants:
75+
debug:
76+
definitions:
77+
DEBUG: 1
78+
REACT_NATIVE_DEBUG: 1
79+
release:
80+
definitions:
81+
NDEBUG: 1
82+
REACT_NATIVE_PRODUCTION: 1

scripts/cxx-api/parser/config.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,24 @@ def parse_config(
4747
"""
4848
Parse a raw config dictionary and return a flattened list of snapshot configs.
4949
50+
The config must contain:
51+
- An optional top-level ``exclude_patterns`` list that is prepended to
52+
every platform's own ``exclude_patterns``.
53+
- A ``platforms`` mapping whose values are per-platform view configs.
54+
5055
Args:
5156
raw_config: Dictionary containing the parsed YAML config
5257
base_dir: Base directory for resolving relative input paths
53-
codegen_path: Optional path to codegen generated code
5458
5559
Returns:
5660
Flattened list of ApiViewSnapshotConfig objects for all views and variants
5761
"""
62+
global_exclude_patterns: list[str] = raw_config.get("exclude_patterns") or []
63+
platforms: dict = raw_config.get("platforms") or {}
64+
5865
snapshot_configs = []
5966

60-
for view_name, view_config in raw_config.items():
67+
for view_name, view_config in platforms.items():
6168
inputs = [
6269
path if path.startswith("/") else os.path.join(base_dir, path)
6370
for path in (view_config.get("inputs") or [])
@@ -69,6 +76,15 @@ def parse_config(
6976
input_filter = view_config.get("input_filter", False)
7077
base_definitions = view_config.get("definitions") or {}
7178

79+
exclude_platform_patterns = view_config.get("exclude_patterns") or []
80+
seen: set[str] = set()
81+
merged_patterns: list[str] = []
82+
for pattern in global_exclude_patterns + exclude_platform_patterns:
83+
if pattern not in seen:
84+
merged_patterns.append(pattern)
85+
seen.add(pattern)
86+
exclude_patterns = merged_patterns
87+
7288
raw_variants = view_config.get("variants") or {}
7389
variants = [
7490
ApiViewVariant(
@@ -117,7 +133,6 @@ def parse_config_file(
117133
Args:
118134
config_path: Path to the config.yml file
119135
base_dir: Base directory for resolving relative input paths
120-
codegen_path: Optional path to codegen generated code
121136
122137
Returns:
123138
Flattened list of ApiViewSnapshotConfig objects for all views and variants

0 commit comments

Comments
 (0)