Commit c2bdc5b
[TrimmableTypeMap] Build pipeline: targets, stubs, manifest integration, feature switches (#11036)
* PR 4: Build pipeline changes for trimmable typemap
- Update TrimmableTypeMapGenerator.Execute() with manifest generation,
assembly manifest scanning, acw-map writing, and new optional parameters
- Add ManifestConfig record to TrimmableTypeMapTypes.cs
- Update TrimmableTypeMapResult with AdditionalProviderSources
- Update GenerateTrimmableTypeMap MSBuild task with manifest/config properties
- Create GenerateEmptyTypemapStub task for LLVM IR native typemap stubs
- Create ApplicationRegistration.Trimmable.java (empty registerApplications)
- Create Trimmable.CoreCLR.xml preserve list for JNIEnvInit.Initialize
- Rewrite Trimmable.targets with full build pipeline (separate generation
and _GenerateJavaStubs targets, native stub generation, manifest handling)
- Rewrite Trimmable.CoreCLR.targets with ILLink integration and per-ABI
assembly store support
- Add TrimmableTypeMap=false feature switch to MonoVM and NativeAOT targets
- Handle trimmed JNIEnvInit tokens in GenerateNativeApplicationConfigSources
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: remove #nullable enable, use IsNullOrEmpty extension
- Remove redundant #nullable enable from 6 Generator files and task file
- Convert string.IsNullOrEmpty to IsNullOrEmpty extension in task
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix _PrepareNativeAssemblySources Outputs typo (typemaps → typemap)
The target declared Outputs as typemaps.{abi}.ll but GenerateEmptyTypemapStub
writes typemap.{abi}.ll. The mismatch caused MSBuild to always rerun the target.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix CS1503: load XDocument from manifest path, guard GetDirectoryName null
- Load manifestTemplatePath into XDocument before passing to
ManifestGenerator.Generate() which expects XDocument? (not string)
- Guard Path.GetDirectoryName() result with IsNullOrEmpty check
before passing to Directory.CreateDirectory()
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Move all IO from TrimmableTypeMapGenerator to MSBuild task
The previous PR (#11034) established the pattern that TTMG has no IO
operations. The build pipeline PR regressed this by adding acw-map
writing, manifest template loading, and manifest file saving into
the generator.
Move all IO back to GenerateTrimmableTypeMap (MSBuild task):
- Load manifest template XDocument from file path
- Write merged manifest to disk via XDocument.Save()
- Write merged acw-map.txt via Files.CopyIfStreamChanged()
Refactor ManifestGenerator.Generate to return (XDocument, IList<string>)
instead of writing to disk. Add GeneratedManifest record to carry the
in-memory result.
Update ManifestGeneratorTests to work entirely in-memory (no temp dirs,
no IDisposable).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Generate ApplicationRegistration.java with registerNatives for App/Instrumentation types
Application and Instrumentation types skip the JCW static initializer
block (CannotRegisterInStaticCtor) because libmonodroid.so isn't loaded
when these classes are first instantiated by the Android framework.
The legacy path deferred their registration to the generated
ApplicationRegistration.registerApplications() method. The trimmable
path incorrectly used an empty static file, meaning these types would
never get their native methods registered → UnsatisfiedLinkError.
Fix: dynamically generate ApplicationRegistration.java in the
GenerateTrimmableTypeMap MSBuild task with
mono.android.Runtime.registerNatives(MyApp.class);
for each Application/Instrumentation type. This triggers the
trimmable TrimmableTypeMap.OnRegisterNatives handler which
dispatches to the UCO-generated IAndroidCallableWrapper.RegisterNatives.
Call graph:
MonoPackageManager.LoadApplication()
→ Runtime.initInternal()
→ ApplicationRegistration.registerApplications()
→ Runtime.registerNatives(MyApp.class) [generated]
→ OnRegisterNatives (JNI native) [TrimmableTypeMap.cs]
→ IAndroidCallableWrapper.RegisterNatives() [UCO IL]
→ Application.onCreate() → n_onCreate() [now registered]
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address trimmable typemap review feedback
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix CS0246/CS1503: add missing 'using System.Xml.Linq' to GenerateTrimmableTypeMap.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Restore pre-existing feature switches in NativeAOT.targets; fix null! in TrimmableTypeMapTypes
- Restore IsMonoRuntime=false and IsCoreClrRuntime=false RuntimeHostConfigurationOption
items accidentally removed from NativeAOT.targets
- Change ApplicationRegistrationTypes parameter from null! to nullable (null?)
to comply with the no null-forgiving operator rule
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Address review: fix manifest save, remove dead PerAssemblyAcwMaps, style
- Use Files.CopyIfStringChanged instead of XDocument.Save() to preserve
manifest file timestamp when content is unchanged (fixes incremental builds)
- Remove dead PerAssemblyAcwMapFiles [Output] property, GeneratePerAssemblyAcwMaps()
method, and AcwMapDirectory [Required] property — the only consumer (_MergeAcwMaps)
was removed in this PR; nothing reads the per-assembly acw-map files anymore
- Add 'using System.Text' and use short StringBuilder form
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix: use MemoryStream to preserve XML declaration in manifest output
XDocument.ToString() drops the <?xml version="1.0" encoding="utf-8"?>
declaration. Use XDocument.Save(Stream) + Files.CopyIfStreamChanged to
preserve both the XML declaration and incremental-build safety.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Update BuildReleaseArm64SimpleDotNet.MonoVM.apkdesc from CI
Updated sizes from macOS > Tests > MSBuild 3 build artifacts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* Fix indentation in GenerateTrimmableTypeMap.cs
Address code review feedback: properly indent the entire file using
tabs per the repo's .editorconfig convention (1 tab for class members,
2 tabs for method body, etc.).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>1 parent 77f88ea commit c2bdc5b
20 files changed
Lines changed: 735 additions & 329 deletions
File tree
- src
- Microsoft.Android.Sdk.TrimmableTypeMap
- Generator
- Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk
- PreserveLists
- targets
- Tasks
- Tests
- Xamarin.Android.Build.Tests/Tasks
- Xamarin.ProjectTools/Resources/Base
- tests/Microsoft.Android.Sdk.TrimmableTypeMap.Tests/Generator
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
| |||
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
160 | | - | |
| 158 | + | |
161 | 159 | | |
162 | 160 | | |
163 | 161 | | |
| |||
169 | 167 | | |
170 | 168 | | |
171 | 169 | | |
172 | | - | |
| 170 | + | |
173 | 171 | | |
174 | 172 | | |
175 | 173 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
Lines changed: 23 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
| |||
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
| 41 | + | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
46 | | - | |
| 44 | + | |
47 | 45 | | |
48 | 46 | | |
49 | 47 | | |
| |||
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
| 80 | + | |
83 | 81 | | |
84 | 82 | | |
85 | 83 | | |
| |||
123 | 121 | | |
124 | 122 | | |
125 | 123 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
| 124 | + | |
134 | 125 | | |
135 | 126 | | |
136 | 127 | | |
| |||
162 | 153 | | |
163 | 154 | | |
164 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
165 | 162 | | |
166 | 163 | | |
167 | 164 | | |
| |||
185 | 182 | | |
186 | 183 | | |
187 | 184 | | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
| 185 | + | |
| 186 | + | |
194 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
Lines changed: 0 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | 3 | | |
| |||
Lines changed: 64 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
21 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
22 | 30 | | |
23 | 31 | | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | | - | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
| |||
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
39 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
40 | 98 | | |
41 | 99 | | |
42 | | - | |
| 100 | + | |
43 | 101 | | |
44 | 102 | | |
45 | 103 | | |
| 104 | + | |
46 | 105 | | |
47 | | - | |
| 106 | + | |
48 | 107 | | |
49 | 108 | | |
50 | 109 | | |
| |||
Lines changed: 37 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
10 | 22 | | |
11 | 23 | | |
12 | 24 | | |
13 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments