Skip to content

Commit d3e51d5

Browse files
committed
move profile into cargo args
1 parent 8e50c65 commit d3e51d5

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

crates/iroha_kagami/src/wasm.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,28 @@ impl<T: Write> RunArgs<T> for Args {
7070
out_file,
7171
profile,
7272
} => {
73+
let (mut cargo_args, mut profile) = (cargo_args, profile);
74+
// if `--profile` is present at both the places, the value from `--cargo-args` is applied.
75+
if let Some(profile_index) = cargo_args
76+
.0
77+
.iter()
78+
.position(|arg| arg.contains("--profile"))
79+
{
80+
let profile_argument = if let Some(v) = cargo_args.0.get(profile_index + 1) {
81+
v.clone()
82+
} else {
83+
// for argument of type `--profile=deploy`
84+
let v = cargo_args.0[profile_index].split('=').collect::<Vec<_>>();
85+
String::from(v[v.len() - 1])
86+
};
87+
88+
profile = match profile_argument.as_str() {
89+
"deploy" => Profile::Deploy,
90+
_ => Profile::Release,
91+
};
92+
93+
cargo_args.0 = Vec::from(&cargo_args.0[0..profile_index]);
94+
}
7395
let builder = Builder::new(&path, profile)
7496
.cargo_args(cargo_args.0)
7597
.show_output();

scripts/build_wasm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ build() {
7777
mkdir -p "$TARGET_DIR/$1"
7878
for name in "${NAMES[@]}"; do
7979
out_file="$TARGET_DIR/$1/$name.wasm"
80-
"${bin_kagami[@]}" wasm build "$CARGO_DIR/$1/$name" --profile="$PROFILE" --out-file "$out_file" --cargo-args="--locked"
80+
"${bin_kagami[@]}" wasm build "$CARGO_DIR/$1/$name" --out-file "$out_file" --cargo-args="--locked --profile ${PROFILE}"
8181
done
8282

8383
echo "profile = \"${PROFILE}\"" > "$TARGET_DIR/build_config.toml"

0 commit comments

Comments
 (0)