Skip to content

Commit 248298c

Browse files
committed
libxamarin-app.so has it all now
1 parent b811e29 commit 248298c

File tree

3 files changed

+44
-46
lines changed

3 files changed

+44
-46
lines changed

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.BuildOrder.targets

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ properties that determine build ordering.
6767
_GenerateEnvironmentFiles;
6868
_CompileJava;
6969
_CreateApplicationSharedLibraries;
70-
_CreateAssemblySharedLibraries;
7170
_CompileDex;
7271
$(_AfterCompileDex);
7372
_CreateBaseApk;

src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NativeCompilation.targets

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
</PrepareAbiItems>
5858
</Target>
5959

60-
<Target Name="_PrepareAssemblySharedLibrariesSources">
60+
<Target Name="_PrepareAssemblySharedLibrariesSources"
61+
Condition=" '$(_AndroidUseAssemblySharedLibraries)' == 'true' ">
6162
<PrepareAbiItems
6263
BuildTargetAbis="@(_BuildTargetAbis)"
6364
NativeSourcesDir="$(_NativeAssemblySourceDir)"
@@ -100,14 +101,10 @@
100101
<_NativeAssemblyTarget Include="@(_AndroidRemapAssemblySource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')">
101102
<abi>%(_AndroidRemapAssemblySource.abi)</abi>
102103
</_NativeAssemblyTarget>
103-
</ItemGroup>
104-
</Target>
105104

106-
<Target Name="_PrepareAssemblySharedLibrariesItems">
107-
<ItemGroup>
108-
<_NativeAssemblySharedLibrariesTarget Include="@(_AssemblyDSOSource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')">
105+
<_NativeAssemblyTarget Include="@(_AssemblyDSOSource->'$([System.IO.Path]::ChangeExtension('%(Identity)', '.o'))')">
109106
<abi>%(_AssemblyDSOSource.abi)</abi>
110-
</_NativeAssemblySharedLibrariesTarget>
107+
</_NativeAssemblyTarget>
111108
</ItemGroup>
112109
</Target>
113110

@@ -119,25 +116,16 @@
119116
</ItemGroup>
120117
</Target>
121118

122-
<Target Name="_PrepareAssemblySharedLibrariesItems">
123-
<ItemGroup>
124-
<_AssemblySharedLibrary Include="$(_AndroidApplicationSharedLibraryPath)%(_BuildTargetAbis.Identity)\libxamarin-assemblies.so">
125-
<abi>%(_BuildTargetAbis.Identity)</abi>
126-
</_AssemblySharedLibrary>
127-
</ItemGroup>
128-
</Target>
129-
130119
<!-- Native source code generation targets -->
131120
<Target Name="_GenerateAssemblyDsoNativeSourceFiles"
132-
DependsOnTargets="_PrepareAssemblySharedLibrariesItems"
133121
Condition=" '$(_AndroidUseAssemblySharedLibraries)' == 'true' "
134-
Inputs="@(_ShrunkUserAssemblies);@(_ShrunkFrameworkAssemblies);@(_AndroidResolvedSatellitePaths)"
122+
Inputs="@(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies);@(_AndroidResolvedSatellitePaths)"
135123
Outputs="@(_AssemblyDSOSource)">
136124
<GenerateAssemblyDsoNativeSourceFiles
137125
SourcesOutputDirectory="$(_NativeAssemblySourceDir)"
138126
CompressedAssembliesOutputDirectory="$(_CompressedAssembliesOutputDir)"
139127
SupportedAbis="@(_BuildTargetAbis)"
140-
Assemblies="@(_ShrunkUserAssemblies);@(_ShrunkFrameworkAssemblies);@(_AndroidResolvedSatellitePaths)"
128+
Assemblies="@(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies);@(_AndroidResolvedSatellitePaths)"
141129
EnableCompression="$(AndroidEnableAssemblyCompression)"
142130
/>
143131
</Target>
@@ -182,11 +170,11 @@
182170

183171
<!-- Native code compilation targets -->
184172
<Target Name="_CompileNativeAssemblySources"
185-
DependsOnTargets="_PrepareNativeAssemblyItems;_GenerateCompressedAssembliesNativeSourceFiles"
186-
Inputs="@(_TypeMapAssemblySource);@(_TypeMapAssemblyInclude);@(_EnvironmentAssemblySource);@(_CompressedAssembliesAssemblySource);@(_MarshalMethodsAssemblySource);@(_AndroidRemapAssemblySource)"
173+
DependsOnTargets="_PrepareAssemblySharedLibrariesSources;_PrepareNativeAssemblyItems;_GenerateCompressedAssembliesNativeSourceFiles;_GenerateAssemblyDsoNativeSourceFiles"
174+
Inputs="@(_TypeMapAssemblySource);@(_TypeMapAssemblyInclude);@(_EnvironmentAssemblySource);@(_CompressedAssembliesAssemblySource);@(_MarshalMethodsAssemblySource);@(_AndroidRemapAssemblySource);@(_AssemblyDSOSource)"
187175
Outputs="@(_NativeAssemblyTarget)">
188176
<CompileNativeAssembly
189-
Sources="@(_TypeMapAssemblySource);@(_EnvironmentAssemblySource);@(_CompressedAssembliesAssemblySource);@(_MarshalMethodsAssemblySource);@(_AndroidRemapAssemblySource)"
177+
Sources="@(_TypeMapAssemblySource);@(_EnvironmentAssemblySource);@(_CompressedAssembliesAssemblySource);@(_MarshalMethodsAssemblySource);@(_AndroidRemapAssemblySource);@(_AssemblyDSOSource)"
190178
DebugBuild="$(AndroidIncludeDebugSymbols)"
191179
WorkingDirectory="$(_NativeAssemblySourceDir)"
192180
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
@@ -196,13 +184,6 @@
196184
</ItemGroup>
197185
</Target>
198186

199-
<Target Name="_CompileAssemblySharedLibrariesSources"
200-
DependsOnTargets="_PrepareAssemblySharedLibrariesSources;_GenerateAssemblyDsoNativeSourceFiles"
201-
Condition=" '$(_AndroidUseAssemblySharedLibraries)' == 'true' "
202-
Inputs="@(_AssemblyDSOSource)"
203-
Outputs="@(_NativeAssemblySharedLibrariesTarget)">
204-
</Target>
205-
206187
<!-- Shared library linking targets -->
207188
<Target Name="_CreateApplicationSharedLibraries"
208189
DependsOnTargets="_CompileNativeAssemblySources;_PrepareApplicationSharedLibraryItems"
@@ -218,20 +199,4 @@
218199
<FileWrites Include="@(_ApplicationSharedLibrary)" />
219200
</ItemGroup>
220201
</Target>
221-
222-
<Target Name="_CreateAssemblySharedLibraries"
223-
DependsOnTargets="_CompileAssemblySharedLibrariesSources;_PrepareAssemblySharedLibrariesItems"
224-
Condition=" '$(_AndroidUseAssemblySharedLibraries)' == 'true' "
225-
Inputs="@(_NativeAssemblySharedLibrariesTarget)"
226-
Outputs="@(_AssemblySharedLibrary)">
227-
<LinkApplicationSharedLibraries
228-
ObjectFiles="@(_NativeAssemblySharedLibrariesTarget)"
229-
ApplicationSharedLibraries="@(_AssemblySharedLibrary)"
230-
DebugBuild="$(AndroidIncludeDebugSymbols)"
231-
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)"
232-
/>
233-
<ItemGroup>
234-
<FileWrites Include="@(_AssemblySharedLibrary)" />
235-
</ItemGroup>
236-
</Target>
237202
</Project>

src/Xamarin.Android.Build.Tasks/Utilities/LlvmIrGenerator/LlvmIrGenerator.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void WriteType (GeneratorWriteContext context, Type type, object? value, out Llv
421421
Type elementType = type.GetArrayElementType ();
422422
ulong elementCount = GetAggregateValueElementCount (context, type, value, globalVariable);
423423

424-
WriteArrayType (context, elementType, elementCount, out typeInfo);
424+
WriteArrayType (context, elementType, elementCount, globalVariable, out typeInfo);
425425
return;
426426
}
427427

@@ -437,6 +437,11 @@ void WriteType (GeneratorWriteContext context, Type type, object? value, out Llv
437437
}
438438

439439
void WriteArrayType (GeneratorWriteContext context, Type elementType, ulong elementCount, out LlvmTypeInfo typeInfo)
440+
{
441+
WriteArrayType (context, elementType, elementCount, variable: null, out typeInfo);
442+
}
443+
444+
void WriteArrayType (GeneratorWriteContext context, Type elementType, ulong elementCount, LlvmIrGlobalVariable? variable, out LlvmTypeInfo typeInfo)
440445
{
441446
string irType;
442447
ulong size;
@@ -453,6 +458,35 @@ void WriteArrayType (GeneratorWriteContext context, Type elementType, ulong elem
453458
} else {
454459
irType = GetIRType (elementType, out size, out isPointer);
455460
maxFieldAlignment = size;
461+
462+
if (elementType.IsArray) {
463+
if (variable == null) {
464+
throw new InvalidOperationException ($"Internal error: array of arrays ({elementType}) requires variable to be defined");
465+
}
466+
467+
// For the sake of simpler code, we currently assume that all the element arrays are of the same size, because that's the only scenario
468+
// that we use at this time.
469+
var value = variable.Value as ICollection;
470+
if (value == null) {
471+
throw new InvalidOperationException ($"Internal error: variable '{variable.Name}' of type '{variable.Type}' is required to have a value of type which implements the ICollection interface");
472+
}
473+
474+
if (value.Count == 0) {
475+
throw new InvalidOperationException ($"Internal error: variable '{variable.Name}' of type '{variable.Type}' is required to have a value which is a non-empty ICollection");
476+
}
477+
478+
Array? firstItem = null;
479+
foreach (object v in value) {
480+
firstItem = (Array)v;
481+
break;
482+
}
483+
484+
if (firstItem == null) {
485+
throw new InvalidOperationException ($"Internal error: variable '{variable.Name}' of type '{variable.Type}' is required to have a value which is a non-empty ICollection with non-null elements");
486+
}
487+
488+
irType = $"[{MonoAndroidHelper.CultureInvariantToString (firstItem.Length)} x {irType}]";
489+
}
456490
}
457491
typeInfo = new LlvmTypeInfo (
458492
isPointer: isPointer,

0 commit comments

Comments
 (0)