Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vporton committed Jan 29, 2025
1 parent 7b4050f commit 4f21c99
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/dfx/src/commands/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ pub fn exec(env1: &dyn Environment, opts: RulesOpts) -> DfxResult {
} else {
output_file.write_fmt(format_args!(
"{}: {}\n",
make_target(graph, edge.source()),
make_target(graph, edge.target()),
make_target(graph, edge.source())?,
make_target(graph, edge.target())?,
))?;
}
}
for node in graph0.nodes() {
// TODO: `node.1` is a hack.
let command = get_build_command(graph, *node.1);
if let Some(command) = command {
output_file.write_fmt(format_args!("{}:\n\t{}\n\n", make_target(graph, *node.1), command))?;
output_file.write_fmt(format_args!("{}:\n\t{}\n\n", make_target(graph, *node.1)?, command))?;
}
if let Import::Canister(canister_name) = node.0 {
output_file.write_fmt(format_args!("\ndeploy@{}: canister@{}\n", canister_name, canister_name))?;
Expand All @@ -181,19 +181,19 @@ pub fn exec(env1: &dyn Environment, opts: RulesOpts) -> DfxResult {
Ok(())
}

fn make_target(graph: &Graph<Import, ()>, node_id: <Graph<Import, ()> as GraphBase>::NodeId) -> String {
fn make_target(graph: &Graph<Import, ()>, node_id: <Graph<Import, ()> as GraphBase>::NodeId) -> DfxResult<String> {
let node_value = graph.node_weight(node_id).unwrap();
match node_value {
Ok(match node_value {
Import::Canister(canister_name) => {
// duplicate code
let path1 = format!("$(ROOT_DIR)/.dfx/local/canisters/{}/{}.wasm", canister_name, canister_name);
let path2 = format!("$(ROOT_DIR)/.dfx/local/canisters/{}/{}.did", canister_name, canister_name);
format!("{} {}", path1, path2)
}
Import::FullPath(path) => format!("$(ROOT_DIR)/{}", path.to_str().unwrap().to_owned()), // FIXME: `unwrap`
Import::FullPath(path) => format!("$(ROOT_DIR)/{}", path.to_str().unwrap_or("<unknown>").to_owned()), // TODO: <unknown> is a hack
Import::Ic(principal_str) => format!("ic:{}", principal_str),
Import::Lib(_path) => "".to_string(),
}
})
}

fn get_build_command(graph: &Graph<Import, ()>, node_id: <Graph<Import, ()> as GraphBase>::NodeId) -> Option<String> {
Expand Down

0 comments on commit 4f21c99

Please sign in to comment.