Skip to content

Commit d7df92b

Browse files
authored
feat/fe cli interface (argotorg#732)
1 parent a761022 commit d7df92b

12 files changed

Lines changed: 541 additions & 304 deletions

File tree

Cargo.lock

Lines changed: 71 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/driver/src/lib.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ pub struct CompiledContract {
3535
#[derive(Debug)]
3636
pub struct CompileError(pub Vec<Diagnostic>);
3737

38+
pub fn check_single_file(db: &mut Db, path: &str, src: &str) -> Vec<Diagnostic> {
39+
let module = ModuleId::new_standalone(db, path, src);
40+
module.diagnostics(db)
41+
}
42+
3843
pub fn compile_single_file(
3944
db: &mut Db,
4045
path: &str,
@@ -43,15 +48,37 @@ pub fn compile_single_file(
4348
optimize: bool,
4449
) -> Result<CompiledModule, CompileError> {
4550
let module = ModuleId::new_standalone(db, path, src);
46-
4751
let diags = module.diagnostics(db);
52+
4853
if diags.is_empty() {
4954
compile_module_id(db, module, with_bytecode, optimize)
5055
} else {
5156
Err(CompileError(diags))
5257
}
5358
}
5459

60+
// Run analysis with ingot
61+
// Return vector error,waring...
62+
pub fn check_ingot(
63+
db: &mut Db,
64+
name: &str,
65+
files: &[(impl AsRef<str>, impl AsRef<str>)],
66+
) -> Vec<Diagnostic> {
67+
let std = IngotId::std_lib(db);
68+
let ingot = IngotId::from_files(
69+
db,
70+
name,
71+
IngotMode::Main,
72+
FileKind::Local,
73+
files,
74+
indexmap! { "std".into() => std },
75+
);
76+
77+
let mut diags = ingot.diagnostics(db);
78+
ingot.sink_external_ingot_diagnostics(db, &mut diags);
79+
diags
80+
}
81+
5582
/// Compiles the main module of a project.
5683
///
5784
/// If `with_bytecode` is set to false, the compiler will skip the final Yul ->

crates/fe/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ version = "0.18.0-alpha"
1414
solc-backend = ["fe-driver/solc-backend"]
1515

1616
[dependencies]
17-
clap = "2.33.3"
17+
clap = {version="3.1.18", features = ["derive"]}
18+
fs_extra = "1.2.0"
1819
walkdir = "2"
1920
indexmap = "1.6.2"
21+
include_dir = "0.7.2"
2022

2123
fe-common = {path = "../common", version = "^0.18.0-alpha"}
2224
fe-driver = {path = "../driver", version = "^0.18.0-alpha"}

0 commit comments

Comments
 (0)