inital commit, scaffolding
commit
c16f4793fe
@ -0,0 +1,34 @@
|
|||||||
|
[unstable]
|
||||||
|
codegen-backend = true
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
codegen-backend = "cranelift"
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
codegen-backend = "llvm"
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
opt-level = "z"
|
||||||
|
lto = "thin"
|
||||||
|
|
||||||
|
[profile.wasm-dev]
|
||||||
|
inherits = "dev"
|
||||||
|
codegen-backend = "llvm"
|
||||||
|
|
||||||
|
[profile.wasm-release]
|
||||||
|
inherits = "release"
|
||||||
|
opt-level = "s"
|
||||||
|
strip = "debuginfo"
|
||||||
|
|
||||||
|
[target.x86_64-unknown-linux-gnu]
|
||||||
|
linker = "clang"
|
||||||
|
rustflags = [
|
||||||
|
# (Nightly) Make the current crate share its generic instantiations
|
||||||
|
"-Zshare-generics=y",
|
||||||
|
# lld linker
|
||||||
|
"-C", "link-arg=-fuse-ld=lld"
|
||||||
|
]
|
||||||
|
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
.direnv/
|
||||||
|
**/target/
|
||||||
|
dist/*
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
[dependencies.engine]
|
||||||
|
path = "../engine"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
use engine::*;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
App::new()
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
|||||||
|
[package]
|
||||||
|
name = "engine"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = "0.18.1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
dev = ["bevy/dynamic_linking", "bevy/file_watcher", "bevy/debug", "bevy/bevy_light", "bevy/free_camera"]
|
||||||
|
web = []
|
||||||
|
|
||||||
|
# Enable a small amount of optimization in the dev profile.
|
||||||
|
[profile.dev]
|
||||||
|
opt-level = 1
|
||||||
|
|
||||||
|
# Enable a large amount of optimization in the dev profile for dependencies.
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
pub use bevy::{color::palettes::basic::*, input::common_conditions::*, prelude::*, platform::collections::HashSet};
|
||||||
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1780243769,
|
||||||
|
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs_2": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1744536153,
|
||||||
|
"narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs_2"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1780456895,
|
||||||
|
"narHash": "sha256-CvRZn3Ut0scqLJ1xwQFkZwKGVBUUNBPrFVXRTMZpbfU=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "7cc96a6a3fd6613cafd633250a3934483479b9a1",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
outputs = { self, nixpkgs, utils, rust-overlay }: utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ rust-overlay.overlays.default ];
|
||||||
|
};
|
||||||
|
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
rust
|
||||||
|
|
||||||
|
# Linker toolchain (.cargo/config.toml: linker = "clang", -fuse-ld=lld)
|
||||||
|
clang
|
||||||
|
lld
|
||||||
|
|
||||||
|
# automatic rebuild
|
||||||
|
watchexec
|
||||||
|
|
||||||
|
# agent issue tracking
|
||||||
|
beans
|
||||||
|
|
||||||
|
# Like make, but just...
|
||||||
|
just
|
||||||
|
|
||||||
|
# Web toolchain
|
||||||
|
###
|
||||||
|
# $ cargo install -f wasm-bindgen-cli --version 0.2.122
|
||||||
|
# wasm-bindgen
|
||||||
|
###
|
||||||
|
# Provides: wasm-opt
|
||||||
|
binaryen
|
||||||
|
simple-http-server
|
||||||
|
|
||||||
|
# Bevy Linux dependencies
|
||||||
|
alsa-lib
|
||||||
|
libudev-zero
|
||||||
|
libxkbcommon
|
||||||
|
pkg-config
|
||||||
|
udev
|
||||||
|
vulkan-loader
|
||||||
|
wayland
|
||||||
|
libX11
|
||||||
|
libXcursor
|
||||||
|
libXi
|
||||||
|
libXrandr
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook = ''
|
||||||
|
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath [ pkgs.vulkan-loader pkgs.wayland pkgs.libxkbcommon pkgs.udev pkgs.alsa-lib ]}:$LD_LIBRARY_PATH"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
export CARGO_TARGET_DIR := justfile_directory() / "target"
|
||||||
|
|
||||||
|
default:
|
||||||
|
@just --list
|
||||||
|
|
||||||
|
# Create a new prototype or full game
|
||||||
|
# Usage: just new prototypes/new-experiment
|
||||||
|
# just new foo
|
||||||
|
new target:
|
||||||
|
scripts/new {{target}}
|
||||||
|
|
||||||
|
# Run a debug build
|
||||||
|
run target:
|
||||||
|
scripts/run {{target}}
|
||||||
|
|
||||||
|
# Watch for changes and re-run
|
||||||
|
develop target:
|
||||||
|
scripts/develop {{target}}
|
||||||
|
|
||||||
|
# Clippy check
|
||||||
|
check target:
|
||||||
|
scripts/check {{target}}
|
||||||
|
|
||||||
|
# Release build
|
||||||
|
build target:
|
||||||
|
scripts/build {{target}}
|
||||||
|
|
||||||
|
# Format all projects
|
||||||
|
fmt:
|
||||||
|
scripts/fmt
|
||||||
|
|
||||||
|
# Build a wasm32 release and optimize with wasm-opt; output goes to dist/<target>/
|
||||||
|
webbuild target:
|
||||||
|
scripts/webbuild {{target}}
|
||||||
|
|
||||||
|
# Serve a built web target from dist/<target>/ via simple-http-server
|
||||||
|
serve target:
|
||||||
|
scripts/serve {{target}}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
[package]
|
||||||
|
name = "prototypes"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bevy = "0.18.1"
|
||||||
|
|
||||||
|
[dependencies.engine]
|
||||||
|
path = "../engine"
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
targets = ["wasm32-unknown-unknown"]
|
||||||
|
components = ["rust-src", "rust-analyzer", "clippy", "rustc-codegen-cranelift-preview"]
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
cd prototypes
|
||||||
|
FLAGS="--release --bin $(basename "${TARGET}")"
|
||||||
|
else
|
||||||
|
cd "${TARGET}"
|
||||||
|
FLAGS="--release"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo build ${FLAGS}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
cd prototypes
|
||||||
|
FLAGS="--bin $(basename "${TARGET}")"
|
||||||
|
else
|
||||||
|
cd "${TARGET}"
|
||||||
|
FLAGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo check ${FLAGS}
|
||||||
|
cargo clippy ${FLAGS}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
WATCH_PATH=prototypes/src/bin/
|
||||||
|
else
|
||||||
|
WATCH_PATH="${TARGET}/src/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
watchexec --stop-signal SIGINT -w "${WATCH_PATH}" just run "${TARGET}"
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
for dir in $(find . -mindepth 2 -maxdepth 2 -name "Cargo.toml" -not -path "*/target/*" -exec dirname {} \;);
|
||||||
|
do
|
||||||
|
cargo fmt --manifest-path "$dir/Cargo.toml";
|
||||||
|
done
|
||||||
|
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
name="$(basename ${TARGET})"
|
||||||
|
file="prototypes/src/bin/${name}.rs"
|
||||||
|
[[ -f "$file" ]] && { echo "already exists: $file"; exit 1; }
|
||||||
|
cp .templates/main.rs "$file"
|
||||||
|
echo "created: $file"
|
||||||
|
else
|
||||||
|
cargo init "${TARGET}"
|
||||||
|
cp .templates/deps.toml >> "${TARGET}/Cargo.toml"
|
||||||
|
echo "created: ${TARGET}/"
|
||||||
|
fi
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
cd prototypes
|
||||||
|
FLAGS="--bin $(basename "${TARGET}")"
|
||||||
|
else
|
||||||
|
cd "${TARGET}"
|
||||||
|
FLAGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
cargo run ${FLAGS}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
|
DIST="${REPO_ROOT}/dist/${TARGET}"
|
||||||
|
|
||||||
|
simple-http-server "${DIST}"
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
TARGET=$1
|
||||||
|
NAME="$(basename "${TARGET}")"
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
|
DIST="${REPO_ROOT}/dist/${TARGET}"
|
||||||
|
PROFILE="wasm-release"
|
||||||
|
RUST_TARGET="wasm32-unknown-unknown"
|
||||||
|
BUILD_FLAGS="--profile ${PROFILE} --target ${RUST_TARGET} --features engine/web"
|
||||||
|
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
BUILD_DIR="${REPO_ROOT}/prototypes"
|
||||||
|
BUILD_FLAGS="${BUILD_FLAGS} --bin ${NAME}"
|
||||||
|
else
|
||||||
|
BUILD_DIR="${REPO_ROOT}/${TARGET}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build
|
||||||
|
(cd "${BUILD_DIR}" && cargo build ${BUILD_FLAGS})
|
||||||
|
|
||||||
|
WASM="${CARGO_TARGET_DIR}/${RUST_TARGET}/${PROFILE}/${NAME}.wasm"
|
||||||
|
|
||||||
|
# wasm-bindgen
|
||||||
|
mkdir -p "${DIST}"
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
rm -rf ${DIST}/*.wasm ${DIST}/*.js ${DIST}/*.html
|
||||||
|
|
||||||
|
wasm-bindgen \
|
||||||
|
--no-typescript \
|
||||||
|
--target web \
|
||||||
|
--out-dir "${DIST}" \
|
||||||
|
--out-name "bin" \
|
||||||
|
"${WASM}"
|
||||||
|
|
||||||
|
# wasm-opt size pass
|
||||||
|
wasm-opt -Oz \
|
||||||
|
-o "${DIST}/bin_bg-tmp.wasm" \
|
||||||
|
"${DIST}/bin_bg.wasm"
|
||||||
|
mv "${DIST}/bin_bg-tmp.wasm" "${DIST}/bin_bg.wasm"
|
||||||
|
|
||||||
|
# HTML template
|
||||||
|
cp "${REPO_ROOT}/web/index.html" "${DIST}/index.html"
|
||||||
|
|
||||||
|
# Assets
|
||||||
|
if [[ "${TARGET}" == prototypes/* ]]; then
|
||||||
|
ASSETS_SRC="${REPO_ROOT}/prototypes/assets/${NAME}"
|
||||||
|
else
|
||||||
|
ASSETS_SRC="${REPO_ROOT}/${TARGET}/assets"
|
||||||
|
fi
|
||||||
|
ASSETS_DST="${DIST}/assets"
|
||||||
|
|
||||||
|
if [[ -d "${ASSETS_SRC}" ]]; then
|
||||||
|
mkdir -p "$(dirname "${ASSETS_DST}")"
|
||||||
|
rm -rf "${ASSETS_DST}"
|
||||||
|
cp -r "${ASSETS_SRC}" "${ASSETS_DST}"
|
||||||
|
fi
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<body style="margin: 0px;">
|
||||||
|
<script type="module">
|
||||||
|
import init from './bin.js'
|
||||||
|
|
||||||
|
init().catch((error) => {
|
||||||
|
if (!error.message.startsWith("Using exceptions for control flow, don't mind me. This isn't actually an error!")) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue