Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions e2e/assets/custom_canister/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
echo CUSTOM_CANISTER2_BUILD_DONE
6 changes: 6 additions & 0 deletions e2e/assets/custom_canister/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"candid": "main.did",
"wasm": "main.wasm",
"build": "echo CUSTOM_CANISTER_BUILD_DONE"
},
"custom2": {
"type": "custom",
"candid": "main.did",
"wasm": "main.wasm",
"build": "build.sh"
}
},
"defaults": {
Expand Down
5 changes: 4 additions & 1 deletion e2e/tests-dfx/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ teardown() {
install_asset custom_canister
dfx_start
dfx canister create --all
assert_command dfx build
assert_command dfx build custom
assert_match "CUSTOM_CANISTER_BUILD_DONE"
assert_command dfx build custom2
assert_match "CUSTOM_CANISTER2_BUILD_DONE"

dfx canister install --all
assert_command dfx canister call custom fromQuery
assert_command dfx canister call custom2 fromQuery
}

@test "build succeeds with network parameter" {
Expand Down
16 changes: 12 additions & 4 deletions src/dfx/src/lib/builders/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use ic_types::principal::Principal as CanisterId;
use serde::Deserialize;
use slog::info;
use slog::Logger;
use std::path::PathBuf;
use std::process::Stdio;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

/// Set of extras that can be specified in the dfx.json.
struct CustomBuilderExtra {
Expand Down Expand Up @@ -189,8 +189,16 @@ impl CanisterBuilder for CustomBuilder {

fn run_command(args: Vec<String>, vars: &[super::Env<'_>]) -> DfxResult<()> {
let (command_name, arguments) = args.split_first().unwrap();

let mut cmd = std::process::Command::new(command_name);
let command_path = Path::new(command_name);
Comment thread
adamspofford-dfinity marked this conversation as resolved.
Outdated
let mut cmd = if arguments.is_empty()
&& command_path.components().count() == 1
Comment thread
adamspofford-dfinity marked this conversation as resolved.
Outdated
&& command_path.exists()
{
// handle "command.sh" with no ./
Command::new(format!("./{command_name}"))
} else {
Command::new(command_name)
};
Comment thread
adamspofford-dfinity marked this conversation as resolved.
Outdated

cmd.args(arguments)
.stdout(Stdio::inherit())
Expand Down