-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proc macro server: Load
ProcMacroHost
commit-id:819109f5
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,54 @@ | ||
use anyhow::Result; | ||
use scarb::core::Config; | ||
use scarb::{ | ||
compiler::{plugin::proc_macro::ProcMacroHost, CairoCompilationUnit, CompilationUnit}, | ||
core::{Config, Workspace}, | ||
ops::{self, FeaturesOpts, FeaturesSelector}, | ||
}; | ||
|
||
#[tracing::instrument(skip_all, level = "info")] | ||
pub fn run(_config: &Config) -> Result<()> { | ||
unimplemented!() | ||
pub fn run(config: &mut Config) -> Result<()> { | ||
let ws = ops::read_workspace(config.manifest_path(), config)?; | ||
let resolve = ops::resolve_workspace(&ws)?; | ||
let compilation_units = ops::generate_compilation_units( | ||
&resolve, | ||
&FeaturesOpts { | ||
features: FeaturesSelector::AllFeatures, | ||
no_default_features: false, | ||
}, | ||
&ws, | ||
)?; | ||
|
||
// Compile procedural macros only. | ||
for unit in &compilation_units { | ||
if let CompilationUnit::ProcMacro(_) = unit { | ||
ops::compile_unit(unit.clone(), &ws)?; | ||
} | ||
} | ||
|
||
let mut proc_macros = ProcMacroHost::default(); | ||
|
||
// Load previously compiled procedural macros. | ||
for unit in compilation_units { | ||
if let CompilationUnit::Cairo(unit) = unit { | ||
load_plugins(unit, &ws, &mut proc_macros)?; | ||
} | ||
} | ||
|
||
ops::start_proc_macro_server(proc_macros) | ||
} | ||
|
||
fn load_plugins( | ||
unit: CairoCompilationUnit, | ||
ws: &Workspace<'_>, | ||
proc_macros: &mut ProcMacroHost, | ||
) -> Result<()> { | ||
for plugin_info in unit | ||
.cairo_plugins | ||
.into_iter() | ||
.filter(|plugin_info| !plugin_info.builtin) | ||
{ | ||
proc_macros.register(plugin_info.package, ws.config())?; | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::compiler::plugin::proc_macro::ProcMacroHost; | ||
use anyhow::Result; | ||
|
||
pub fn start_proc_macro_server(proc_macros: ProcMacroHost) -> Result<()> { | ||
unimplemented!() | ||
} |