@@ -7,6 +7,8 @@ use cairo_lang_filesystem::cfg::CfgSet;
7
7
use cairo_lang_filesystem:: db:: {
8
8
CrateSettings , DependencySettings , Edition , ExperimentalFeaturesConfig ,
9
9
} ;
10
+ use cairo_lang_semantic:: inline_macros:: get_default_plugin_suite;
11
+ use cairo_lang_semantic:: plugin:: PluginSuite ;
10
12
use itertools:: Itertools ;
11
13
use scarb_metadata:: {
12
14
CompilationUnitComponentDependencyMetadata , CompilationUnitComponentId , Metadata ,
@@ -15,6 +17,7 @@ use scarb_metadata::{
15
17
use smol_str:: ToSmolStr ;
16
18
use tracing:: { debug, error, warn} ;
17
19
20
+ use super :: builtin_plugins:: BuiltinPlugin ;
18
21
use super :: manifest_registry:: member_config:: MemberConfig ;
19
22
use crate :: lang:: db:: AnalysisDatabase ;
20
23
use crate :: project:: crate_data:: Crate ;
@@ -64,6 +67,16 @@ pub fn extract_crates(metadata: &Metadata) -> Vec<Crate> {
64
67
}
65
68
66
69
for component in & compilation_unit. components {
70
+ // Plugin components don't have crates associated with them.
71
+ if component
72
+ . id
73
+ . as_ref ( )
74
+ . and_then ( |component_id| metadata. get_plugin ( component_id) )
75
+ . is_some ( )
76
+ {
77
+ continue ;
78
+ }
79
+
67
80
let crate_name = component. name . as_str ( ) ;
68
81
let Some ( component_id) = component. id . clone ( ) else {
69
82
error ! ( "id of component {crate_name} was None in metadata" ) ;
@@ -180,12 +193,36 @@ pub fn extract_crates(metadata: &Metadata) -> Vec<Crate> {
180
193
181
194
let custom_main_file_stems = ( file_stem != "lib" ) . then_some ( vec ! [ file_stem. into( ) ] ) ;
182
195
196
+ let plugin_dependencies = package
197
+ . and_then ( |package| metadata. get_package_plugin_dependencies ( & package. id ) )
198
+ . unwrap_or_default ( ) ;
199
+
200
+ let plugins = plugin_dependencies
201
+ . into_iter ( )
202
+ . filter_map ( |plugin_metadata| {
203
+ let is_builtin = metadata. is_builtin ( plugin_metadata) ;
204
+ if !is_builtin. unwrap_or_default ( ) {
205
+ return None ;
206
+ }
207
+
208
+ let builtin_plugin = BuiltinPlugin :: try_new ( plugin_metadata) ;
209
+ Some ( builtin_plugin?. suite ( ) )
210
+ } )
211
+ . chain ( [ get_default_plugin_suite ( ) ] . into_iter ( ) )
212
+ . fold ( PluginSuite :: default ( ) , |mut acc, suite| {
213
+ acc. add ( suite) ;
214
+ acc
215
+ } ) ;
216
+
217
+ debug ! ( "Plugins for {}: {:#?}" , package. unwrap( ) . id. repr, plugins) ;
218
+
183
219
let cr = Crate {
184
220
name : crate_name. into ( ) ,
185
221
discriminator : component. discriminator . as_ref ( ) . map ( ToSmolStr :: to_smolstr) ,
186
222
root : root. into ( ) ,
187
223
custom_main_file_stems,
188
224
settings,
225
+ plugins,
189
226
} ;
190
227
191
228
if compilation_unit. package == component. package {
@@ -237,6 +274,8 @@ pub fn extract_crates(metadata: &Metadata) -> Vec<Crate> {
237
274
let name = first_crate. name . clone ( ) ;
238
275
let discriminator = first_crate. discriminator . clone ( ) ;
239
276
277
+ let plugins = first_crate. plugins . clone ( ) ;
278
+
240
279
let custom_main_file_stems =
241
280
crs. into_iter ( ) . flat_map ( |cr| cr. custom_main_file_stems . unwrap ( ) ) . collect ( ) ;
242
281
@@ -246,6 +285,7 @@ pub fn extract_crates(metadata: &Metadata) -> Vec<Crate> {
246
285
root,
247
286
custom_main_file_stems : Some ( custom_main_file_stems) ,
248
287
settings,
288
+ plugins,
249
289
} ) ;
250
290
}
251
291
0 commit comments