1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+
1
5
using Microsoft . Build . Framework ;
6
+ using Xamarin . Android . Tasks . LLVMIR ;
7
+ using Xamarin . Android . Tools ;
2
8
3
9
namespace Xamarin . Android . Tasks ;
4
10
5
11
partial class AssemblyBlobDSOGenerator
6
12
{
7
- public sealed class BlobAssemblyInfo
8
- {
9
- public bool IsCompressed { get ; set ; }
10
- public ulong OffsetInBlob { get ; set ; }
11
- public ulong SizeInBlob { get ; set ; }
12
- public ulong Size { get ; set ; }
13
- public ITaskItem Item { get ; }
13
+ // Native structures and constants
14
14
15
- public BlobAssemblyInfo ( ITaskItem item )
16
- {
17
- Item = item ;
18
- }
19
- }
15
+ // Must be identical to the like-named constants in src/monodroid/jni/xamarin-app.hh
16
+ const uint AssemblyEntry_IsCompressed = 1 << 0 ;
17
+ const uint AssemblyEntry_HasConfig = 1 << 1 ;
20
18
21
19
class AssemblyIndexEntryBase < T >
22
20
{
21
+ [ NativeAssembler ( Ignore = true ) ]
22
+ public string Name ;
23
+
24
+ [ NativeAssembler ( NumberFormat = LlvmIrVariableNumberFormat . Hexadecimal ) ]
23
25
public T name_hash ;
24
26
public uint input_data_offset ;
25
27
public uint input_data_size ;
26
28
public uint output_data_offset ;
27
29
public uint output_data_size ;
28
30
public uint info_index ;
29
- public bool is_compressed ;
30
- } ;
31
+ public uint flags ;
32
+ }
31
33
32
34
sealed class AssemblyIndexEntry32 : AssemblyIndexEntryBase < uint >
33
35
{ }
@@ -40,5 +42,52 @@ struct AssembliesConfig
40
42
public uint assembly_blob_size ;
41
43
public uint assembly_name_length ;
42
44
public uint assembly_count ;
43
- } ;
45
+ }
46
+
47
+ // Generator support
48
+ public sealed class BlobAssemblyInfo
49
+ {
50
+ public bool IsCompressed { get ; set ; }
51
+ public ulong OffsetInBlob { get ; set ; }
52
+ public ulong SizeInBlob { get ; set ; }
53
+ public ulong Size { get ; set ; }
54
+ public ulong Offset { get ; set ; }
55
+ public string ? Config { get ; set ; }
56
+ public ITaskItem Item { get ; }
57
+ public string Name { get ; }
58
+ public byte [ ] NameBytes { get ; }
59
+
60
+ public BlobAssemblyInfo ( ITaskItem item )
61
+ {
62
+ Item = item ;
63
+ Name = Path . GetFileName ( item . ItemSpec ) ;
64
+ NameBytes = LlvmIrComposer . StringToBytes ( Name ) ;
65
+ }
66
+ }
67
+
68
+ sealed class ArchState
69
+ {
70
+ public ulong BlobSize = 0 ;
71
+ public ulong DataSize = 0 ;
72
+ public ulong AssemblyNameLength = 0 ;
73
+ public ulong AssemblyCount = 0 ;
74
+
75
+ public readonly bool Is64Bit ;
76
+ public readonly List < StructureInstance < AssemblyIndexEntry32 > > Index32 = new List < StructureInstance < AssemblyIndexEntry32 > > ( ) ;
77
+ public readonly List < StructureInstance < AssemblyIndexEntry64 > > Index64 = new List < StructureInstance < AssemblyIndexEntry64 > > ( ) ;
78
+ public readonly List < byte [ ] > AssemblyNames = new List < byte [ ] > ( ) ;
79
+ public readonly List < BlobAssemblyInfo > Assemblies ;
80
+
81
+ public ArchState ( List < BlobAssemblyInfo > assemblies , AndroidTargetArch arch )
82
+ {
83
+ Assemblies = assemblies ;
84
+ Is64Bit = arch switch {
85
+ AndroidTargetArch . Arm => false ,
86
+ AndroidTargetArch . X86 => false ,
87
+ AndroidTargetArch . Arm64 => true ,
88
+ AndroidTargetArch . X86_64 => true ,
89
+ _ => throw new NotSupportedException ( $ "Architecture '{ arch } ' is not supported")
90
+ } ;
91
+ }
92
+ }
44
93
}
0 commit comments