Skip to content

Commit 8078ced

Browse files
committed
misc
1 parent 2b6878b commit 8078ced

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

src/dfx/src/lib/builders/motoko.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ fn get_imports(cache: &dyn Cache, info: &MotokoCanisterInfo, imports: &mut Impor
5151
file: &Path,
5252
imports: &mut ImportsTracker,
5353
) -> DfxResult {
54-
if imports.nodes.contains_key(&MotokoImport::Relative(file.to_path_buf())) {
54+
let parent = MotokoImport::Relative(file.to_path_buf());
55+
if imports.nodes.contains_key(&parent) {
5556
return Ok(());
5657
}
58+
imports.nodes.insert(parent.clone(), ());
5759

5860
let mut command = cache.get_binary_command("moc")?;
5961
let command = command.arg("--print-deps").arg(file);
@@ -63,23 +65,17 @@ fn get_imports(cache: &dyn Cache, info: &MotokoCanisterInfo, imports: &mut Impor
6365
let output = String::from_utf8_lossy(&output.stdout);
6466

6567
for line in output.lines() {
66-
let import = MotokoImport::try_from(line).context("Failed to create MotokoImport.")?;
67-
match &import {
68+
let child = MotokoImport::try_from(line).context("Failed to create MotokoImport.")?;
69+
// TODO: The code seems screwed: Why recompile onluy on `Relative`?
70+
match &child {
6871
MotokoImport::Relative(path) => {
69-
if !imports.nodes.contains_key(&import) { // Don't look up already looked up dependencies
70-
imports.nodes.insert(&import, ());
71-
get_imports_recursive(cache, path.as_path(), imports)?;
72-
}
73-
}
74-
_ => {
75-
let parent = MotokoImport::Relative(file.to_path_buf());
76-
// imports.insert(parent);
77-
78-
let parent_node = imports.graph.add_node(parent);
79-
let child_node = imports.graph.add_node(import);
80-
imports.graph.add_edge(parent_node, child_node, ());
72+
get_imports_recursive(cache, path.as_path(), imports)?;
8173
}
74+
_ => {}
8275
}
76+
let parent_node = imports.graph.add_node(parent.clone());
77+
let child_node = imports.graph.add_node(child);
78+
imports.graph.add_edge(parent_node, child_node, ());
8379
}
8480

8581
Ok(())

src/dfx/src/lib/models/canister.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ fn check_valid_subtype(compiled_idl_path: &Path, specified_idl_path: &Path) -> D
436436
}
437437

438438
/// TODO: Motoko-specific code not here
439-
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
439+
#[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq, Hash)]
440440
pub enum MotokoImport {
441441
Canister(String),
442442
Ic(String),

0 commit comments

Comments
 (0)