Skip to content

Commit

Permalink
build: Set up Cargo Make for project build orchestration
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Dec 10, 2024
1 parent fb1a753 commit f0ff3ef
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 9 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/dioxus-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Install cargo-make
uses: actions-rs/cargo@v1
with:
command: install
args: --force cargo-make

- name: Cache cargo registry
uses: actions/cache@v3
Expand All @@ -37,10 +43,6 @@ jobs:
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build Room Contract
run: |
cd contracts/room-contract
cargo build --release --target wasm32-unknown-unknown -p room-contract
- name: Cache Dioxus CLI
uses: actions/cache@v3
with:
Expand All @@ -50,7 +52,5 @@ jobs:
- name: Install Dioxus CLI
run: cargo install dioxus-cli --force

- name: Build Dioxus Project
run: |
cd ui
dx build
- name: Build Project
run: cargo make build
51 changes: 51 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[config]
skip_core_tasks = true
default_to_workspace = false

[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["contracts/room-contract", "ui"]
CONTRACT_TARGET = "wasm32-unknown-unknown"
CONTRACT_NAME = "room_contract"
CONTRACTS_DIR = "ui/public/contracts"

[tasks.clean]
description = "Clean build artifacts"
command = "cargo"
args = ["clean"]

[tasks.build-contract]
description = "Build the room contract WASM"
command = "cargo"
args = ["build", "--release", "--target", "${CONTRACT_TARGET}", "-p", "room-contract"]

[tasks.create-contracts-dir]
description = "Ensure contracts directory exists"
script = [
"mkdir -p ${CONTRACTS_DIR}",
]

[tasks.copy-contract]
description = "Copy contract WASM to UI public directory"
dependencies = ["build-contract", "create-contracts-dir"]
script = [
"cp target/${CONTRACT_TARGET}/release/${CONTRACT_NAME}.wasm ${CONTRACTS_DIR}/"
]

[tasks.build-ui]
description = "Build the Dioxus UI"
dependencies = ["copy-contract"]
command = "dx"
args = ["build"]
cwd = "./ui"

[tasks.build]
description = "Build everything"
dependencies = ["build-ui"]

[tasks.dev]
description = "Development build"
dependencies = ["copy-contract"]
command = "dx"
args = ["serve"]
cwd = "./ui"
2 changes: 1 addition & 1 deletion ui/src/constants.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub const KEY_VERSION_PREFIX: &str = "river:v1:user:vk:";

// TODO: Should be built as a dependency with cargo build --release --target wasm32-unknown-unknown -p room-contract
pub const ROOM_CONTRACT_WASM: &[u8] = include_bytes!("../../target/wasm32-unknown-unknown/release/room_contract.wasm");
pub const ROOM_CONTRACT_WASM: &[u8] = include_bytes!("../public/contracts/room_contract.wasm");

// pub const ROOM_CONTRACT_CODE_HASH: CodeHash = CodeHash::from_code(ROOM_CONTRACT_WASM);

0 comments on commit f0ff3ef

Please sign in to comment.