Skip to content

Commit

Permalink
feat: add no-sync feature and flexible feature handling in Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
sanity committed Jan 14, 2025
1 parent 1c601ce commit ce623e7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
23 changes: 21 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ CARGO_MAKE_WORKSPACE_INCLUDE_MEMBERS = ["contracts/room-contract", "ui"]
CONTRACT_TARGET = "wasm32-unknown-unknown"
CONTRACT_NAME = "room_contract"
BUILD_PROFILE = "release"
# Comma-separated list of features to enable
UI_FEATURES = ""

[tasks.clean]
description = "Clean build artifacts"
Expand All @@ -24,14 +26,31 @@ args = ["build", "--profile", "${BUILD_PROFILE}", "--target", "${CONTRACT_TARGET
description = "Build the Dioxus UI"
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}"]
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"

[tasks.build-ui-example]
description = "Build the Dioxus UI with example data"
env = { UI_FEATURES = "example-data" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "example-data"]
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"

[tasks.build-ui-no-sync]
description = "Build the Dioxus UI without Freenet sync"
env = { UI_FEATURES = "no-sync" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"

[tasks.build-ui-example-no-sync]
description = "Build the Dioxus UI with example data and no Freenet sync"
env = { UI_FEATURES = "example-data,no-sync" }
dependencies = ["build-contract"]
command = "dx"
args = ["build", "--${BUILD_PROFILE}", "--features", "${UI_FEATURES}"]
cwd = "./ui"

[tasks.build]
Expand Down
1 change: 1 addition & 0 deletions ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors = ["Ian Clarke <[email protected]>"]

[features]
example-data = []
no-sync = []

[dependencies]
bs58 = "0.5.0"
Expand Down
5 changes: 4 additions & 1 deletion ui/src/components/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub fn App() -> Element {
use_context_provider(|| Signal::new(EditRoomModalSignal { room: None }));
use_context_provider(|| Signal::new(CreateRoomModalSignal { show: false }));

FreenetApiSynchronizer::start();
#[cfg(not(feature = "no-sync"))]
{
FreenetApiSynchronizer::start();
}

rsx! {
Stylesheet { href: asset!("./assets/bulma.min.css") }
Expand Down

0 comments on commit ce623e7

Please sign in to comment.