Commit d368a60
[TrimmableTypeMap][NativeAOT] Build plumbing fixes (#11989)
Independent build-plumbing fixes for the **trimmable type map on NativeAOT** (the opt-in `-p:_AndroidTypeMapImplementation=trimmable` + `_AndroidRuntime=NativeAOT` path). These stand alone and do **not** depend on making the trimmable type map the NativeAOT default (#11822) — extracting them keeps that PR focused.
### Fixes
- **ILC DGML collection** (3 commits): fix XA4321 by collecting the ILC DGML from the per-RID **inner** build path; handle both single-RID output-path shapes; and fall back to the codegen DGML when the scan DGML is absent. These make the ACW/proguard keep-rule generation robust across the RID-nested inner-build layout.
- **Fix `ManifestPlaceholders` on the trimmable NativeAOT path** — placeholder substitution in the generated manifest now works (`ManifestGenerator`).
- **`_AndroidTrimmableTypemapTrimJavaCode` toggle (default off)** — optionally skip DGML parsing and keep all ACWs, trading a little dex size for skipping the very large DGML files that dominate NativeAOT build time. `GenerateNativeAotProguardConfiguration` no longer requires DGML input when disabled.
- **Generate per-process runtime provider Java sources** — share provider-source generation between MonoVM and NativeAOT (`GenerateAdditionalProviderSources` / `GenerateNativeAotBootstrapSources`).
- **Keep user `AndroidJavaSource` under R8** — user-authored Java (no managed peer) is absent from the ACW map, so emit explicit `-keep` rules; otherwise R8 shrinks it away (which can, e.g., drop sources so an app that needs multidex no longer does).
- **Keep the `_Microsoft.Android.Resource.Designer` assembly** — resource ids are resolved via reflection (`ResourceIdManager`), which the trimmer can't follow; root the designer via `TrimmerRootAssembly` (honored by both ILLink and ILC) so it isn't trimmed away (otherwise resource-id access throws `FileNotFoundException: _Microsoft.Android.Resource.Designer`).
### Testing
- `Microsoft.Android.Sdk.TrimmableTypeMap` generator + `GenerateTrimmableTypeMapTests` build clean; full validation via CI (device tests) since these exercise the on-device NativeAOT path.
Extracted from #11822.
## Issue references
Partially addresses #11774. Contributes to #10790 and #10793.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 44fbb8a commit d368a60
9 files changed
Lines changed: 290 additions & 39 deletions
File tree
- src
- Microsoft.Android.Sdk.TrimmableTypeMap/Generator
- Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk/targets
- Tasks
- Tests/Xamarin.Android.Build.Tests
- Tasks
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
522 | 530 | | |
523 | 531 | | |
524 | 532 | | |
| |||
Lines changed: 53 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
13 | | - | |
| 20 | + | |
| 21 | + | |
14 | 22 | | |
| 23 | + | |
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
| |||
140 | 149 | | |
141 | 150 | | |
142 | 151 | | |
143 | | - | |
| 152 | + | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
| 156 | + | |
147 | 157 | | |
148 | 158 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
153 | 197 | | |
154 | 198 | | |
155 | 199 | | |
156 | 200 | | |
157 | | - | |
| 201 | + | |
158 | 202 | | |
159 | | - | |
| 203 | + | |
160 | 204 | | |
161 | 205 | | |
162 | 206 | | |
163 | 207 | | |
| 208 | + | |
164 | 209 | | |
165 | 210 | | |
166 | 211 | | |
| |||
Lines changed: 56 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
101 | | - | |
| 107 | + | |
102 | 108 | | |
103 | 109 | | |
104 | 110 | | |
| |||
380 | 386 | | |
381 | 387 | | |
382 | 388 | | |
| 389 | + | |
383 | 390 | | |
384 | 391 | | |
385 | 392 | | |
| |||
388 | 395 | | |
389 | 396 | | |
390 | 397 | | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
391 | 407 | | |
392 | 408 | | |
393 | 409 | | |
| |||
397 | 413 | | |
398 | 414 | | |
399 | 415 | | |
| 416 | + | |
| 417 | + | |
400 | 418 | | |
401 | 419 | | |
402 | 420 | | |
| |||
423 | 441 | | |
424 | 442 | | |
425 | 443 | | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
426 | 481 | | |
Lines changed: 24 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 73 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 74 | + | |
85 | 75 | | |
86 | 76 | | |
87 | 77 | | |
| |||
122 | 112 | | |
123 | 113 | | |
124 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
125 | 138 | | |
126 | 139 | | |
127 | 140 | | |
| |||
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | 41 | | |
36 | 42 | | |
| 43 | + | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
0 commit comments