@@ -61,11 +61,14 @@ public string GenerateXCode(
61
61
string ? nativeMainSource = null )
62
62
{
63
63
// bundle everything as resources excluding native files
64
- var excludes = new List < string > { ".dll.o" , ".dll.s" , ".dwarf" , ".m" , ".h" , ".a" , ".bc" , "libmonosgen-2.0.dylib" , " libcoreclr.dylib" } ;
64
+ var excludes = new List < string > { ".dll.o" , ".dll.s" , ".dwarf" , ".m" , ".h" , ".a" , ".bc" , "libcoreclr.dylib" } ;
65
65
if ( stripDebugSymbols )
66
66
{
67
67
excludes . Add ( ".pdb" ) ;
68
68
}
69
+ if ( ! preferDylibs ) {
70
+ excludes . Add ( "libmonosgen-2.0.dylib" ) ;
71
+ }
69
72
70
73
string [ ] resources = Directory . GetFileSystemEntries ( workspace , "" , SearchOption . TopDirectoryOnly )
71
74
. Where ( f => ! excludes . Any ( e => f . EndsWith ( e , StringComparison . InvariantCultureIgnoreCase ) ) )
@@ -110,46 +113,48 @@ public string GenerateXCode(
110
113
string toLink = "" ;
111
114
112
115
string [ ] allComponentLibs = Directory . GetFiles ( workspace , "libmono-component-*-static.a" ) ;
113
- string [ ] staticComponentStubLibs = Directory . GetFiles ( workspace , "libmono-component-*-stub-static.a" ) ;
114
- bool staticLinkAllComponents = false ;
115
- string [ ] staticLinkedComponents = Array . Empty < string > ( ) ;
116
-
117
- if ( ! string . IsNullOrEmpty ( runtimeComponents ) && runtimeComponents . Equals ( "*" , StringComparison . OrdinalIgnoreCase ) )
118
- staticLinkAllComponents = true ;
119
- else if ( ! string . IsNullOrEmpty ( runtimeComponents ) )
120
- staticLinkedComponents = runtimeComponents . Split ( ";" ) ;
121
-
122
- // by default, component stubs will be linked and depending on how mono runtime has been build,
123
- // stubs can disable or dynamic load components.
124
- foreach ( string staticComponentStubLib in staticComponentStubLibs )
125
- {
126
- string componentLibToLink = staticComponentStubLib ;
127
- if ( staticLinkAllComponents )
128
- {
129
- // static link component.
130
- componentLibToLink = componentLibToLink . Replace ( "-stub-static.a" , "-static.a" , StringComparison . OrdinalIgnoreCase ) ;
131
- }
132
- else
116
+ if ( ! preferDylibs ) {
117
+ string [ ] staticComponentStubLibs = Directory . GetFiles ( workspace , "libmono-component-*-stub-static.a" ) ;
118
+ bool staticLinkAllComponents = false ;
119
+ string [ ] staticLinkedComponents = Array . Empty < string > ( ) ;
120
+
121
+ if ( ! string . IsNullOrEmpty ( runtimeComponents ) && runtimeComponents . Equals ( "*" , StringComparison . OrdinalIgnoreCase ) )
122
+ staticLinkAllComponents = true ;
123
+ else if ( ! string . IsNullOrEmpty ( runtimeComponents ) )
124
+ staticLinkedComponents = runtimeComponents . Split ( ";" ) ;
125
+
126
+ // by default, component stubs will be linked and depending on how mono runtime has been build,
127
+ // stubs can disable or dynamic load components.
128
+ foreach ( string staticComponentStubLib in staticComponentStubLibs )
133
129
{
134
- foreach ( string staticLinkedComponent in staticLinkedComponents )
130
+ string componentLibToLink = staticComponentStubLib ;
131
+ if ( staticLinkAllComponents )
132
+ {
133
+ // static link component.
134
+ componentLibToLink = componentLibToLink . Replace ( "-stub-static.a" , "-static.a" , StringComparison . OrdinalIgnoreCase ) ;
135
+ }
136
+ else
135
137
{
136
- if ( componentLibToLink . Contains ( staticLinkedComponent , StringComparison . OrdinalIgnoreCase ) )
138
+ foreach ( string staticLinkedComponent in staticLinkedComponents )
137
139
{
138
- // static link component.
139
- componentLibToLink = componentLibToLink . Replace ( "-stub-static.a" , "-static.a" , StringComparison . OrdinalIgnoreCase ) ;
140
- break ;
140
+ if ( componentLibToLink . Contains ( staticLinkedComponent , StringComparison . OrdinalIgnoreCase ) )
141
+ {
142
+ // static link component.
143
+ componentLibToLink = componentLibToLink . Replace ( "-stub-static.a" , "-static.a" , StringComparison . OrdinalIgnoreCase ) ;
144
+ break ;
145
+ }
141
146
}
142
147
}
143
- }
144
148
145
- // if lib doesn't exist (primarly due to runtime build without static lib support), fallback linking stub lib.
146
- if ( ! File . Exists ( componentLibToLink ) )
147
- {
148
- Utils . LogInfo ( $ "\n Couldn't find static component library: { componentLibToLink } , linking static component stub library: { staticComponentStubLib } .\n ") ;
149
- componentLibToLink = staticComponentStubLib ;
150
- }
149
+ // if lib doesn't exist (primarly due to runtime build without static lib support), fallback linking stub lib.
150
+ if ( ! File . Exists ( componentLibToLink ) )
151
+ {
152
+ Utils . LogInfo ( $ "\n Couldn't find static component library: { componentLibToLink } , linking static component stub library: { staticComponentStubLib } .\n ") ;
153
+ componentLibToLink = staticComponentStubLib ;
154
+ }
151
155
152
- toLink += $ " \" -force_load { componentLibToLink } \" { Environment . NewLine } ";
156
+ toLink += $ " \" -force_load { componentLibToLink } \" { Environment . NewLine } ";
157
+ }
153
158
}
154
159
155
160
string [ ] dylibs = Directory . GetFiles ( workspace , "*.dylib" ) ;
@@ -161,7 +166,7 @@ public string GenerateXCode(
161
166
162
167
string libName = Path . GetFileNameWithoutExtension ( lib ) ;
163
168
// libmono must always be statically linked, for other librarires we can use dylibs
164
- bool dylibExists = libName != "libmonosgen-2.0" && dylibs . Any ( dylib => Path . GetFileName ( dylib ) == libName + ".dylib" ) ;
169
+ bool dylibExists = /* libName != "libmonosgen-2.0" &&*/ dylibs . Any ( dylib => Path . GetFileName ( dylib ) == libName + ".dylib" ) ;
165
170
166
171
if ( forceAOT || ! ( preferDylibs && dylibExists ) )
167
172
{
0 commit comments