diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2024-01-28 12:06:58 +0100 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2024-01-28 12:06:58 +0100 |
commit | a6cb7f4f88f2471e6329298230bb64827c852348 (patch) | |
tree | a95648a15831bf5f7f974a1df24e9695867bf5c0 | |
parent | 02231403df6241d08ea61600713fc1565bb22956 (diff) |
close but not thereflake
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Cargo.lock | 65 | ||||
-rw-r--r-- | Cargo.toml | 10 | ||||
-rw-r--r-- | flake.lock | 94 | ||||
-rw-r--r-- | flake.nix | 39 | ||||
-rw-r--r-- | src/main.rs | 6 |
6 files changed, 170 insertions, 47 deletions
@@ -1 +1,2 @@ -/target +target +result @@ -1,28 +1,30 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "c_vec" -version = "1.3.3" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8a318911dce53b5f1ca6539c44f5342c632269f0fa7ea3e35f32458c27a7c30" +checksum = "fdd7a427adc0135366d99db65b36dae9237130997e560ed61118041fb72be6e8" [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "getrandom" -version = "0.1.14" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -37,34 +39,32 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.73" +version = "0.2.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "ppv-lite86" -version = "0.2.8" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "rand" -version = "0.7.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "getrandom", "libc", "rand_chacha", "rand_core", - "rand_hc", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", @@ -72,27 +72,18 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.5.1" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] [[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core", -] - -[[package]] name = "sdl2" -version = "0.34.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fb006600d16da4f1f1e5c7b398f44af2f1b476ff5f2e555651bd78cf4c18d8" +checksum = "8356b2697d1ead5a34f40bcc3c5d3620205fe0c7be0a14656223bfeec0258891" dependencies = [ "bitflags", "c_vec", @@ -103,9 +94,9 @@ dependencies = [ [[package]] name = "sdl2-sys" -version = "0.34.2" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed17d6d46b62b7df12134513bcc4f071268963e8c9bc8bf7ad983fbfb2bc3cc" +checksum = "26bcacfdd45d539fb5785049feb0038a63931aa896c7763a2a12e125ec58bd29" dependencies = [ "cfg-if", "libc", @@ -114,15 +105,15 @@ dependencies = [ [[package]] name = "version-compare" -version = "0.0.10" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" [[package]] name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "web" @@ -1,11 +1,9 @@ [package] name = "web" version = "0.1.0" -authors = ["Tom Barrett <tom@tombarrett.xyz>"] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +authors = ["tom barrett <tom@tombarrett.xyz>"] +edition = "2021" [dependencies] -sdl2 = {version = "0.34", features = ["gfx"]} -rand = "0.7.3" +sdl2 = {version = "0.36", features = ["gfx"]} +rand = "0.8.5" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ad7131a --- /dev/null +++ b/flake.lock @@ -0,0 +1,94 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1706173671, + "narHash": "sha256-lciR7kQUK2FCAYuszyd7zyRRmTaXVeoZsCyK6QFpGdk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4fddc9be4eaf195d631333908f2a454b03628ee5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1681358109, + "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1706407941, + "narHash": "sha256-MAz9Oz6ddtJzK0UFzYMRrO99cCVcpYD6+MfTMiJdN/8=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "ca8b329ae48f3c760f0e7e0249e8afa50edc8ed1", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..5bff2cc --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs = { + rust-overlay.url = "github:oxalica/rust-overlay"; + }; + outputs = { + self, + nixpkgs, + rust-overlay, + }: let + overlays = [(import rust-overlay)]; + system = "x86_64-linux"; + pkgs = import nixpkgs { + inherit system overlays; + }; + asmjs-rust-bin = pkgs.rust-bin.stable.latest.default.override { + targets = ["asmjs-unknown-emscripten"]; + }; + rustPlatform = pkgs.makeRustPlatform { + cargo = asmjs-rust-bin; + rustc = asmjs-rust-bin; + }; + in { + packages.x86_64-linux.default = rustPlatform.buildRustPackage rec { + name = "web"; + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + doCheck = false; + HOME = "$TMPDIR"; + buildPhase = '' + cargo build --target asmjs-unknown-emscripten --release + ''; + nativeBuildInputs = [pkgs.SDL2 pkgs.SDL2_gfx pkgs.emscripten]; + RUST_BACKTRACE = "full"; + buildInputs = [pkgs.python3Packages.requests]; + }; + }; +} diff --git a/src/main.rs b/src/main.rs index edf6f2e..0c65830 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ pub mod emscripten; fn find_origin() -> (i16, i16) { let mut rng = rand::thread_rng(); - (rng.gen_range(100, 400), rng.gen_range(100, 400)) + (rng.gen_range(100..400), rng.gen_range(100..400)) } struct Line { @@ -74,8 +74,8 @@ fn main() { let mut rng = rand::thread_rng(); lines.shuffle(&mut rng); - let a = rng.gen_range(-7.0, 7.0); - let b = rng.gen_range(-7.0, 7.0); + let a = rng.gen_range(-7.0..7.0); + let b = rng.gen_range(-7.0..7.0); let mut pixels = Vec::new(); for i in (1000..200000).step_by(10) { |