Skip to content

Commit

Permalink
tweak makefile to generate asset package
Browse files Browse the repository at this point in the history
  • Loading branch information
artifex11 committed Aug 25, 2023
1 parent 8753b50 commit 8a647da
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
28 changes: 17 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
PROJECT := $(shell sed -n '0,/name\s*=\s*"\(.*\)"/s/name\s*=\s*"\(.*\)"/\1/p' Cargo.toml)
VERSION := $(shell sed -n '0,/version\s*=\s*"\(.*\)"/s/version\s*=\s*"\(.*\)"/\1/p' Cargo.toml)
FLAGS := RUSTFLAGS="$(RUSTFLAGS) --remap-path-prefix $(HOME)= -C link-args=-zstack-size=65536"
WASM := "target/wasm32-unknown-unknown/release/$(shell sed -n '0,/name\s*=\s*"\(.*\)"/s/name\s*=\s*"\(.*\)"/\1/p' Cargo.toml | sed 's/-/_/g').wasm"
NPM_WASM := "mod.wasm"
PACKAGE := "assets/$(PROJECT)-$(VERSION).wasm"

help: ## Display this help screen
@grep -h \
-E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
Expand All @@ -7,16 +14,15 @@ test: wasm ## Run the wasmer tests
@cargo test

wasm: ## Build the WASM files
@RUSTFLAGS="$(RUSTFLAGS) --remap-path-prefix $(HOME)= -C link-args=-zstack-size=65536" \
cargo build \
--release \
--color=always \
-Z build-std=core,alloc,panic_abort \
-Z build-std-features=panic_immediate_abort \
--target wasm32-unknown-unknown
@$(FLAGS) cargo build --release \
--target wasm32-unknown-unknown \
--color=always \
-Z build-std=core,alloc,panic_abort \
-Z build-std-features=panic_immediate_abort

package: ## Prepare the WASM npm package
wasm-opt -O4 target/wasm32-unknown-unknown/release/dusk_wallet_core.wasm \
-o mod.wasm
package: wasm ## Prepare the WASM package
@wasm-opt -O3 $(WASM) -o $(NPM_WASM)
@cp $(NPM_WASM) $(PACKAGE)
@echo "Package created: $(PACKAGE)"

.PHONY: test wasm help
.PHONY: test wasm package help
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

A library for generating and dealing with transactions.

## Requirements

To generate packages, we use [binaryen](https://github.com/WebAssembly/binaryen).

## Build

To build and test the crate:
Expand Down
5 changes: 3 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

#![allow(missing_docs)]

use alloc::vec::Vec;
use alloc::string::String;
use serde::{Serialize, Deserialize};#[doc = " The arguments of the balance function"]
use alloc::vec::Vec;
use serde::{Deserialize, Serialize};
#[doc = " The arguments of the balance function"]
#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct BalanceArgs {
#[doc = " A rkyv serialized [Vec<phoenix_core::Note>]; all notes should have their keys derived from "]
Expand Down

0 comments on commit 8a647da

Please sign in to comment.