Skip to content

Commit 4d55775

Browse files
Fix assembly store: add ABI metadata to TypeMap DLLs, call GenerateNativeApplicationConfigSources
The trimmable _GenerateJavaStubs was missing: 1. ABI/RuntimeIdentifier metadata on TypeMap _ResolvedAssemblies items (required by CreateAssemblyStore) 2. GenerateNativeApplicationConfigSources call (builds assembly hash table) 3. _DefineBuildTargetAbis dependency (provides @(_BuildTargetAbis)) Now TypeMap DLLs flow through the full assembly pipeline and appear in libassembly-store.so with correct hash entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 483dc03 commit 4d55775

1 file changed

Lines changed: 57 additions & 9 deletions

File tree

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.TypeMap.Trimmable.targets

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
</Target>
6767

6868
<!--
69-
_GenerateJavaStubs: lightweight — copies JCW files and generates stubs.
70-
TypeMap generation already happened via _GenerateTrimmableTypeMap.
69+
_GenerateJavaStubs: overrides the legacy target from BuildOrder.targets.
70+
In the trimmable path, TypeMap generation already happened in _GenerateTrimmableTypeMap,
71+
so this target only handles JCW file copying, manifest, assembly store setup, and native config.
72+
We keep the name _GenerateJavaStubs because BuildOrder.targets references it.
7173
-->
7274
<Target Name="_GenerateJavaStubs"
73-
DependsOnTargets="_SetLatestTargetFrameworkVersion;_CleanIntermediateIfNeeded;_PrepareAssemblies;_GetGenerateJavaStubsInputs;_PrepareNativeAssemblySources"
75+
DependsOnTargets="_SetLatestTargetFrameworkVersion;_CleanIntermediateIfNeeded;_PrepareAssemblies;_GetGenerateJavaStubsInputs;_DefineBuildTargetAbis;_PrepareNativeAssemblySources"
7476
Inputs="@(_GenerateJavaStubsInputs)"
7577
Outputs="$(_AndroidStampDirectory)_GenerateJavaStubs.stamp">
7678

@@ -79,16 +81,62 @@
7981
</ItemGroup>
8082
<Copy SourceFiles="@(_TypeMapJavaFiles)" DestinationFolder="$(IntermediateOutputPath)android\src\%(RecursiveDir)" />
8183

82-
<!-- Add TRIMMED TypeMap DLLs (from ILLink output) to _ResolvedAssemblies so they're
83-
counted by GenerateNativeApplicationConfigSources and included in the assembly store.
84-
ILLink has already run in inner builds by the time _GenerateJavaStubs executes. -->
84+
<!-- TypeMap DLLs are already in _ResolvedAssemblies (added by the glob in _GenerateTrimmableTypeMap
85+
output flowing through the pipeline). They go through _RemoveRegisterAttribute → shrunk/.
86+
But they lack ABI metadata needed by CreateAssemblyStore.
87+
Add the metadata and ensure they're in _ShrunkUserAssemblies for the compression pipeline. -->
88+
<PropertyGroup>
89+
<_TypeMapFirstAbi Condition=" '$(AndroidSupportedAbis)' != '' ">$([System.String]::Copy('$(AndroidSupportedAbis)').Split(';')[0])</_TypeMapFirstAbi>
90+
<_TypeMapFirstAbi Condition=" '$(_TypeMapFirstAbi)' == '' ">arm64-v8a</_TypeMapFirstAbi>
91+
<_TypeMapFirstRid Condition=" '$(_TypeMapFirstAbi)' == 'arm64-v8a' ">android-arm64</_TypeMapFirstRid>
92+
<_TypeMapFirstRid Condition=" '$(_TypeMapFirstAbi)' == 'armeabi-v7a' ">android-arm</_TypeMapFirstRid>
93+
<_TypeMapFirstRid Condition=" '$(_TypeMapFirstAbi)' == 'x86_64' ">android-x64</_TypeMapFirstRid>
94+
<_TypeMapFirstRid Condition=" '$(_TypeMapFirstAbi)' == 'x86' ">android-x86</_TypeMapFirstRid>
95+
</PropertyGroup>
8596
<ItemGroup>
86-
<_LinkedTypeMapDlls Include="$(IntermediateOutputPath)android-arm64\linked\_*.TypeMap.dll;$(IntermediateOutputPath)android-arm64\linked\_Microsoft.Android.TypeMaps.dll" />
87-
<_ResolvedAssemblies Include="@(_LinkedTypeMapDlls)">
88-
<DestinationSubPath>%(Filename)%(Extension)</DestinationSubPath>
97+
<!-- Update existing _ResolvedAssemblies items to have ABI metadata -->
98+
<_ResolvedAssemblies Update="$(_TypeMapOutputDirectory)*.dll">
99+
<Abi>$(_TypeMapFirstAbi)</Abi>
100+
<RuntimeIdentifier>$(_TypeMapFirstRid)</RuntimeIdentifier>
101+
<DestinationSubPath>$(_TypeMapFirstAbi)/%(Filename)%(Extension)</DestinationSubPath>
102+
<DestinationSubDirectory>$(_TypeMapFirstAbi)/</DestinationSubDirectory>
89103
</_ResolvedAssemblies>
90104
</ItemGroup>
91105

106+
<!-- Generate native application config (assembly store hash table, environment, etc.).
107+
Must run AFTER TypeMap DLLs are added to _ResolvedAssemblies above. -->
108+
<GenerateNativeApplicationConfigSources
109+
ResolvedAssemblies="@(_ResolvedAssemblies)"
110+
SatelliteAssemblies="@(_AndroidResolvedSatellitePaths)"
111+
NativeLibraries="@(_AllNativeLibraries)"
112+
NativeLibrariesNoJniPreload="@(_AndroidNativeLibraryNeverJniPreload);@(AndroidNativeLibraryNoJniPreload)"
113+
NativeLibrariesAlwaysJniPreload="@(_AndroidNativeLibraryAlwaysJniPreload)"
114+
MonoComponents="@(_MonoComponent)"
115+
EnvironmentOutputDirectory="$(IntermediateOutputPath)android"
116+
Environments="@(_EnvironmentFiles)"
117+
AndroidAotMode="$(AndroidAotMode)"
118+
AndroidAotEnableLazyLoad="$(AndroidAotEnableLazyLoad)"
119+
EnableLLVM="$(EnableLLVM)"
120+
HttpClientHandlerType="$(AndroidHttpClientHandlerType)"
121+
TlsProvider="$(AndroidTlsProvider)"
122+
Debug="$(AndroidIncludeDebugSymbols)"
123+
AndroidSequencePointsMode="$(_SequencePointsMode)"
124+
EnableSGenConcurrent="$(AndroidEnableSGenConcurrent)"
125+
SupportedAbis="@(_BuildTargetAbis)"
126+
AndroidPackageName="$(_AndroidPackage)"
127+
EnablePreloadAssembliesDefault="$(_AndroidEnablePreloadAssembliesDefault)"
128+
PackageNamingPolicy="$(AndroidPackageNamingPolicy)"
129+
BoundExceptionType="$(AndroidBoundExceptionType)"
130+
RuntimeConfigBinFilePath="$(_BinaryRuntimeConfigPath)"
131+
UseAssemblyStore="$(_AndroidUseAssemblyStore)"
132+
EnableMarshalMethods="$(_AndroidUseMarshalMethods)"
133+
EnableManagedMarshalMethodsLookup="$(_AndroidUseManagedMarshalMethodsLookup)"
134+
CustomBundleConfigFile="$(AndroidBundleConfigurationFile)"
135+
TargetsCLR="$(_AndroidUseCLR)"
136+
AndroidRuntime="$(_AndroidRuntime)"
137+
ProjectRuntimeConfigFilePath="$(ProjectRuntimeConfigFilePath)"
138+
/>
139+
92140
<!-- HACK: Copy user's AndroidManifest.xml (TODO: #10807) -->
93141
<Copy SourceFiles="$(_AndroidManifestAbs)" DestinationFiles="$(IntermediateOutputPath)AndroidManifest.xml"
94142
SkipUnchangedFiles="true"

0 commit comments

Comments
 (0)