@@ -7,6 +7,14 @@ namespace Xamarin.Android.Tasks;
7
7
8
8
class NativeRuntimeComponents
9
9
{
10
+ public sealed class KnownSets
11
+ {
12
+ public const string BCL = "bcl" ;
13
+ public const string CoreClrRuntime = "coreclr" ;
14
+ public const string CplusPlusRuntime = "c++" ;
15
+ public const string XamarinAndroidRuntime = "xaruntime" ;
16
+ }
17
+
10
18
internal class Archive
11
19
{
12
20
public readonly string Name ;
@@ -15,13 +23,16 @@ internal class Archive
15
23
public readonly bool WholeArchive ;
16
24
public bool DontExportSymbols { get ; set ; }
17
25
public HashSet < string > ? SymbolsToPreserve { get ; set ; }
26
+ public string SetName { get ; }
27
+
18
28
public readonly bool NeedsClrHack ;
19
29
20
30
Func < Archive , bool > shouldInclude ;
21
31
22
- public Archive ( string name , Func < Archive , bool > ? include = null , bool wholeArchive = false , string ? jniOnLoadName = null , bool needsClrHack = false )
32
+ public Archive ( string name , string setName , Func < Archive , bool > ? include = null , bool wholeArchive = false , string ? jniOnLoadName = null , bool needsClrHack = false )
23
33
{
24
34
Name = name ;
35
+ SetName = setName ;
25
36
shouldInclude = include == null ? ( ( Archive arch ) => true ) : include ;
26
37
WholeArchive = wholeArchive ;
27
38
JniOnLoadName = jniOnLoadName ;
@@ -32,21 +43,39 @@ public Archive (string name, Func<Archive, bool>? include = null, bool wholeArch
32
43
sealed class ClangBuiltinsArchive : Archive
33
44
{
34
45
public ClangBuiltinsArchive ( string clangAbi )
35
- : base ( $ "libclang_rt.builtins-{ clangAbi } -android.a")
46
+ : base ( $ "libclang_rt.builtins-{ clangAbi } -android.a", KnownSets . CplusPlusRuntime )
36
47
{ }
37
48
}
38
49
39
50
class AndroidArchive : Archive
40
51
{
41
52
public AndroidArchive ( string name , bool wholeArchive = false )
42
- : base ( name , wholeArchive : wholeArchive )
53
+ : base ( name , KnownSets . XamarinAndroidRuntime , wholeArchive : wholeArchive )
43
54
{ }
44
55
}
45
56
46
57
sealed class BclArchive : Archive
47
58
{
48
59
public BclArchive ( string name , bool wholeArchive = false , string ? jniOnLoadName = null )
49
- : base ( name , wholeArchive : wholeArchive , jniOnLoadName : jniOnLoadName , needsClrHack : true )
60
+ : base ( name , KnownSets . BCL , wholeArchive : wholeArchive , jniOnLoadName : jniOnLoadName , needsClrHack : true )
61
+ {
62
+ DontExportSymbols = true ;
63
+ }
64
+ }
65
+
66
+ sealed class ClrArchive : Archive
67
+ {
68
+ public ClrArchive ( string name , bool wholeArchive = false )
69
+ : base ( name , KnownSets . CoreClrRuntime , wholeArchive : wholeArchive , needsClrHack : true )
70
+ {
71
+ DontExportSymbols = true ;
72
+ }
73
+ }
74
+
75
+ sealed class CplusPlusArchive : Archive
76
+ {
77
+ public CplusPlusArchive ( string name )
78
+ : base ( name , KnownSets . CplusPlusRuntime )
50
79
{
51
80
DontExportSymbols = true ;
52
81
}
@@ -59,36 +88,21 @@ public BclArchive (string name, bool wholeArchive = false, string? jniOnLoadName
59
88
public readonly List < string > LinkStartFiles ;
60
89
public readonly List < string > LinkEndFiles ;
61
90
62
- // LINK_LIBRARIES = pal/src/eventprovider/dummyprovider/libeventprovider.a -llog nativeresources/libnativeresourcestring.a shared_minipal/libminipal.a -ldl -latomic -lm
63
91
public NativeRuntimeComponents ( ITaskItem [ ] monoComponents )
64
92
{
65
93
this . monoComponents = monoComponents ;
66
94
KnownArchives = new ( ) {
67
95
// CoreCLR runtime + BCL
68
- new Archive ( "libcoreclr.a" , needsClrHack : true ) {
69
- DontExportSymbols = true ,
70
- } ,
71
- new Archive ( "libcoreclrminipal.a" , needsClrHack : true ) {
72
- DontExportSymbols = true ,
73
- } ,
74
- new Archive ( "libgc_pal.a" , needsClrHack : true ) {
75
- DontExportSymbols = true ,
76
- } ,
77
- new Archive ( "libcoreclrpal.a" , wholeArchive : true , needsClrHack : true ) {
78
- DontExportSymbols = true ,
79
- } ,
80
- new Archive ( "libeventprovider.a" , needsClrHack : true ) {
81
- DontExportSymbols = true ,
82
- } ,
83
- new Archive ( "libnativeresourcestring.a" , needsClrHack : true ) {
84
- DontExportSymbols = true ,
85
- } ,
86
- new Archive ( "libminipal.a" , needsClrHack : true ) {
87
- DontExportSymbols = true ,
88
- } ,
89
- new Archive ( "libbrotlicommon.a" , needsClrHack : true ) ,
90
- new Archive ( "libbrotlidec.a" , needsClrHack : true ) ,
91
- new Archive ( "libbrotlienc.a" , needsClrHack : true ) ,
96
+ new ClrArchive ( "libcoreclr.a" ) ,
97
+ new ClrArchive ( "libcoreclrminipal.a" ) ,
98
+ new ClrArchive ( "libgc_pal.a" ) ,
99
+ new ClrArchive ( "libcoreclrpal.a" , wholeArchive : true ) ,
100
+ new ClrArchive ( "libeventprovider.a" ) ,
101
+ new ClrArchive ( "libnativeresourcestring.a" ) ,
102
+ new ClrArchive ( "libminipal.a" ) ,
103
+ new ClrArchive ( "libbrotlicommon.a" ) ,
104
+ new ClrArchive ( "libbrotlidec.a" ) ,
105
+ new ClrArchive ( "libbrotlienc.a" ) ,
92
106
93
107
new BclArchive ( "libSystem.Globalization.Native.a" ) ,
94
108
new BclArchive ( "libSystem.IO.Compression.Native.a" ) ,
@@ -121,23 +135,17 @@ public NativeRuntimeComponents (ITaskItem[] monoComponents)
121
135
new AndroidArchive ( "libxa-shared-bits-release.a" ) ,
122
136
new AndroidArchive ( "libxamarin-startup-release.a" ) ,
123
137
138
+ // C++ standard library
139
+ new CplusPlusArchive ( "libc++_static.a" ) ,
140
+ new CplusPlusArchive ( "libc++abi.a" ) ,
141
+
124
142
// LLVM clang built-ins archives
125
143
new ClangBuiltinsArchive ( "aarch64" ) ,
126
144
new ClangBuiltinsArchive ( "arm" ) ,
127
145
new ClangBuiltinsArchive ( "i686" ) ,
128
146
new ClangBuiltinsArchive ( "x86_64" ) ,
129
147
130
- // C++ standard library
131
- new Archive ( "libc++_static.a" ) {
132
- DontExportSymbols = true ,
133
- } ,
134
- new Archive ( "libc++abi.a" ) {
135
- DontExportSymbols = true ,
136
- } ,
137
-
138
- new Archive ( "libunwind.a" ) {
139
- DontExportSymbols = true ,
140
- } ,
148
+ new CplusPlusArchive ( "libunwind.a" ) , // techically it's from clang
141
149
} ;
142
150
143
151
// Just the base names of libraries to link into the unified runtime. Must have all the dependencies of all the static archives we
0 commit comments