[TrimmableTypeMap] Generate per-assembly acw-map.txt from scanner results#10959
Draft
simonrozsival wants to merge 1 commit intodev/simonrozsival/trimmable-typemap-05-msbuild-taskfrom
Draft
Conversation
46fbf94 to
feec59b
Compare
…ults Part of #10807. Stacked on #10924. The trimmable typemap path needs acw-map.txt for _ConvertCustomView to fix up custom view names in layout XMLs. This adds acw-map generation as a side-output of GenerateTrimmableTypeMap — the task already has all JavaPeerInfo records from scanning, so no extra scan is needed. Changes: - AcwMapWriter: converts JavaPeerInfo → acw-map.txt format (3 lines per type: partial-asm-qualified, managed, compat-jni — matching legacy format) - GenerateTrimmableTypeMap: new AcwMapDirectory input + PerAssemblyAcwMapFiles output, writes per-assembly acw-map.{AssemblyName}.txt during generation - Trimmable.targets: _MergeAcwMaps target concatenates per-assembly files into the single acw-map.txt consumed by _ConvertCustomView and R8 - 8 unit tests for AcwMapWriter (263 total tests pass) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
feec59b to
39fc4ab
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #10807
Stacked on #10924.
Summary
Adds per-assembly
acw-map.{AssemblyName}.txtgeneration to the trimmable typemap path, enabling_ConvertCustomViewand R8 to work with the trimmable build flow.Background: What is acw-map.txt?
The
acw-map.txtfile maps .NET managed type names to their corresponding Java/ACW (Android Callable Wrapper) names. It is consumed by:_ConvertCustomView— replaces managed type names with ACW names in layout XML files (e.g.,<My.Custom.View>→<crc64.../MyCustomView>)Legacy format (from
ACWMapGenerator)The legacy
ACWMapGenerator(inACWMapGenerator.cs) uses Cecil to scanTypeDefinitionobjects and writes 3 lines per type:Replace('/', '.')is appliedMemoryStreamPool.CreateStreamWriter()which usesUTF8withoutBOM)Files.CopyIfStreamChanged)LoadMapFilereads lines, splits on;, and populates aDictionary<string, string>(first entry wins for duplicates)Trimmable path:
AcwMapWriterThe trimmable path replaces Cecil-based scanning with
JavaPeerScanner(SRM-based).JavaPeerInfoalready contains all the data needed:ManagedTypeName→ managed keyJavaName→ java key (with/→.conversion)CompatJniName→ compat JNI key (with/→.conversion)AssemblyName→ for partial assembly-qualified nameAcwMapWriterwrites the exact same 3-line format as the legacy generator, ensuringLoadMapFileconsumers see no difference.Approach
Instead of a separate scanning task, acw-map generation is a side-output of
GenerateTrimmableTypeMap— the task already has allJavaPeerInforecords from scanning, so no extra scan pass is needed.Changes
AcwMapWriter— pure formatting logic:JavaPeerInfo→ acw-map.txt lines (UTF-8 without BOM, ordinal sort, content-comparison write)GenerateTrimmableTypeMap— newAcwMapDirectoryinput +PerAssemblyAcwMapFilesoutput. Groups peers by assembly and writes per-assembly files._CollectPerAssemblyAcwMapstarget — globs per-assembly*.txtfiles into an item group after_GenerateJavaStubsruns_MergeAcwMapstarget — concatenates per-assembly files into the singleacw-map.txt. UsesInputs/Outputsfor incrementality andWriteOnlyWhenDifferentto avoid unnecessary downstream rebuilds.AcwMapWriterformat correctness (261 total tests pass)Build flow
Incrementality
_GenerateJavaStubs: stamp-based — skipped when assemblies unchangedAcwMapWriter.WriteToFile: content comparison — unchanged assemblies produce identical files (no timestamp update)_MergeAcwMaps:Inputs="@(_PerAssemblyAcwMapFiles)"/Outputs="$(_AcwMapFile)"— skipped when no per-assembly file is newerWriteOnlyWhenDifferent: mergedacw-map.txtonly updated when content changesFuture: per-assembly incremental optimization
Per-assembly acw-map files lay the groundwork for #10958 (build time optimizations). When the scan step gains per-assembly
Inputs/Outputsincrementality, unchanged assemblies will skip scanning entirely — and their acw-map files will remain untouched, so the merge step will also be skipped.