From f8bed3111ff3502b96b2e504380cc92923613b12 Mon Sep 17 00:00:00 2001 From: Elijah Voigt Date: Fri, 13 Dec 2024 13:15:47 -0800 Subject: [PATCH] saving place --- .cargo/config.toml | 13 ++++---- Makefile | 83 +++++++++++++++++++++++++++++++++------------- flake.nix | 6 ++-- src/menu.rs | 18 ++++++---- 4 files changed, 81 insertions(+), 39 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 0b6db5f..26e1361 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,11 +1,12 @@ -# [unstable] -# codegen-backend = true +[unstable] +codegen-backend = true -# [profile.dev] -# codegen-backend = "cranelift" +[profile.quick] +inherits = "dev" +codegen-backend = "cranelift" -# [profile.dev.package."*"] -# codegen-backend = "llvm" +[profile.quick.package."*"] +codegen-backend = "llvm" # for Linux [target.x86_64-unknown-linux-gnu] diff --git a/Makefile b/Makefile index 50c5ecc..b55c627 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,72 @@ -ifeq ($(PROFILE),release) -RELEASE = --release -PROFILE = release -else -PROFILE = debug -endif +### +target/x86_64-unknown-linux-gnu/release/set: src/* + cargo build --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking --release -target/x86_64-unknown-linux-gnu/$(PROFILE)/set: src/* - cargo build --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking $(RELEASE) +target/x86_64-unknown-linux-gnu/quick/set: src/* + cargo build --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking --profile quick +### -target/wasm32-unknown-unknown/$(PROFILE)/set.wasm: src/* - cargo build --target wasm32-unknown-unknown $(RELEASE) +### +target/wasm32-unknown-unknown/debug/set.wasm: src/* + cargo build --target wasm32-unknown-unknown -out/$(PROFILE)/set.js: target/wasm32-unknown-unknown/$(PROFILE)/set.wasm - wasm-bindgen --no-typescript --target web --out-dir "./out/$(PROFILE)" ./target/wasm32-unknown-unknown/$(PROFILE)/set.wasm +target/wasm32-unknown-unknown/release/set.wasm: src/* + cargo build --target wasm32-unknown-unknown --release +### -out/$(PROFILE)/assets: - rm -rf ./out/$(PROFILE)/assets - cp -r ./assets ./out/$(PROFILE)/ +### +out/debug/set.js: target/wasm32-unknown-unknown/debug/set.wasm + wasm-bindgen --no-typescript --target web --out-dir "./out/debug" ./target/wasm32-unknown-unknown/debug/set.wasm -out/$(PROFILE)/index.html: - cp index.html ./out/$(PROFILE)/index.html +out/release/set.js: target/wasm32-unknown-unknown/release/set.wasm + wasm-bindgen --no-typescript --target web --out-dir "./out/release" ./target/wasm32-unknown-unknown/release/set.wasm +### -native/build: target/x86_64-unknown-linux-gnu/$(PROFILE)/set +### +out/debug/assets: + rm -rf ./out/debug/assets + cp -r ./assets ./out/debug/ -native/run: native/build - cargo run --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking $(RELEASE) +out/release/assets: + rm -rf ./out/release/assets + cp -r ./assets ./out/release/ +### -web/build: out/$(PROFILE)/set.js out/$(PROFILE)/assets out/$(PROFILE)/index.html +### +out/debug/index.html: + cp index.html ./out/debug/index.html -web/serve: web/build - cd ./out/$(PROFILE)/; simple-http-server +out/release/index.html: + cp index.html ./out/release/index.html +### + +### +native/debug/build: target/x86_64-unknown-linux-gnu/quick/set + +native/release/build: target/x86_64-unknown-linux-gnu/release/set +### + +### +native/debug/run: native/debug/build + cargo run --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking --profile quick + +native/release/run: native/release/build + cargo run --target x86_64-unknown-linux-gnu --features bevy/dynamic_linking --release +### + +### +web/debug/build: out/debug/set.js out/debug/assets out/debug/index.html + +web/release/build: out/release/set.js out/release/assets out/release/index.html +### + +### +web/debug/serve: web/debug/build + cd ./out/debug/; simple-http-server + +web/release/serve: web/release/build + cd ./out/release/; simple-http-server +### clean: rm ./target/*/*/set* diff --git a/flake.nix b/flake.nix index 59105ad..e905f10 100644 --- a/flake.nix +++ b/flake.nix @@ -28,10 +28,10 @@ ]; nativeBuildInputs = with pkgs; [ libxkbcommon - (rust-bin.stable.latest.default.override { - extensions = [ "rust-src" "clippy" ]; + (rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ "rust-src" "clippy" "rustc-codegen-cranelift-preview" ]; targets = [ "x86_64-unknown-linux-gnu" "wasm32-unknown-unknown" ]; - }) + })) ]; all_deps = with pkgs; [ cargo-flamegraph diff --git a/src/menu.rs b/src/menu.rs index 9d1e4d6..ee1bdf9 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -165,6 +165,9 @@ fn setup_how_to_play(mut commands: Commands, deck: Res) { position_type: PositionType::Absolute, width: Val::Percent(100.0), height: Val::Percent(100.0), + align_items: AlignItems::Center, + justify_content: JustifyContent::Center, + flex_direction: FlexDirection::Column, ..default() }, )) @@ -182,13 +185,14 @@ fn setup_how_to_play(mut commands: Commands, deck: Res) { .observe(button_set_state(ViewState::Menu)); parent.spawn((Node { - align_items: AlignItems::Center, - justify_content: JustifyContent::Center, - flex_direction: FlexDirection::Column, - ..default() - }, - BackgroundColor(BLACK.with_alpha(0.9).into()), + align_items: AlignItems::Center, + justify_content: JustifyContent::Center, + flex_direction: FlexDirection::Column, + ..default() + }, + BackgroundColor(BLACK.with_alpha(0.9).into()), )).with_children(|parent| { + parent.spawn((Text("How to Play".into()), TextFont::default().with_font_size(30.0))); let most_matching = ( Card { color: ItemColor::Red, @@ -255,7 +259,7 @@ fn setup_how_to_play(mut commands: Commands, deck: Res) { ("For example all agree on Color, Shading, and Shape but not Number...", Some(most_matching)), ("...or all agree on Number but not Color, Number, Shading, and Shape...", Some(most_not_matching)), ("...but never partial agreement on a trait...", Some(not_valid)), - ("When in doubt, click the 'Help!' button to get an assist", None), + ("When in doubt, click the 'Help!' button to get an assist.", None), ] .iter() .for_each(|(t, example)| {