Commit 948835d
fix(gradle-plugin): guard missing autolinked JNI dirs (#56886)
Summary:
Related to #56334.
`GenerateAutolinkingNewArchitecturesFileTask` currently emits unconditional `add_subdirectory(...)` calls for autolinked New Architecture JNI/codegen directories.
During `clean`, Android Studio native model configuration, or other native cleanup/configuration flows, some dependency codegen directories may not exist yet. CMake then fails before clean/configuration can complete:
```text
add_subdirectory given source ".../android/build/generated/source/codegen/jni/"
which is not an existing directory
```
This changes the generated `Android-autolinking.cmake` to:
- initialize `AUTOLINKED_LIBRARIES` as an empty list;
- only call `add_subdirectory(...)` when the native directory exists;
- append each autolinked target only after its directory has been added.
That keeps existing generated JNI directories linked as before while allowing native clean/model configuration to skip directories that have not been generated yet.
## Changelog:
[ANDROID] [FIXED] - Guard missing autolinked JNI directories in generated CMake during native clean/model configuration.
Pull Request resolved: #56886
Test Plan:
```sh
./gradlew -p packages/gradle-plugin :react-native-gradle-plugin:test --tests com.facebook.react.tasks.GenerateAutolinkingNewArchitecturesFileTaskTest
```
Result:
```text
BUILD SUCCESSFUL
```
Reviewed By: christophpurrer
Differential Revision: D105826478
Pulled By: cortinico
fbshipit-source-id: e3a698c2334cc02189eefca21b34a0a0181eb5f31 parent b3c0f3c commit 948835d
2 files changed
Lines changed: 46 additions & 31 deletions
File tree
- packages/gradle-plugin/react-native-gradle-plugin/src
- main/kotlin/com/facebook/react/tasks
- test/kotlin/com/facebook/react/tasks
Lines changed: 25 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
71 | 92 | | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | 96 | | |
88 | | - | |
89 | 97 | | |
90 | 98 | | |
91 | 99 | | |
| |||
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
176 | | - | |
| 184 | + | |
177 | 185 | | |
178 | | - | |
179 | | - | |
180 | | - | |
| 186 | + | |
181 | 187 | | |
182 | 188 | | |
183 | 189 | | |
| |||
Lines changed: 21 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
131 | 132 | | |
132 | 133 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 134 | | |
137 | 135 | | |
138 | 136 | | |
| |||
155 | 153 | | |
156 | 154 | | |
157 | 155 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| |||
0 commit comments