-
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.
- Loading branch information
1 parent
7b11ab7
commit 25b9be8
Showing
7 changed files
with
80 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,44 @@ | ||
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::{Context, Result}; | ||
use cairo_lang_compiler::db::RootDatabase; | ||
use cairo_lang_executable::executable::Executable; | ||
|
||
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 executable = Executable::new( | ||
cairo_lang_executable::compile::compile_executable_in_prepared_db( | ||
db, | ||
None, | ||
main_crate_ids, | ||
compiler_config.diagnostics_reporter, | ||
) | ||
.with_context(|| format!("Failed to compile executable"))?, | ||
); | ||
|
||
write_json( | ||
format!("{}.executable.json", unit.main_component().target_name()).as_str(), | ||
"output file", | ||
&target_dir, | ||
ws, | ||
&executable, | ||
)?; | ||
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
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