From c88bf10c37d32f18774cfa3ef480eb77df294565 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sat, 19 Jul 2014 21:54:37 -0700 Subject: rustc: Pass optional additional plugins to compile_input This provides a way for clients of the rustc library to add their own features to the pipeline. --- src/librustc/plugin/load.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/librustc/plugin') diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index 499cffa42aa..4f38c74893e 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -66,10 +66,24 @@ impl<'a> PluginLoader<'a> { } /// Read plugin metadata and dynamically load registrar functions. -pub fn load_plugins(sess: &Session, krate: &ast::Crate) -> Plugins { +pub fn load_plugins(sess: &Session, krate: &ast::Crate, + addl_plugins: Option) -> Plugins { let mut loader = PluginLoader::new(sess); visit::walk_crate(&mut loader, krate, ()); - loader.plugins + + let mut plugins = loader.plugins; + + match addl_plugins { + Some(addl_plugins) => { + // Add in the additional plugins requested by the frontend + let Plugins { macros: addl_macros, registrars: addl_registrars } = addl_plugins; + plugins.macros.push_all_move(addl_macros); + plugins.registrars.push_all_move(addl_registrars); + } + None => () + } + + return plugins; } // note that macros aren't expanded yet, and therefore macros can't add plugins. -- cgit 1.4.1-3-g733a5