-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
104 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::compiler::helpers::write_json; | ||
use crate::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; | ||
use crate::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; | ||
use crate::core::{TargetKind, Workspace}; | ||
use anyhow::Result; | ||
use cairo_lang_compiler::db::RootDatabase; | ||
use cairo_lang_executable::executable::Executable; | ||
use tracing::trace_span; | ||
|
||
pub struct ExecutableCompiler; | ||
|
||
impl Compiler for ExecutableCompiler { | ||
fn target_kind(&self) -> TargetKind { | ||
TargetKind::EXECUTABLE.clone() | ||
} | ||
|
||
fn compile( | ||
&self, | ||
unit: CairoCompilationUnit, | ||
db: &mut RootDatabase, | ||
ws: &Workspace<'_>, | ||
) -> Result<()> { | ||
let target_dir = unit.target_dir(ws); | ||
let main_crate_ids = collect_main_crate_ids(&unit, db); | ||
let compiler_config = build_compiler_config(db, &unit, &main_crate_ids, ws); | ||
let span = trace_span!("compile_executable"); | ||
let executable = { | ||
let _guard = span.enter(); | ||
Executable::new( | ||
cairo_lang_executable::compile::compile_executable_in_prepared_db( | ||
db, | ||
None, | ||
main_crate_ids, | ||
compiler_config.diagnostics_reporter, | ||
)?, | ||
) | ||
}; | ||
|
||
write_json( | ||
format!("{}.executable.json", unit.main_component().target_name()).as_str(), | ||
"output file", | ||
&target_dir, | ||
ws, | ||
&executable, | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
pub use executable::*; | ||
pub use lib::*; | ||
pub use starknet_contract::*; | ||
pub use test::*; | ||
|
||
mod executable; | ||
mod lib; | ||
mod starknet_contract; | ||
mod test; |
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
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
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