Skip to content

Commit

Permalink
fix: make release a default profile
Browse files Browse the repository at this point in the history
Signed-off-by: Lohachov Mykhailo <[email protected]>
  • Loading branch information
aoyako committed Nov 13, 2024
1 parent dc2034e commit dbea8cc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build
run: ./scripts/build_wasm.sh --profile=release
run: ./scripts/build_wasm.sh
- name: Upload all built WASMs
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build wasm libs
run: ./scripts/build_wasm.sh libs
run: ./scripts/build_wasm.sh --profile=deploy libs
- name: Upload wasm libs to reuse in other jobs
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion crates/iroha_wasm_builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ mod internal {
[
"-Z",
"build-std",
// format!("--profile={}", self.profile).as_str(),
"-Z",
"build-std-features=panic_immediate_abort",
"-Z",
Expand Down
8 changes: 3 additions & 5 deletions crates/iroha_wasm_builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use color_eyre::eyre::{eyre, Context};
use iroha_wasm_builder::Builder;
use owo_colors::OwoColorize;

const OPTIMIZED_PROFILE: &str = "deploy";

#[derive(Parser, Debug)]
#[command(name = "iroha_wasm_builder", version, author)]
enum Cli {
Expand All @@ -21,9 +23,6 @@ enum Cli {
Build {
#[command(flatten)]
common: CommonArgs,
/// Optimize WASM output.
#[arg(long)]
optimize: bool,
/// Build profile
#[arg(long, default_value = "release")]
profile: String,
Expand All @@ -50,7 +49,6 @@ fn main() -> color_eyre::Result<()> {
}
Cli::Build {
common: CommonArgs { path },
optimize,
out_file,
profile,
} => {
Expand All @@ -65,7 +63,7 @@ fn main() -> color_eyre::Result<()> {
}
};

let output = if optimize {
let output = if profile == OPTIMIZED_PROFILE {
let sp = if std::env::var("CI").is_err() {
Some(spinoff::Spinner::new_with_stream(
spinoff::spinners::Binary,
Expand Down
17 changes: 2 additions & 15 deletions scripts/build_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e;
DEFAULTS_DIR="defaults"
CARGO_DIR="wasm"
TARGET_DIR="$CARGO_DIR/target/prebuilt"
PROFILE="deploy"
PROFILE="release"
SHOW_HELP=false

main() {
Expand All @@ -25,19 +25,6 @@ main() {
esac
done

case $PROFILE in
"deploy")
OPTIMIZE_FLAG="--optimize"
;;
"release")
OPTIMIZE_FLAG=""
;;
*)
echo "error: unrecognized profile: $PROFILE. Profile can be either [deploy, release]"
exit 1
;;
esac

if $SHOW_HELP; then
print_help
exit 0
Expand Down Expand Up @@ -86,7 +73,7 @@ build() {
mkdir -p "$TARGET_DIR/$1"
for name in ${NAMES[@]}; do
out_file="$TARGET_DIR/$1/$name.wasm"
cargo run --bin iroha_wasm_builder -- build "$CARGO_DIR/$1/$name" $OPTIMIZE_FLAG --profile=$PROFILE --out-file "$out_file"
cargo run --bin iroha_wasm_builder -- build "$CARGO_DIR/$1/$name" --profile=$PROFILE --out-file "$out_file"
done
echo "info: WASM $1 build complete"
echo "artifacts written to $TARGET_DIR/$1/"
Expand Down
4 changes: 2 additions & 2 deletions wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ bash scripts/build_wasm.sh samples
```

## WASM in specific profile
1. Deploy **(default)**
1. Deploy
```bash
bash scripts/build_wasm.sh --profile=deploy
```
2. Release (with debug information)
2. Release (with debug information) **(default)**
```bash
bash scripts/build_wasm.sh --profile=release
```

0 comments on commit dbea8cc

Please sign in to comment.